From defc781f9a66b0fe25a79356ac5ac0c2143003f9 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 5 Jun 2025 15:17:45 +0200 Subject: [PATCH] fix(xp): adding xp if user joins a disabled voice channel in certain conditions --- events.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/events.go b/events.go index 50306dc..fc60ba0 100644 --- a/events.go +++ b/events.go @@ -51,12 +51,12 @@ func OnVoiceUpdate(s *discordgo.Session, e *discordgo.VoiceStateUpdate) { return } cfg := config.GetGuildConfig(e.GuildID) - if e.BeforeUpdate == nil && e.ChannelID != "" { + if (e.BeforeUpdate == nil || cfg.IsDisabled(e.BeforeUpdate.ChannelID)) && e.ChannelID != "" { if cfg.IsDisabled(e.ChannelID) { return } onConnection(s, e) - } else if e.BeforeUpdate != nil && e.ChannelID == "" { + } else if e.BeforeUpdate != nil && (e.ChannelID == "" || cfg.IsDisabled(e.ChannelID)) { if cfg.IsDisabled(e.BeforeUpdate.ChannelID) { return } @@ -73,8 +73,8 @@ func onDisconnect(s *discordgo.Session, e *discordgo.VoiceStateUpdate) { now := time.Now().Unix() c := user.GetCopaing(e.UserID, e.GuildID) // check the validity of user - con := connectedSince[e.UserID] - if con == NotConnected { + con, ok := connectedSince[e.UserID] + if !ok || con == NotConnected { utils.SendWarn(fmt.Sprintf( "User %s diconnect from a vocal but was registered as not connected", e.Member.DisplayName(), ))