-1

I am trying to make a discord bot. However some of my commands have had to be done on the outdated on_message event because they wont work under the commands extension. Is there any line of code i need to add to make the command extension work at the same time. What i mean is i have some on_message events and when i add a @client.command to the end of the code the @client.command commands wont respond.

Here is an example code of what i am trying to achieve here.

@client.event
async def on_message(message):
    if message.content.startswith('ggg'):
        print('hello')
    elif message.content.startswith('hello')
        print('hello')

@client.command()
async def example():
    print('hello')

Obviously the code would be more developed. That was just an example.

Modz
  • 3
  • 5
  • 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) – Patrick Haugh Jun 02 '20 at 13:35

1 Answers1

1

Of course it can work. Only thing you need to know is await client.process_commands(message). In discord.py docs you can read about this issue.

Also check this: on_message() and @bot.command issue

Thundo
  • 174
  • 2
  • 11