Fix logic to disconnect then try to reconnect

This commit is contained in:
2025-02-23 20:31:16 -05:00
parent 0fb1a155b5
commit 5434941f3d

View File

@@ -56,6 +56,10 @@ class DiscordBotManager:
if member == self.bot.user and after.channel is None:
guild_id = before.channel.guild.id
LOGGER.info(f"Bot was disconnected from channel in guild {guild_id}. Attempting to reconnect...")
try:
leave_voice_channel(guild_id)
except Exception as e:
LOGGER.warning(f"Error to leave voice channel", e)
# Attempt to reconnect to the channel after a brief pause
await asyncio.sleep(2)
await self.join_voice_channel(guild_id, before.channel.id)