简体   繁体   中英

I wrote code that should give message's (I am blue) author a role, it doesn't work, rewrite my code please

this is my code that should give message author a role:

color roles

@bot.event
async def on_message(ctx, message):
    await bot.process_commands()
    user = ctx.message.author
    msg = message.content.lower
    role = discord.utils.get(discord.guild.roles, name = "blue as alian egg")
    if msg == ['I am blue']:
        await user.add_roles(role)

and this is my errors:

C:\Users\Егор\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/Егор/PycharmProjects/Luiji/Luiji.py
Luiji is ready to work!
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Егор\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
TypeError: on_message() missing 1 required positional argument: 'message'

on_message does not have a ctx, it should just be

async def on_message(message):

That is what the error on_message() missing 1 required positional argument: 'message' means, you have an extra argument, message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM