Discord.py Bot Leaving Voice Channel
I've been making a discord bot which enters a vc plays an audio then leaves, but I can't seem to get the leaving part to work. Here is my code: # Discord specific import import dis
Solution 1:
My problems were that:
- I needed to use: await vc.disconnect()
- My version of websockets was too high and needed to be below v4.0.0
Hope this helps people with my problem
Solution 2:
try vc.disconnect()
as stated here in the docs, since Client.join_voice_channel(channel)
creates a VoiceClient
. Also I suggest not having redundant variables like
author = ctx.message.author
channel = author.voice_channel
When you can have vc = await client.join_voice_channel(ctx.message.author.voice_channel)
Also, another redundant variable is Client = discord.Client()
since you don't use it anywhere, you use the commands.Bot
instance, so it's best to remove that.
Solution 3:
player.disconnect()
is a coroutine, you should use the await
keyword before it.
await player.disconnect()
Post a Comment for "Discord.py Bot Leaving Voice Channel"