on_guild_join() 不工作,不抛出任何错误

on_guild_join() not working and not throwing any errors

所以,我使用 Python 3.9 制作了一个 Discord 机器人来计算您的邀请。但是,我遇到了 on_member_join() 的问题。即使成员加入,它也不会调用函数或抛出错误。 TIA

@bot.event
async def on_member_join(member):
    print("A member {} joined!".format(member))

您必须启用 intents.members,方法如下:

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(..., intents=intents)

还记得在 developer portal

中启用它们

docs