我想让Discord BOT做这样的事情:
如果我说“反应”,那么BOT会回应
如果我以外的人说“反应”,那么BOT将不会响应
我已经在下面尝试了此代码,但对我而言不起作用
if message.author.id == ('<User ID here>') and message.content.lower() == 'react':
await message.channel.send('i am only react to my Master not others!')
也许我在代码中写错了?请告诉我,它将对我有很大帮助!
答案 0 :(得分:1)
这应该完全符合您的要求:
@client.event
#We create an on message event
async def on_message(message):
#We check if the the message that has been sent equals react
if "react" in message.content:
#We check that the person who sent the message is you
if type(message.author) == discord.user.ClientUser:
#Do something
else:
#Do something else
else:
pass
答案 1 :(得分:0)
这是我的错误,我猜,所以我以前确实写过这样的书
if message.author.id == ('<User ID here>') and message.content.lower() == 'react':
await message.channel.send('i am only react to my Master not others!')
我不应该在括号message.author.id
之后加上括号,这是正确的
if message.author.id == <ID goes here> and message.content.lower() == 'react':
await message.channel.send('reacted!')