【问题标题】:Unresolved attribute reference 'voice_client_in' for class 'Bot'类“Bot”的未解析属性引用“voice_client_in”
【发布时间】:2021-05-16 17:16:42
【问题描述】:

我想制作一个可以对歌曲进行排队的不和谐机器人。我看到了代码here,但代码显示如下错误:

Traceback (most recent call last):
  File "C:\Users\Komputer\PycharmProjects\CiaaBot\venv\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Komputer\PycharmProjects\CiaaBot\venv\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Komputer\PycharmProjects\CiaaBot\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'is_voice_connected'

那我该怎么办?

【问题讨论】:

  • 请在您的问题中向我们展示您的代码。
  • 您正在查看的代码已经过时了,现在 discord.py 不包含is_voice_connected,您应该在其他示例中或尝试通过文档自己实现。

标签: python discord.py


【解决方案1】:

is_voice_connected 已过时

你应该使用Guild.voice_client

@bot.command()
async def queue(ctx):
    if ctx.guild.voice_client: # Its connected to voice
        ...

【讨论】:

    猜你喜欢
    • 2019-08-19
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 2021-08-13
    • 2021-09-30
    • 2017-10-07
    • 2022-08-03
    • 2019-05-04
    相关资源
    最近更新 更多