From 23f397c18081d81c07c5f267ce7f7e865c1600ff Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 18 Apr 2024 12:50:36 +0200 Subject: [PATCH] fix(event): using old UserBase --- xp/events.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xp/events.go b/xp/events.go index 7504c77..e8acd59 100644 --- a/xp/events.go +++ b/xp/events.go @@ -86,10 +86,10 @@ func OnVoiceUpdate(s *discordgo.Session, e *discordgo.VoiceStateUpdate) { } func onConnection(_ *discordgo.Session, e *discordgo.VoiceStateUpdate, client *redis.Client) { - u := gokord.UserBase{DiscordID: e.UserID, GuildID: e.GuildID} + c := GetCopaing(e.UserID, e.GuildID) err := client.Set( context.Background(), - fmt.Sprintf("%s:%s", u.GenKey(), ConnectedSince), + c.GenKey(ConnectedSince), strconv.FormatInt(time.Now().Unix(), 10), 0, ).Err() @@ -100,8 +100,8 @@ func onConnection(_ *discordgo.Session, e *discordgo.VoiceStateUpdate, client *r func onDisconnect(s *discordgo.Session, e *discordgo.VoiceStateUpdate, client *redis.Client) { now := time.Now().Unix() - u := gokord.UserBase{DiscordID: e.UserID, GuildID: e.GuildID} - key := fmt.Sprintf("%s:%s", u.GenKey(), ConnectedSince) + c := GetCopaing(e.UserID, e.GuildID) + key := c.GenKey(ConnectedSince) res := client.Get(context.Background(), key) // check validity of user (1) if errors.Is(res.Err(), redis.Nil) { @@ -146,7 +146,6 @@ func onDisconnect(s *discordgo.Session, e *discordgo.VoiceStateUpdate, client *r utils.SendWarn(fmt.Sprintf("User %s spent more than 6 hours in vocal", e.Member.DisplayName())) timeInVocal = MaxTimeInVocal } - c := GetCopaing(u.DiscordID, u.GuildID) e.Member.GuildID = e.GuildID c.AddXP(s, e.Member, XPVocal(uint(timeInVocal)), func(_ uint, newLevel uint) { cfg := config.GetGuildConfig(e.GuildID)