on_member_join 和删除不起作用.如何让它发挥作用?

2022-01-14 00:00:00 python discord.py

问题描述

我不知道为什么,但这两个命令对我不起作用.

I don't know why but those 2 commands don't work for me.

@client.event
async def on_member_join(member):
    ver_Channel = client.get_channel(799666119787020289)
    await ver_Channel.send(member+ " have joined the server!")


@client.event
async def on_member_remove(member):
    ver_Channel = client.get_channel(799666119787020289)
    await ver_Channel.send(member + " have been left :(")

顺便说一句,请写下基本的编码说明我是初学者

btw please write in basic coding explanation I'm a beginner


解决方案

我很确定这是一个意图问题,你应该启用 intents.members

I'm pretty sure this is an intents issue, you should enable intents.members

intents = discord.Intents.default() # Enabling everything apart from privileged intents (members & presences)
intents.members = True # Explicitly enabling `intents.members`

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

还要确保在开发者门户

如何启用特权网关意图

相关文章