Skip to content
Advertisement

Bot Mentions Discord.py

  if client.user.mentioned_in(message):
    await ctx.send("Hi!")

So I want my bot to respond to anyone who @mentions it. It does work as it should, but the only problem it’ll respond to @everyone and @here pings. It’s probably simple and I am overthinking it but I just want to know if there is any way to make the bot respond to messages it’s actually mentioned in, not @everyone or @here pings?

Advertisement

Answer

Check whether the bot’s user id is in the message content. Try the following:

    if str(client.user.id) in message.content:
        await ctx.send("Hi!")
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement