D
D
DopASfnf2021-12-16 09:04:10
Python
DopASfnf, 2021-12-16 09:04:10

How to make the bot react to a discord.py message?

How to make the bot react to a specific discord.py message?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-12-16
@Vindicar

Google it! This is shown in Quick Start in the discord.py docks.

# вместо client.event может быть bot.event, смотря как названа переменная с объектом бота
@client.event 
async def on_message(message):
    # отсеиваем сообщения, которые отправили мы сами
    if message.author == client.user:
        return
    # а вот тут мы проверяем содержимое сообщения. Это пример.
    # Реальную логику проверки, разумеется, пишешь самостоятельно, под свои нужды.
    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question