discord.py on_message definitions conflicting?

Question:

This is the code:

async def on_message(message):
    if client.user.mentioned_in(message):
        await message.channel.send("Hey!")

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if "$example" in message.content:
        if message.author.id == int(discord id here):
            await message.channel.send("Hi Name")
        if message.author.id == int(discord id here):
            await message.channel.send("Hi Name2")

So, my issue is if I have the second piece of code in, my first piece of code doesn’t work. No error messages, nothing it just doesn’t seem to exist. I’m assuming it would also be the same vice versa.
My question is: I’d like to know what’s causing this and how I should go about fixing it. Is my code incorrect? Am I missing something? Or should I be defining one of them as something else? I’m stuck. Thanks in advance.

Asked By: user17505466

||

Answers:

There can not exist two functions with the same name in the same file. You can try using a cog or merging the code of your functions.

i was having the same problem but i managed to solve it. At the end of the second class put

`await bot.process_commands(message)`
Answered By: Reb3llo
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.