python - 我的 on_member_join 没有发送欢迎消息
问题描述
所以,我正在为我所在的服务器制作一个机器人,并尝试在成员加入时添加欢迎消息。到目前为止,它一直没有工作,也没有给出错误。有什么问题吗?
async def on_member_join(member):
print("working") #I have this here to check to see if its being called, but no message is printed.
rules = client.get_channel(772263419210235916)
verify = client.get_channel(772995392521895937)
channel = client.get_channel(772583213797212211)
embed=discord.Embed(title="Welcome to Delight Stuidos!",
description=f"""{member.mention} has joined! \nDon't forget to read the {rules.mention}, and react with the purple star in {verify.mention}!
Enjoy your stay ^^""",
color = discord.Colour.orange())
embed.set_thumbnail(url=f"https://i.ibb.co/NC2Wgnk/DS.png")
await channel.send(embed=embed)
还启用了意图,所以我不知道发生了什么。
解决方案
更改了一些可能导致错误的内容
async def on_member_join(member):
try:
print("working") #I have this here to check to see if its being called, but no message is printed.
rules = member.guild.get_channel(772263419210235916)
verify = member.guild.get_channel(772995392521895937)
channel = member.guild.get_channel(772583213797212211)
embed=discord.Embed(title="Welcome to Delight Stuidos!",
description=f"{member.mention} has joined! \nDon't forget to read the {rules.mention}, and react with the purple star in {verify.mention}!\n Enjoy your stay ^^",
color = discord.Colour.orange())
embed.set_thumbnail(url="https://i.ibb.co/NC2Wgnk/DS.png")
await channel.send(embed=embed)
except Exception as e:
print(e)
推荐阅读
- git - 如何在 gitlab 中 git clone 后包含文件
- python - 基于没有重复的键合并两个字典
- python - 如何在 python 3 中的字典上使用随机模块?
- java - 热点服务能力代理如何处理elf文件中的GOT?
- python - 如何打印 ndarray 完成信息?
- java - 将 XML 格式的字符串解析为 Java 对象
- mysql - OperationalError(1366,“不正确的字符串值:'\\xE2\\x80\\x8ESen...')MySQL Django
- reactjs - 当我从列表中选择新链接时,反应子功能类不会重新呈现
- android - 为什么可检查的菜单项不显示复选框
- typescript - 基于另一个对象的 arras 类型对象