Python 我的Discord Bot如何断开与语音频道的连接

Python 我的Discord Bot如何断开与语音频道的连接,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我正在尝试创建一个简单的Discord Bot(Python 3中的wirtten),它只在一个命令后连接和断开连接。Connect命令工作正常,但我的DISCONECT命令不工作。以下是包含两个命令的代码段: async def join(message): channel = message.message.author.voice.channel await channel.connect() @client.command(pass_context = True) a

我正在尝试创建一个简单的Discord Bot(Python 3中的wirtten),它只在一个命令后连接和断开连接。Connect命令工作正常,但我的DISCONECT命令不工作。以下是包含两个命令的代码段:

async def join(message):
    channel = message.message.author.voice.channel
    await channel.connect()


@client.command(pass_context = True)
async def leave(message):
    channel = message.message.author.voice.channel
    await channel.disconnect()```

尝试将您的
leave
功能替换为:

@commands.command()
异步def离开(ctx):
频道=ctx.message.author.voice.channel
voice=get(self.bot.voice\u客户端,guild=ctx.guild)
如果voice和voice.is_已连接():
等待ctx.send(f'Disconnecting from channel**{channel}**')
等待语音。断开连接()
其他:
等待ctx.send(“我没有连接任何通道”)

尝试将您的
离开功能替换为:

@commands.command()
异步def离开(ctx):
频道=ctx.message.author.voice.channel
voice=get(self.bot.voice\u客户端,guild=ctx.guild)
如果voice和voice.is_已连接():
等待ctx.send(f'Disconnecting from channel**{channel}**')
等待语音。断开连接()
其他:
等待ctx.send(“我没有连接任何通道”)

您是否收到任何错误?如果是这样的话,你应该在问题中包含错误。你有错误吗?如果是这样,你应该在问题中包括错误