aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daniel Gu <[email protected]>2023-05-02 11:42:35 +0800
committerGravatar GitHub <[email protected]>2023-05-02 11:42:35 +0800
commite136edbfc7026318a000d81c861905cdd0f44af8 (patch)
tree24d6ab363384869e2fedf5bbff90a9e5fe4dc156
parentMerge branch 'main' into on-message-event-tag (diff)
Update bot/resources/tags/on-message-event.md
Co-authored-by: Canttuchdiz <[email protected]>
-rw-r--r--bot/resources/tags/on-message-event.md6
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.