Discord.py 2.0.0 voice chat disconnection problem

Question:

@commands.command(name="disconnect")
    async def _disconnect(self, ctx):
        voice_state = ctx.author.voice
        if voice_state is None:
            return
        for voice_client in ctx.bot.voice_clients:
            if voice_client.channel == ctx.author.voice.channel:
                await voice_client.disconnect()
                print("disconnected")

The code executes fine but the bot is still in voice chat

I tried changing ctx.bot.voice_clients: to self.bot.voice_clients: but it had no effect. I changed vesrion of discord.py multiple times but im still stuck on this

Asked By: IIKrolZlotyII

||

Answers:

Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.