0

I made a simple event to delete all messages with attachments within a channel and now commands within my bot are not working as intended

the event

@client.event
async def on_message(message):
 if message.attachments and message.channel.id == 957450518463119400:
  await message.delete()
 if not message.attachments and message.channel.id == 957450518463119400:
  await message.send()

an example of a command that isn't working (not sending the "stop" message)

@client.command()
async def damndaniel(ctx: commands.Context):
    await ctx.send(f"stop")

there aren't any errors in terminal. as soon as I remove the event the example command is working fine

ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

rea ldlll
  • 3
  • 1

1 Answers1

3

If you override the on_message() event, you need to add client.process_commands() to your event manually so it should be like this:

@client.event
async def on_message(message):
 if message.attachments and message.channel.id == 957450518463119400:
  await message.delete()

 if not message.attachments and message.channel.id == 957450518463119400:
  await message.send()
 
 await client.process_commands(message)

Reference

3nws
  • 1,391
  • 2
  • 10
  • 21