discord.py how do I get a bot to send a message when a specific user types?

Viewed 243

I'm trying to get my bot to type when a specific member types. How would I be able to use their ID, or get their discord ID and allow the bot to use it to detect that they are the author of the message

1 Answers

The simplest way to do so is to use the ID of that user as reference

If you have developer mode activated on your personal discord client, right click on a user and click "copy the ID" (or something like that)

Now, on the discord.py API, you can find everything you need about objets and their attributes.

the Message class has a author attribute which is of class Member. And the Member class has a id attribute, which is an integer. You should write inside the on_message method:

async def on_message(self, message):
    if message.author.id == id_of_the_user_as_integer:
        # Do what you want

Related