stuart harper
stuart harper

Reputation: 33

Error code with discord .py

 @bot.command(pass_conetext = True)
async def info(ctx,  user: discord.Member):
    embed = discord.Embed(title = "Super Bot", description = "Thinking" , color = 0x00ff00)
    embed.add_field(name = "Name", value = user.name, inline = True)
    embed.add_field(name = "ID", value = user.id , inline = True)
    embed.add_field(name = "Status", value = user.status , inline = True)
    embed.add_field(name = "Highest Role", value = user.top_role , inline = True)
    embed.add_field(name = "Joined", value = user.joined_at , inline = True)
    embed.set_thumbnail(url = user.avatar_url)

every time i run this code it comes back with this error and i have no idea why

Ignoring exception in command info
Traceback (most recent call last):
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 367, in invoke
    yield from self.prepare(ctx)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 345, in prepare
    yield from self._parse_arguments(ctx)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 304, in _parse_arguments
    transformed = yield from self.transform(ctx, param)
  File "C:\Users\Stuart\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 212, in transform
    raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
discord.ext.commands.errors.MissingRequiredArgument: user is a required argument that is missing.

can somone please explain why and maybe a solution thanx

Upvotes: 2

Views: 896

Answers (2)

Kaneki
Kaneki

Reputation: 109

You can change your code to this to deny the error:

@bot.command(pass_context= True)
async def info(ctx,  user: discord.Member=None):
    if user is None:
        user = ctx.message.author
    embed = discord.Embed(title = "Super Bot", description = "Thinking" , color = 0x00ff00)
    embed.add_field(name = "Name", value = user.name, inline = True)
    embed.add_field(name = "ID", value = user.id , inline = True)
    embed.add_field(name = "Status", value = user.status , inline = True)
    embed.add_field(name = "Highest Role", value = user.top_role , inline = True)
    embed.add_field(name = "Joined", value = user.joined_at , inline = True)
    embed.set_thumbnail(url = user.avatar_url)

Basically if the user is nothing it will give the message authors info..

Upvotes: 0

Joshua Liu
Joshua Liu

Reputation: 41

Whoever ran the command didn't have the user argument.

!info @user instead of !info

Upvotes: 1

Related Questions