Discord.py bot 不会加入 vc

时间:2021-05-13 01:17:27

标签: python discord discord.py

我试图让我的 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)

1 个答案:

答案 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()

这应该有效。