aboutsummaryrefslogtreecommitdiff
path: root/commands/stats.go
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-08-31 16:56:02 +0200
committerWilliam Hergès <william@herges.fr>2025-08-31 16:56:02 +0200
commit59ba978ba78b56e9195946b5bb12011a7a936294 (patch)
treee6af5e9cea843b5ae4b79c8c1527bed0932b394d /commands/stats.go
parent355db490b72f51e312d599bd38c7e412cbb94691 (diff)
fix(stats): index out of range another time3.2.0
I think I have fixed every out out of range could be tested in debug mode, but is very hard to reproduce
Diffstat (limited to 'commands/stats.go')
-rw-r--r--commands/stats.go6
1 files changed, 3 insertions, 3 deletions
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),
}