Reputation: 2041
I'm trying to make an on_message event where if an admin is mentioned it will delete that message and then tell them they can't do that. Here is my code right now
@bot.event
async def on_message(message):
admin_id = "<@496186362886619138>"
if admin_id in message.content:
await message.delete()
await message.channel.send("You can't do that")
await bot.process_commands(message)
Upvotes: 1
Views: 220
Reputation: 2041
Took another look at the documentation and found mentioned_in()
and Client.fetch_user()
.
My final code looks like this:
@bot.event
async def on_message(message):
# DELETE ADMIN MENTION
user = await bot.fetch_user(496186362886619138)
if user.mentioned_in(message):
await message.delete()
await message.channel.send("You can't do that")
await bot.process_commands(message)
Upvotes: 2