fix(command): /rank prochain niveau not working

This commit is contained in:
Anhgelus Morhtuuzh 2024-04-15 19:30:02 +02:00
parent 9f9c27f422
commit e78c8d8c42
No known key found for this signature in database
GPG key ID: CF4550297832A29F

View file

@ -9,8 +9,8 @@ import (
func Rank(s *discordgo.Session, i *discordgo.InteractionCreate) { func Rank(s *discordgo.Session, i *discordgo.InteractionCreate) {
optMap := utils.GenerateOptionMap(i) optMap := utils.GenerateOptionMap(i)
c := xp.GetCopaing(i.User.ID, i.GuildID) // current copaing = member who used /rank c := xp.GetCopaing(i.Member.User.ID, i.GuildID) // current copaing = member who used /rank
xp.LastEventUpdate(c) // update xp and reset last event xp.LastEventUpdate(c) // update xp and reset last event
msg := "Votre niveau" msg := "Votre niveau"
m := i.Member m := i.Member
var err error var err error
@ -45,13 +45,13 @@ func Rank(s *discordgo.Session, i *discordgo.InteractionCreate) {
msg = fmt.Sprintf("Le niveau de %s", m.DisplayName()) msg = fmt.Sprintf("Le niveau de %s", m.DisplayName())
} }
lvl := xp.Level(c.XP) lvl := xp.Level(c.XP)
nxtLvl := xp.XPForLevel(lvl + 1) nxtLvlXP := xp.XPForLevel(lvl + 1)
err = resp.Message(fmt.Sprintf( err = resp.Message(fmt.Sprintf(
"%s : **%d**\n> XP : %d\n> Prochain niveau dans %d XP", "%s : **%d**\n> XP : %d\n> Prochain niveau dans %d XP",
msg, msg,
lvl, lvl,
c.XP, c.XP,
nxtLvl-lvl, nxtLvlXP-xp.XPForLevel(lvl),
)).Send() )).Send()
if err != nil { if err != nil {
utils.SendAlert("rank.go - Sending rank", err.Error()) utils.SendAlert("rank.go - Sending rank", err.Error())