on_member_join 函数在 discord.py 中不起作用

时间:2021-03-03 20:36:27

标签: discord.py

我正在开发一个机器人,当用户加入服务器时,on_member_join 函数不起作用。我的函数在一个 cog 中,并且是唯一不起作用的函数,

def __init__(self, client):
    self.client = client

@commands.Cog.listener()
    async def on_ready(self):

@commands.Cog.listener()
    async def on_member_join(self, member):
        print('working')

1 个答案:

答案 0 :(得分:0)

我假设在粘贴这里而不是在实际代码中缩进是错误的。 如果你还没有这样做,新版本的 discord.py 有一个叫做意图的东西。首先,您必须转到 developer portal 并激活它。然后你必须将意图添加到你的代码中。
这将启用所有意图:

intents = discord.Intents.all()
client = commands.Bot(command_prefix = '-', intents=intents)