0
votes

my code is

@bot.command()
async def on_message(message):
    if 'Congratulations' in message.content:
        await message.delete(message)

    await bot.process_commands(message)

However whenever I type Congratulations the message wont get deleted

2

2 Answers

0
votes

Do await message.delete() instead of await message.delete(message).

0
votes

Your code provided in your question is a command, it would not be listening for an on_message event, as the command must be invoked by a user.

This is an event applied to your code, it would always wait for a message, only if the message contains "Congratulations", will trigger the message delete

@bot.event
async def on_message(message):
    if 'Congratulations' in message.content:
        await message.delete()

    await bot.process_commands(message)