首页 > 解决方案 > 类“Bot”的未解析属性引用“voice_client_in”

问题描述

我想制作一个可以排队歌曲的不和谐机器人。我在这里看到了一个代码,但代码显示了这样的错误:

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'

那我该怎么办?

标签: pythondiscord.py

解决方案


is_voice_connected已过时

你应该使用Guild.voice_client

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

推荐阅读