diff options
-rw-r--r-- | bot/resources/tags/on-message-event.md | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bot/resources/tags/on-message-event.md b/bot/resources/tags/on-message-event.md index 54980c03f..b5e6fc6b0 100644 --- a/bot/resources/tags/on-message-event.md +++ b/bot/resources/tags/on-message-event.md @@ -7,9 +7,15 @@ Registering the `on_message` event with [`@bot.event`](https://discordpy.readthe Instead, use [`@bot.listen`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.listen) to add a listener. Listeners get added alongside the default `on_message` event, rather than overriding it, so prefix commands can still be invoked as usual: ```python +# Method 1 @bot.listen('on_message') async def message_listener(message): ... # do stuff here + +# Method 2 +async def on_message(message): + ... # do stuff here ``` You can also tell discord.py to process the message for commands as usual at the end of the `on_message` handler with [`bot.process_commands()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.process_commands). However, this method isn't recommended as it does not allow you to add multiple `on_message` handlers. |