Reputation: 33
i want to make my Discord BOT do something like this :
If i say 'react' the BOT will respond
If someone else than me says 'react' the BOT will not respond
I've tried this code bellow but it don't work for me
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!')
Maybe i wrote something wrong in the code? please tell me it'll help me a lot!
Upvotes: 0
Views: 3860
Reputation: 33
It's my mistake i guess so i did write like this before
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!')
I should not put (brackets) after message.author.id
and this is the correct one
if message.author.id == <ID goes here> and message.content.lower() == 'react':
await message.channel.send('reacted!')
Upvotes: 0
Reputation: 418
That should do exactly what you want:
@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
Upvotes: 2