Riju
Riju

Reputation: 77

On_message command not letting other commands work

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()

Upvotes: 0

Views: 113

Answers (1)

Ecks Dee
Ecks Dee

Reputation: 471

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)

Upvotes: 1

Related Questions