diff --git a/app/internal/bot_manager.py b/app/internal/bot_manager.py index c5b7a38..3dc14fc 100644 --- a/app/internal/bot_manager.py +++ b/app/internal/bot_manager.py @@ -46,6 +46,9 @@ class DiscordBotManager: # Check if the bot was disconnected if member == self.bot.user and after.channel is None: guild_id = before.channel.guild.id + if not self.voice_clients.get(guild_id): + LOGGER.info("Bot has left channel, reconnection ignored.") + return LOGGER.info(f"Bot was disconnected from channel in guild {guild_id}. Attempting to reconnect...") try: await self.leave_voice_channel(guild_id) @@ -129,7 +132,6 @@ class DiscordBotManager: except asyncio.TimeoutError: LOGGER.error("Timeout waiting for bot to join voice.") raise RuntimeError("Bot failed to join voice within timeout.") - async def leave_voice_channel(self, guild_id: int): if not self.bot: