diff --git a/alexBot/cogs/voiceStats.py b/alexBot/cogs/voiceStats.py index bc5df45..a13a88b 100644 --- a/alexBot/cogs/voiceStats.py +++ b/alexBot/cogs/voiceStats.py @@ -27,6 +27,14 @@ async def cog_load(self): async def cog_unload(self): self.bot.voiceCommandsGroup.remove_command("stats") + @Cog.listener() + async def on_guild_leave(self, guild: discord.Guild): + async with async_session() as session: + vs = await session.scalar(select(VoiceStat).where(VoiceStat.id == guild.id)) + if vs: + vs.currently_running = False + await session.commit() + @Cog.listener() async def on_voice_state_update( self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState