Ignore reconnection logic when disconnecting
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user