aboutsummaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2026-01-17 22:05:47 +0100
committerWilliam Hergès <william@herges.fr>2026-01-17 22:05:47 +0100
commita3b0f488f799020d20c6cd2eb6bb082071bb0455 (patch)
tree0969f9cec659338988507cc24f8ca455cf926901 /user
parenta3543d79561a3754540b921c54c3c177016c2397 (diff)
style(): clean various old things
Diffstat (limited to 'user')
-rw-r--r--user/state.go1
-rw-r--r--user/xp.go7
2 files changed, 6 insertions, 2 deletions
diff --git a/user/state.go b/user/state.go
index effdc80..676728b 100644
--- a/user/state.go
+++ b/user/state.go
@@ -214,6 +214,7 @@ func generateXPs(c *Copaing) []XPCached {
i := 0
for _, v := range data {
ccs[i] = v
+ println(v.Time.String(), v.XP)
i++
}
return ccs
diff --git a/user/xp.go b/user/xp.go
index c87c450..35c11f3 100644
--- a/user/xp.go
+++ b/user/xp.go
@@ -51,7 +51,7 @@ func (cc *CopaingCached) GetXPForDays(n uint) uint {
}
// GetBestXP returns n Copaing with the best XP within d days (d <= cfg.DaysXPRemain; d < 0 <=> d = cfg.DaysXPRemain)
-func GetBestXP(ctx context.Context, guildId string, n uint, d int) ([]CopaingCached, error) {
+func GetBestXP(ctx context.Context, guildId string, n uint, d int) []CopaingCached {
ccs := GetState(ctx).Copaings(guildId)
if d > 0 {
for _, v := range ccs {
@@ -62,5 +62,8 @@ func GetBestXP(ctx context.Context, guildId string, n uint, d int) ([]CopaingCac
// desc order
return int(b.XP) - int(a.XP)
})
- return ccs[:min(len(ccs), int(n))], nil
+ m := min(len(ccs), int(n))
+ res := make([]CopaingCached, m)
+ copy(ccs[:m], res)
+ return res
}