aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-05-13 21:25:51 +0200
committerAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-05-13 21:25:51 +0200
commit9c64718c76af83a21de92e48a7276d6edd981b25 (patch)
treebdc84a616da8bc678039180d5e7da58541eefc8f
parent8d6af4b6aa8f4902316c7f30c5229c97b0ec1a81 (diff)
feat(command): prevent sending full time if days is set to 30
-rw-r--r--commands/top.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/commands/top.go b/commands/top.go
index a43e055..0423bab 100644
--- a/commands/top.go
+++ b/commands/top.go
@@ -3,6 +3,7 @@ package commands
import (
"fmt"
"github.com/anhgelus/gokord/utils"
+ "github.com/anhgelus/les-copaings-bot/config"
"github.com/anhgelus/les-copaings-bot/exp"
"github.com/anhgelus/les-copaings-bot/user"
"github.com/bwmarrin/discordgo"
@@ -38,14 +39,22 @@ func Top(s *discordgo.Session, i *discordgo.InteractionCreate) {
Color: utils.Success,
}
}
-
- wg.Add(3)
- go fn("Top full time", 10, -1, 0)
+ cfg := config.GetGuildConfig(i.GuildID)
+ if cfg.DaysXPRemains > 30 {
+ wg.Add(1)
+ go fn("Top full time", 10, -1, 0)
+ }
+ wg.Add(2)
go fn("Top 30 jours", 5, 30, 1)
go fn("Top 7 jours", 5, 7, 2)
go func() {
wg.Wait()
- err = resp.Embeds(embeds).Send()
+ if cfg.DaysXPRemains > 30 {
+ resp.Embeds(embeds)
+ } else {
+ resp.Embeds(embeds[1:])
+ }
+ err = resp.Send()
if err != nil {
utils.SendAlert("commands/top.go - Sending response top", err.Error())
}