[英]How do I make my discord bot respond when a specific user sends a message in the channel?
[英]I want my discord bot to respond if a specific message is coming from a specific user
到目前为止,我设法找到的最佳解决方案是检查用户 ID。 ''' @client.event async def on_message(message):
if(message.author == client.user): #if message is coming from the bot itself
return
if(message.author.id == 103001222035981612 and message.content.startswith == 'Yo'):
await message.channel.send('Hello {}'.format(message.author.name))
#await message.channel.send(message.content)
客户端运行(令牌)'''
最终发生的是,无论我说什么,机器人都会做出响应,这不是我想要它做的。 我尝试了其他一些方法,但没有任何帮助。 我很感激我能得到的任何帮助。 谢谢!
确保在最后添加这个
*await client.process_commands(message)*
例子:
@client.event
async def on_message(message):
if message.author == client.user:
return
if client.user.mentioned_in(message):
await message.channel.send("hey!")
await client.process_commands(message)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.