Python 不和谐机器人 ctx.guild.voice_client.disconnect() 不起作用

问题描述 投票:0回答:1
@bot.command(pass_context = True, help="make bot leave vc")
async def leave(ctx):
    if ctx.voice_client:
        await ctx.guild.voice_client.disconnect()
        await ctx.send('disconnected from vc')

    else:
        await ctx.send('im not currently in a vc')

我试图让一个不和谐的机器人与不和谐的语音通道断开连接,但它不起作用。当我使用该命令时,机器人会发送“与 vc 断开连接”,但实际上并未断开连接。

python discord.py disconnect
1个回答
0
投票

直接使用“ctx.voice_client”。应该是这样的:

@bot.command(pass_context = True, help = "make bot leave vc")

async def leave(ctx):
  if ctx.voice_client:
      await ctx.voice_client.disconnect()
      await ctx.send('disconnected from vc')
  else:
      await ctx.send('im not currently in a vc')
© www.soinside.com 2019 - 2024. All rights reserved.