0

This is the code I am using. This works, but the rest of the commands do not work. How can I make it so it does not affect other commands?

@client.event
async def on_message(message):
    if message.content.startswith('!'):
        await message.delete()
Syntle
  • 5,168
  • 3
  • 13
  • 34
Riju
  • 77
  • 1
  • 1
  • 5
  • Does this answer your question? [Why does on\_message stop commands from working?](https://stackoverflow.com/questions/49331096/why-does-on-message-stop-commands-from-working) – TheFungusAmongUs Apr 25 '22 at 14:11

1 Answers1

1

Commands also use some sort of on_message in the background therefore by adding your own on_message, you're making it take it as you want to use your own on_message thus blocking the default one. To make it use both, add await client.process_commands(message) to the end of your on_message.

@client.event
async def on_message(message):
    if message.content.startswith('!'):
        await message.delete()
    await client.process_commands(message)
Ecks Dee
  • 455
  • 1
  • 6
  • 15