Click here to Skip to main content
15,942,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been working on a Discord bot using discord.py and I am fairly new to Python. I keep getting an error like this:

Quote:
Traceback (most recent call last):
File "main.py", line 34, in <module>
@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'


What I have tried:

I have looked over my code and other similar questions and my code is just like other people's and looks fine. Here is the specific part of the code that had the error:

Python
@bot.event()
async def on_message(message):
    if message.author == bot.user:
        return
    if not message.guild:
        try:
            await message.channel.send("This is a DM.")
        except discord.errors.Forbidden:
            pass
    else:
        pass


If anyone finds anything wrong with it, please tell me.

Thanks!
Posted
Updated 12-Aug-22 0:42am
v2

Decorator bot.event() must not be called.

Refer API Reference : discord.py 1.4.1 documentation[^]

For async calls, don't use blocking library functions.
 
Share this answer
 
v3
make bot.event() into bot.event


I think that is what Rajeev Jayaram meant but I didnt understand it.

(We used the same code snippet from stack overflow and ran into the same issue lol)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900