aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/config.go6
-rw-r--r--commands/stats.go2
-rw-r--r--commands/top.go12
3 files changed, 11 insertions, 9 deletions
diff --git a/commands/config.go b/commands/config.go
index f2dcf60..4535203 100644
--- a/commands/config.go
+++ b/commands/config.go
@@ -22,7 +22,7 @@ const (
)
func ConfigResponse(ctx context.Context, guildID uint64) *interaction.Response {
- cfg := config.GetGuildConfig(ctx, guildID)
+ cfg := config.GetGuild(ctx, guildID)
roles := ""
l := len(cfg.XpRoles) - 1
slices.SortFunc(cfg.XpRoles, func(xp1, xp2 config.XpRole) int {
@@ -30,9 +30,9 @@ func ConfigResponse(ctx context.Context, guildID uint64) *interaction.Response {
})
for i, r := range cfg.XpRoles {
if i == l {
- roles += fmt.Sprintf("> Niveau %d - <@&%s>", exp.Level(r.XP), r.RoleID)
+ roles += fmt.Sprintf("> Niveau %d - <@&%d>", exp.Level(r.XP), r.RoleID)
} else {
- roles += fmt.Sprintf("> Niveau %d - <@&%s>\n", exp.Level(r.XP), r.RoleID)
+ roles += fmt.Sprintf("> Niveau %d - <@&%d>\n", exp.Level(r.XP), r.RoleID)
}
}
if len(roles) == 0 {
diff --git a/commands/stats.go b/commands/stats.go
index c9562dc..9277ad7 100644
--- a/commands/stats.go
+++ b/commands/stats.go
@@ -51,7 +51,7 @@ var colors = []color.RGBA{
}
func Stats(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand) {
- cfg := config.GetGuildConfig(ctx, i.GuildID)
+ cfg := config.GetGuild(ctx, i.GuildID)
days := 15
if common.IsDebug(ctx) {
days = 90
diff --git a/commands/top.go b/commands/top.go
index db44dbd..d816c55 100644
--- a/commands/top.go
+++ b/commands/top.go
@@ -3,6 +3,7 @@ package commands
import (
"context"
"fmt"
+ "strings"
"sync"
"git.anhgelus.world/anhgelus/les-copaings-bot/config"
@@ -26,7 +27,7 @@ func Top(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand)
}
}
- cfg := config.GetGuildConfig(ctx, i.GuildID)
+ cfg := config.GetGuild(ctx, i.GuildID)
if cfg.DaysXPRemains > 30 {
wg.Go(func() {
fn(fmt.Sprintf("Top %d jours", cfg.DaysXPRemains), 10, -1, 0)
@@ -57,12 +58,13 @@ func Top(ctx context.Context, dg bot.Session, i *interaction.ApplicationCommand)
}
func genTopsMessage(tops []user.CopaingCached) string {
- msg := ""
+ var sb strings.Builder
for i, c := range tops {
- msg += fmt.Sprintf("%d. **<@%d>** - niveau %d", i+1, c.ID, exp.Level(c.XP))
+ ft := fmt.Sprintf("%d. **<@%d>** - niveau %d", i+1, c.ID, exp.Level(c.XP))
+ sb.WriteString(ft)
if i != len(tops)-1 {
- msg += "\n"
+ sb.WriteString("\n")
}
}
- return msg
+ return sb.String()
}