Ignore reconnection logic when disconnecting
Some checks failed
release-tag / release-image (push) Successful in 1h14m15s
Lint / lint (push) Failing after 10s

This commit is contained in:
Logan Cusano
2025-05-02 22:18:16 -04:00
parent e7956577d7
commit 872bbf2965

View File

@@ -46,6 +46,9 @@ class DiscordBotManager:
# Check if the bot was disconnected # Check if the bot was disconnected
if member == self.bot.user and after.channel is None: if member == self.bot.user and after.channel is None:
guild_id = before.channel.guild.id 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...") LOGGER.info(f"Bot was disconnected from channel in guild {guild_id}. Attempting to reconnect...")
try: try:
await self.leave_voice_channel(guild_id) await self.leave_voice_channel(guild_id)
@@ -129,7 +132,6 @@ class DiscordBotManager:
except asyncio.TimeoutError: except asyncio.TimeoutError:
LOGGER.error("Timeout waiting for bot to join voice.") LOGGER.error("Timeout waiting for bot to join voice.")
raise RuntimeError("Bot failed to join voice within timeout.") raise RuntimeError("Bot failed to join voice within timeout.")
async def leave_voice_channel(self, guild_id: int): async def leave_voice_channel(self, guild_id: int):
if not self.bot: if not self.bot: