discord.py icon indicating copy to clipboard operation
discord.py copied to clipboard

VoiceClient.play() doesnt work after a restart without disconnecting

Open thesn10 opened this issue 5 years ago • 7 comments

Summary

play() doesnt work after a restart without disconnecting and throws no exception. The bot is silent in the voice channel

Reproduction Steps

  1. connect to a voice channel
  2. terminate the bot without disconnecting from the voice channel
  3. the bot will stay inactive in the voice channel
  4. start the bot again
  5. connect to the same voice channel (this step must happen before discord kicks the bot out of the channel)
  6. 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

thesn10 avatar Jul 21 '19 19:07 thesn10

Can confirm this, a little annoying

gregistech avatar Jul 27 '19 15:07 gregistech

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.

hammy275 avatar Aug 16 '19 06:08 hammy275

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.

Steffo99 avatar Aug 17 '19 16:08 Steffo99

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.

Steffo99 avatar Aug 17 '19 17:08 Steffo99

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.

xcrafter40 avatar Oct 26 '19 23:10 xcrafter40

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.

Ruuttu avatar Mar 21 '20 22:03 Ruuttu

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.

HarryIsABozo avatar Mar 11 '22 19:03 HarryIsABozo