Skip to content

Commit

Permalink
Merge pull request helionmusic#27 from SnGmng/master
Browse files Browse the repository at this point in the history
Fix that the bot stops playing after heroku restarts it
  • Loading branch information
infinitepower18 authored Jul 19, 2019
2 parents 5d39df4 + 07a9f91 commit a3ac8ed
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,13 @@ async def disconnect_voice_client(self, guild):

await vc.disconnect()

async def force_disconnect_from_channel(self, channel):
try:
voice_client = await self.get_voice_client(channel)
await voice_client.disconnect(force=True)
except:
return

async def disconnect_all_voice_clients(self):
for vc in list(self.voice_clients).copy():
await self.disconnect_voice_client(vc.channel.guild)
Expand All @@ -416,6 +423,7 @@ async def get_player(self, channel, create=False, *, deserialize=False) -> Music

async with self.aiolocks[_func_() + ':' + str(guild.id)]:
if deserialize:
await self.force_disconnect_from_channel(channel)
voice_client = await self.get_voice_client(channel)
player = await self.deserialize_queue(guild, voice_client)

Expand Down

0 comments on commit a3ac8ed

Please sign in to comment.