Discord-py移动成员

时间:2018-03-11 09:59:22

标签: python discord discord.py

我使用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-32\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\Richard\Desktop\Test Bot\testbot2.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-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\ext\commands\core.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

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

1 个答案:

答案 0 :(得分:1)

您忘了指定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)