我试图让我的 discord.py bot 加入我所在的 vc。但是当我运行命令时,bot 不想加入 vc。我该如何解决这个问题?谢谢。代码如下。
@bot.command()
async def join(ctx):
channel = ctx.message.author.voice.voice_channel
await bot.join_voice_channel(channel)
答案 0 :(得分:2)
根据 discord.Member.voice
的文档(您在哪里执行 ctx.message.author.voice
...),voice_channel
不是有效属性。 channel
是一个有效的属性。
此外,您不必执行 ctx.message.author
,而是使用 ctx.author
。快得多。
因此,您的变量 channel
可以这样定义,您应该像这样连接到频道:
channel = ctx.author.voice.channel
await channel.connect()
这应该有效。