feat(xp): basic reducer

This commit is contained in:
Anhgelus Morhtuuzh 2024-04-15 18:47:52 +02:00
parent c1e4653a5c
commit 2aaeb2115b
No known key found for this signature in database
GPG key ID: CF4550297832A29F
3 changed files with 13 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package xp
import (
"context"
"errors"
"fmt"
"github.com/anhgelus/gokord"
"github.com/anhgelus/gokord/utils"
@ -77,7 +78,9 @@ func (c *Copaing) HourSinceLastEvent() uint {
}
u := c.GetUserBase()
res := client.Get(context.Background(), fmt.Sprintf("%s:%s", u.GenKey(), LastEvent))
if res.Err() != nil {
if errors.Is(res.Err(), redis.Nil) {
return 0
} else if res.Err() != nil {
utils.SendAlert("xp/member.go - Getting last event", res.Err().Error(), "base_key", u.GenKey())
return 0
}