Reputation: 1
I made a bot for my discord, but I named it after myself. So sometimes the bot accidentally gets mentioned instead of me and I don't receive the notification. I wrote some code that if the bot is ever mentioned it will reply with my id so I get the mention.
My problem is: The bot also responds to @everyone, how can I prevent this?
@client.event
async def on_message(message):
if message.author == client.user:
return
if client.user.mentioned_in(message):
await message.channel.send(f'{message.author.mention} You probably meant that message for <@my_id>')
await client.process_commands(message)
Upvotes: 0
Views: 916
Reputation: 2289
You can make a prior if-statement to check if the message mentions everyone, and if so, ignore it.
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.mention_everyone:
return
if client.user.mentioned_in(message):
await message.channel.send(f'{message.author.mention} You probably meant that message for <@my_id>')
await client.process_commands(message)
Upvotes: 2