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
Answers:
Did you try await voice_client.disconnect(force=True)
https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.disconnect
@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
Did you try await voice_client.disconnect(force=True)
https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.disconnect