命令引发异常:AttributeError: 'Guild' 对象没有属性 'voice' 错误

时间:2021-01-29 20:18:18

标签: python

我构建了一个音乐机器人,但我犯了一个错误。

我得到的错误正是这样;

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'voice'

命令;

@Bot.command(pass_context=True)
async def play(ctx, url : str):
    voiceChannel = discord.utils.get(ctx.guild.voice.channels, ctx.message.author.voice_channel)
    voice = discord.utils.get(Bot.voice_clients, guild)
    await voiceChannel.connect()
    guild =  ctx.guild

1 个答案:

答案 0 :(得分:0)

尝试使用这个:

voiceChannel = discord.utils.get(ctx.voice_client,ctx.message.author.voice_channel)