2024-06-07 03:31:56 发布
网友
我试图让我的discord.py机器人加入我所在的vc。但是当我运行命令时,bot不想加入vc。我如何解决这个问题?谢谢代码如下
@bot.command() async def join(ctx): channel = ctx.message.author.voice.voice_channel await bot.join_voice_channel(channel)
根据^{}的文档(您在其中执行了ctx.message.author.voice…)的操作,voice_channel不是有效的属性channel是一个有效的属性
ctx.message.author.voice
voice_channel
channel
此外,您不必执行ctx.message.author,而是使用ctx.author。快得多
ctx.message.author
ctx.author
因此,您的变量channel可以这样定义,您应该像这样连接到通道:
channel = ctx.author.voice.channel await channel.connect()
这应该行得通
根据^{} 的文档(您在其中执行了
ctx.message.author.voice
…)的操作,voice_channel
不是有效的属性channel
是一个有效的属性此外,您不必执行
ctx.message.author
,而是使用ctx.author
。快得多因此,您的变量
channel
可以这样定义,您应该像这样连接到通道:这应该行得通
相关问题 更多 >
编程相关推荐