Search code examples
pythonpython-3.xdiscorddiscord.pybots

How do I make it so that the bot only responds to direct pings or replies?


I want to make it so that the bot only responds to direct pings or replies.

I tried this:

if client.user.mentioned_in(message):

But if I use that, the bot will also respond to @everyone and @here, which I don't want. It must be a direct ping specifically for the bot. Replying to the bot should also work.

How do I do that?


Solution

  • You can simply check if your bot is in the message mentions list:

    if client.user in message.mentions:
        pass