Discord py bot not triggering and ignoring commands

Viewed 89

I have this bot that checks everytime someone sends a message using an on_message event and for some reason the other commands that the bot has seem to be ignored. I figured that out after removing the function of checking the msgs and the commands work pretty fine.

Here is the on_message event code:

@client.event
async def on_message(message):
    text = message.content
    chann = message.channel.id
    yes1 = False
    yes = False
    for ide in ids:
        if message.author.id == ide:
            yes1 = True
    for strf in comms:
        if text.startswith(strf):
            yes = True
    if (yes == False) and (yes1 == False) and (chann == 822089739502616576) and (message.author.id != 769302967803183124):
        print(message.author.id)
        msg = await message.channel.send('lahne kel el commands ye bhim')
        await message.delete()
        await asyncio.sleep(2)
        print('deleting message')
        await msg.delete()
    if yes and (message.author.id != 769302967803183124) and (message.channel.id == 331562608467509249):
        print(message.author.id)
        msg = await message.channel.send('mech lahne tekteb el commands ye bhim')
        await message.delete()
        await asyncio.sleep(2)
        print('deletingmessage')
        await msg.delete()
    if yes1 and (chann == 331562608467509249) and (message.author.id != 769302967803183124):
        await message.delete()

I don't know where the problem comes from.

1 Answers

You need to add await client.process_commands(message) to the end of your on_message coroutine.

As the docs state:

By default, this coroutine is called inside the on_message() event. If you choose to override the on_message() event, then you should invoke this coroutine as well.

Related