From 59ba978ba78b56e9195946b5bb12011a7a936294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Sun, 31 Aug 2025 16:56:02 +0200 Subject: fix(stats): index out of range another time I think I have fixed every out out of range could be tested in debug mode, but is very hard to reproduce --- commands/stats.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'commands/stats.go') diff --git a/commands/stats.go b/commands/stats.go index 263d80c..34734b0 100644 --- a/commands/stats.go +++ b/commands/stats.go @@ -151,8 +151,8 @@ func stats(s *discordgo.Session, i *discordgo.InteractionCreate, days uint, exec pts, ok := stats[raw.CopaingID] now := time.Now().Unix() if !ok { - pts = make([]plotter.XY, days) - for i := 0; i < int(days); i++ { + pts = make([]plotter.XY, days+1) + for i := 0; i < len(pts); i++ { pts[i] = plotter.XY{ X: float64(i - int(days)), Y: 0, @@ -164,7 +164,7 @@ func stats(s *discordgo.Session, i *discordgo.InteractionCreate, days uint, exec if !gokord.Debug { t = int64(math.Ceil(float64(t) / (24 * 60 * 60))) } - pts[int64(days)+t-1] = plotter.XY{ // because t <= 0 + pts[int64(days)+t] = plotter.XY{ // because t <= 0 X: float64(t), Y: float64(raw.XP), } -- cgit v1.2.3