Discord.py 为什么不是';我的语音频道代码不工作吗?

Discord.py 为什么不是';我的语音频道代码不工作吗?,discord.py,Discord.py,因此,我使用discord.py rewrite,下面有一段代码,我用它来生成一个命令,可以连接和断开用户与语音频道的连接。由于某些原因,我得到了错误:“非类型”没有“通道”属性。有人能解释为什么会这样吗 @client.command() async def join(ctx): channel = ctx.author.voice.channel await ctx.voice_client.connect() await ctx.send("You ar

因此,我使用discord.py rewrite,下面有一段代码,我用它来生成一个命令,可以连接和断开用户与语音频道的连接。由于某些原因,我得到了错误:“非类型”没有“通道”属性。有人能解释为什么会这样吗


@client.command()
async def join(ctx):
    channel = ctx.author.voice.channel
    await ctx.voice_client.connect()
    await ctx.send("You are Connect to Voice")


@client.command()
async def leave(ctx):
    channel = ctx.author.voice.channel
    await ctx.voice_client.disconnect()
    await ctx.send("You have Disconnected from Voice")


在发布新问题之前,请搜索基本错误消息。如果你这样做了,你会发现同样的问题在这里之前已经被问过很多次了。