我想编写一个更改特定用户昵称的命令,我编写了以下代码:
async def chnick(ctx, member: discord.Member, nick):
await member.edit(nick="test")
await ctx.send(f'Nickname was changed for {member.mention} ')
python抛出此错误:
Ignoring exception in command chnick:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 847, in invoke
await self.prepare(ctx)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 784, in prepare
await self._parse_arguments(ctx)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 690, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 535, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
请帮帮我!
答案 0 :(得分:0)
您没有指定要编辑的成员。另外,您还应该将nick
参数传递给member.edit()
。您的命令应如下所示:!chnick @member john
@client.command()
async def chnick(ctx, member: discord.Member, *, nick):
await member.edit(nick=nick)
await ctx.send(f'Nickname was changed for {member.mention} ')