不和谐的移动成员



我正在使用 Discord-py API 制作一个不和谐机器人,但我遇到了一个问题,我无法让移动成员工作。

@bot.command(pass_context=True)
 async def w(member = discord.Member):
    await bot.say("Password Correct!")
      await move_member(member, 5)

我收到此错误

Ignoring exception in command w
Traceback (most recent call last):
File "C:Program Files (x86)Python36-32libsite-packagesdiscordextcommandscore.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:UsersRichardDesktopTest Bottestbot2.py", line 29, in w
    await move_member(member, 5)
NameError: name 'move_member' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:Program Files (x86)Python36-32libsite-packagesdiscordextcommandsbot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:Program Files (x86)Python36-32libsite-packagesdiscordextcommandscore.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:Program Files (x86)Python36-32libsite-packagesdiscordextcommandscore.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'move_member' is not defined

有人有我可以使用的例子吗?或任何建议。

您忘了指定bot.move_member . 你的论点也做错了。 如果传递上下文,则函数的第一个参数将是上下文对象。 转换器的语法是 argument: Converter 。签名应async def w(ctx, member: discord.Member):。 此外,要Client.move_member的第二个参数必须是Channel对象。

@bot.command(pass_context=True)
async def move(ctx, member: discord.Member, channel: discord.Channel):
    await bot.say("Password Correct!")
    await bot.move_member(member, channel)

最新更新