无法让 Discord 机器人在 Python 中离开语音频道

Can't make Discord bot leave the voice channel in Python

我试图让我的 Discord 机器人在有人输入 "leave" 作为消息时离开语音频道,但我没有收到任何错误,机器人也没有断开连接。有人可以帮助我吗?

@client.command(pass_context=True)
async def leave(ctx):
    server = ctx.message.guild.voice_client
    await server.disconnect()

在某些情况下,语音客户端可能会进入不良状态,并认为您未连接,而实际上您已连接。尝试为 VoiceClient.disconnect 使用 force 参数,并在断开连接时将其设置为 True