Discord.py bot不会加入vc

2024-06-07 03:31:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图让我的discord.py机器人加入我所在的vc。但是当我运行命令时,bot不想加入vc。我如何解决这个问题?谢谢代码如下

@bot.command()
async def join(ctx):
  channel = ctx.message.author.voice.voice_channel
  await bot.join_voice_channel(channel)

Tags: 代码py命令messageasyncdefbotchannel
1条回答
网友
1楼 · 发布于 2024-06-07 03:31:56

根据^{}的文档(您在其中执行了ctx.message.author.voice…)的操作,voice_channel不是有效的属性channel是一个有效的属性

此外,您不必执行ctx.message.author,而是使用ctx.author。快得多

因此,您的变量channel可以这样定义,您应该像这样连接到通道:

channel = ctx.author.voice.channel
await channel.connect()

这应该行得通

相关问题 更多 >