我在我的不和机器人中有一个事件,当一个成员加入公会时,它会发送一个嵌入来欢迎他。没有错误产生,但事件似乎不为我工作。
下面是事件的代码:
@bot.event
async def on_member_join(member):
"""
The code in this event is executed every time a member joins the server
"""
embed = discord.embed(title=f'Welcome to {member.guild.name}',
description=f'{member.mention}, welcome to the server! nMake sure to checkout the rules first. Enjoy your stay <3',
color=0x0061ff)
if member.guild.icon is not None:
embed.set_thumbnail(
url=member.guild.icon.url
)
await bot.get_channel(1047615507995562014).send(embed=embed)
我也使用了下面的意图,并正确地启用了它们,所以我知道这不是我的代码的问题。
intents = discord.Intents.all()
intents.members = True
你得到一个错误的原因,是因为e在discord.embed是小写的
embed = discord.embed(title=f'Welcome to {member.guild.name}',
description=f'{member.mention}, welcome to the server! nMake sure to checkout the rules first. Enjoy your stay <3',
color=0x0061ff)
正确的版本显然应该是:
embed = discord.Embed(title=f'Welcome to {member.guild.name}',
description=f'{member.mention}, welcome to the server! nMake sure to checkout the rules first. Enjoy your stay <3',
color=0x0061ff)
您的bot可能缺少特权意图,请转到您的bot上的discord开发人员门户,然后将服务器成员意图打开