From 8194268ce15fc8d9011f797f69d17d65225061e2 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Sat, 11 Apr 2026 17:45:05 -0400 Subject: [PATCH] fix: delete player objects when disconnected --- errornocord/core.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/errornocord/core.py b/errornocord/core.py index 0540e90..c89a6c7 100644 --- a/errornocord/core.py +++ b/errornocord/core.py @@ -15,7 +15,7 @@ import disnake_paginator from . import commands, utils from .commands import Command as C from .constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES -from .state import client, command_cooldowns, command_locks, idle_tracker +from .state import client, command_cooldowns, command_locks, idle_tracker, players async def on_message(message, edited=False): @@ -149,17 +149,21 @@ async def on_message(message, edited=False): async def on_voice_state_update(_, before, after): + if not before.channel and after.channel: + return + + if before.channel and not after.channel: + if before.channel.guild.id in players: + del players[before.channel.guild.id] + return + def is_empty(channel): return [m.id for m in (channel.members if channel else [])] == [client.user.id] - channel = None - if is_empty(before.channel): - channel = before.channel - elif is_empty(after.channel): - channel = after.channel - - if channel: - await channel.guild.voice_client.disconnect() + if is_empty(after.channel): + if after.channel.guild.id in players: + del players[after.channel.guild.id] + await after.channel.guild.voice_client.disconnect() def rreload(reloaded_modules, module):