我想让我的discord机器人在特定成员上线时写一条消息



我似乎不知道如何让机器人程序检查特定成员的状态。

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

client = discord.Client(intents=intents)
@client.event
async def on_member_update(before, after):
if after.status.name == 'online':
await client.get_channel("channel_id").send("message")```

在浏览了文档和一些示例之后。。我认为这应该能解决问题。我们在这里所做的是检查";在"之后;,其是成员对象。在查看文档时,我没有找到status.name,所以我将其更改为str(在.status之后(。然后您可以添加频道ID,它应该按计划工作。如果有任何错误,请告诉我!

intents = discord.Intents.default()
intents.members = True
intents.presences = True
memberid = '123'

client = discord.Client(intents=intents)
@client.event
async def on_member_update(before, after):
if after.id == memberid: # "after" is a member object, so we can check the id if its the same as the "specific member"
if str(after.status) == 'online': #check status
await client.get_channel("channel_id").send("message")