Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

discord.py on_message definitions conflicting?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading