【问题标题】:Discord-py Move memberDiscord-py 移动成员
【发布时间】:2018-08-19 12:01:54
【问题描述】:

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

@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

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

【问题讨论】:

    标签: python discord discord.py


    【解决方案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)
    

    【讨论】:

      猜你喜欢
      • 2021-07-05
      • 2021-04-20
      • 2020-12-04
      • 2021-03-24
      • 1970-01-01
      • 2021-04-23
      • 2021-02-17
      • 2022-01-25
      • 1970-01-01
      相关资源
      最近更新 更多