discord.py
discord.py copied to clipboard
VoiceClient.play() doesnt work after a restart without disconnecting
Summary
play() doesnt work after a restart without disconnecting and throws no exception. The bot is silent in the voice channel
Reproduction Steps
- connect to a voice channel
- terminate the bot without disconnecting from the voice channel
- the bot will stay inactive in the voice channel
- start the bot again
- connect to the same voice channel (this step must happen before discord kicks the bot out of the channel)
- the bot is unable to play() until a disconnect and reconnect
Expected Results
play() should work
Actual Results
play() doesnt work and throws no exception. The bot is silent in the voice channel
Checklist
- [x] I have searched the open issues for duplicates.
- [x] I have shown the entire traceback, if possible.
- [x] I have removed my token from display, if visible.
System Information
- Python v3.7.0-final
- discord.py v1.2.3-final
- aiohttp v3.5.4
- websockets v6.0
- system info: Windows 10 10.0.18362
Can confirm this, a little annoying
Can also confirm this issue. The bot doesn't know it's in a voice channel after the restart. Trying to disconnect through ctx.voice (ctx.voice_client.disconnect()) throws an error stating that it isn't connected to a voice channel. Maybe when writing a bot, it could search the voice channels of all the guilds it's in (could take a while depending on the popularity of your bot), and if it finds its own ID, to join and leave that voice channel to get it in a better state.
Can confirm this too, I spent 2 days debugging when I found out that stopping the bot, waiting for it to disconnect, restarting and reconnecting it to voice fixed the issue.
I wasn't using cogs, I was using channel.connect()
created from a discord.Client
.
Might also be related to a bug where Right click > Disconnect
on a bot causes some weird behavior when it reconnects to voice.
If you have a file handle that you are playing audio from, make sure you seek the handle back to the beginning or it will not play anything.
Was there a "good" workaround for this? The only thing I can get to work is to connect to a different voice channel, then back to the one I actually want to play at.
Was there a "good" workaround for this?
@Ruuttu Yep, manually disconnect the bot from voice (Right Click > Disconnect) then restart the bot and reconnect to voice. Not very good but it's the main workaround. There are, of course, hacky ways to entirely eliminate the issue but I wouldn't recommend most.