From 5434941f3dc8006565f0d16902a2717f1317994f Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 23 Feb 2025 20:31:16 -0500 Subject: [PATCH] Fix logic to disconnect then try to reconnect --- app/bot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/bot.py b/app/bot.py index 7852563..6997a3b 100644 --- a/app/bot.py +++ b/app/bot.py @@ -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)