Skip to main content
 首页 » 编程设计

python之discord .py 的错误代码

2025年01月19日9luoye11

 @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) 

每次我运行这段代码都会返回这个错误,我不知道为什么

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. 

有人能解释一下为什么吗?也许还有一个解决方案

请您参考如下方法:

运行命令的人没有 user 参数。

!info @user 而不是 !info