Skip to content

Commit

Permalink
Merge branch 'inactive-player-timeout'
Browse files Browse the repository at this point in the history
  • Loading branch information
itsTheFae committed Dec 9, 2023
2 parents 460b7b7 + a842d01 commit 29f68a8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ async def disconnect_voice_client(self, guild):
await self.reset_player_inactivity(player)
player.kill()

await self.update_now_playing_status()
await vc.disconnect()

async def disconnect_all_voice_clients(self):
Expand Down Expand Up @@ -1502,23 +1503,22 @@ async def handle_vc_inactivity(self, guild: discord.Guild):
self.server_specific_data[guild]["inactive_vc_timer"] = (event, True)

try:
log.debug(
log.info(
f"Channel activity waiting {self.config.leave_inactive_channel_timeout} seconds to leave channel: {guild.me.voice.channel.name}"
)
await discord.utils.sane_wait_for(
[event.wait()], timeout=self.config.leave_inactive_channel_timeout
)
except asyncio.TimeoutError:
log.debug(
log.info(
f"Channel activity timer for {guild.name} has expired. Disconnecting."
)
await self.on_inactivity_timeout_expired(guild.me.voice.channel)
else:
log.debug(
log.info(
f"Channel activity timer canceled for: {guild.me.voice.channel.name} in {guild.name}"
)
finally:
log.debug(f"Cleaning up channel activity timer for guild {guild.name}.")
self.server_specific_data[guild]["inactive_vc_timer"] = (event, False)
event.clear()

Expand All @@ -1541,23 +1541,22 @@ async def handle_player_inactivity(self, player):
self.server_specific_data[guild]["inactive_player_timer"] = (event, True)

try:
log.debug(
log.info(
f"Player activity timer waiting {self.config.leave_player_inactive_for} seconds to leave channel: {channel.name}"
)
await discord.utils.sane_wait_for(
[event.wait()], timeout=self.config.leave_player_inactive_for
)
except asyncio.TimeoutError:
log.debug(
log.info(
f"Player activity timer for {guild.name} has expired. Disconnecting."
)
await self.on_inactivity_timeout_expired(channel)
else:
log.debug(
log.info(
f"Player activity timer canceled for: {channel.name} in {guild.name}"
)
finally:
log.debug(f"Cleaning up player activity timer for guild {guild.name}.")
self.server_specific_data[guild]["inactive_player_timer"] = (event, False)
event.clear()

Expand Down

0 comments on commit 29f68a8

Please sign in to comment.