当特定用户在通道中发送消息时,如何使我的discord bot响应?

2024-04-20 03:57:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我想让我的discord机器人在每次特定用户在聊天中发送消息时都做出响应。代码会运行,但当用户发送消息时不会发生任何事情

这就是我迄今为止所尝试的:

@client.event
async def on_message(message):
    if message.author == client.user:
        return
        
    if message.author.id == '546474118711869440':
        await message.channel.send('shhhhh')

Tags: 代码用户clientevent消息messageasyncif
1条回答
网友
1楼 · 发布于 2024-04-20 03:57:06

它在一根绳子里。您必须将用户id设置为int,因此不能使用引号

if message.author.id == 546474118711869440:
    await message.channel.send('shhhhh')

相关问题 更多 >