标题描述了一切。 请尽可能简单,因为我昨天开始编写我的机器人。谢谢 代码:
@bot.command(name='leave', help='leave from a voice channel')
async def leave(ctx):
if ctx.author.voice == ctx.voice_client.channel: # <-- this doesn't work
if (ctx.voice_client):
channel = ctx.author.voice.channel
await ctx.guild.voice_client.disconnect()
await ctx.send(f'I left from {channel}')
else:
await ctx.send("I'm not to a voice channel to leave.")
else:
await ctx.send('You are not allowed to do that')
答案 0 :(得分:0)
根据您的其他代码,检查应如下所示?
if ctx.author.voice.channel == ctx.voice_client.channel