0

i have code:

bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
    print('Егор выпущен на охоту')



@bot.event
async def on_message(message):
    if message.content.lower().startswith('шутка'):
        await message.channel.send(random.choice(arr2))
        await  bot.process_commands(message)

@bot.command(name="flip")
async def flip(ctx):
    await ctx.send(random.choice(flips))
bot.run('TOKEN')

i tried await bot.process_commands(message) but it didn't help. What could be the issue and how to fix it?

R4mBLe_
  • 3
  • 1
  • 1
    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) – Łukasz Kwieciński Feb 12 '22 at 15:24

1 Answers1

0

The only time bot.process_commands(message) is run in your code is if the user types "шутка", which is not what you want. Instead, take the process outside of the if statement, as seen in the revised code below.

@bot.event
async def on_message(message):
    if message.content.lower().startswith('шутка'):
        await message.channel.send(random.choice(arr2))
    await bot.process_commands(message)
Bagle
  • 2,326
  • 3
  • 12
  • 36
  • 1
    thanks, I needed python only for the bot and did not know about this syntax feature – R4mBLe_ Feb 12 '22 at 12:04
  • 4
    Please next time mark the answer as a duplicate, we don't need the site flooded with the same question over and over again. (https://stackoverflow.com/questions/49331096/why-does-on-message-stop-commands-from-working) – Łukasz Kwieciński Feb 12 '22 at 15:24
  • @ŁukaszKwieciński Thank you, I didn't realize that there was a duplicate of this question, I will ensure to thoroughly check the next time – Bagle Feb 13 '22 at 02:33
  • Also, I had a look at the question linked, and though it does mention `process`, R4mBLe_ already had that in their question. Instead, they had an indentation problem, which the linked question does not include. Once again, thank you for the comment and feedback, as I'm sure there are already answers that exist that answer this page's question. – Bagle Feb 13 '22 at 03:05