build(gokord): upgrade to latest version

This commit is contained in:
Anhgelus Morhtuuzh 2025-08-06 02:22:06 +02:00
parent d72004ae14
commit 5a8da1eaeb
Signed by: anhgelus
GPG key ID: CAD341EFA92DDDE5
13 changed files with 136 additions and 146 deletions

View file

@ -2,44 +2,45 @@ package commands
import (
"github.com/anhgelus/gokord"
"github.com/anhgelus/gokord/utils"
"github.com/anhgelus/gokord/cmd"
"github.com/anhgelus/gokord/logger"
"github.com/anhgelus/les-copaings-bot/user"
"github.com/bwmarrin/discordgo"
)
func Reset(s *discordgo.Session, i *discordgo.InteractionCreate, optMap utils.OptionMap, resp *utils.ResponseBuilder) {
func Reset(_ *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMap, resp *cmd.ResponseBuilder) {
var copaings []*user.Copaing
gokord.DB.Where("guild_id = ?", i.GuildID).Delete(&copaings)
if err := resp.IsEphemeral().SetMessage("L'XP a été reset.").Send(); err != nil {
utils.SendAlert("commands/reset.go - Sending success (all)", err.Error())
logger.Alert("commands/reset.go - Sending success (all)", err.Error())
}
}
func ResetUser(s *discordgo.Session, i *discordgo.InteractionCreate, optMap utils.OptionMap, resp *utils.ResponseBuilder) {
func ResetUser(s *discordgo.Session, i *discordgo.InteractionCreate, optMap cmd.OptionMap, resp *cmd.ResponseBuilder) {
resp.IsEphemeral()
v, ok := optMap["user"]
if !ok {
if err := resp.SetMessage("Le user n'a pas été renseigné.").Send(); err != nil {
utils.SendAlert("commands/reset.go - Copaing not set", err.Error())
logger.Alert("commands/reset.go - Copaing not set", err.Error())
}
return
}
m := v.UserValue(s)
if m.Bot {
if err := resp.SetMessage("Les bots n'ont pas de niveau :upside_down:").Send(); err != nil {
utils.SendAlert("commands/reset.go - Copaing not set", err.Error())
logger.Alert("commands/reset.go - Copaing not set", err.Error())
}
return
}
err := user.GetCopaing(m.ID, i.GuildID).Delete()
if err != nil {
utils.SendAlert("commands/reset.go - Copaing not deleted", err.Error(), "discord_id", m.ID, "guild_id", i.GuildID)
logger.Alert("commands/reset.go - Copaing not deleted", err.Error(), "discord_id", m.ID, "guild_id", i.GuildID)
err = resp.SetMessage("Erreur : impossible de reset l'utilisateur").Send()
if err != nil {
utils.SendAlert("commands/reset.go - Error deleting", err.Error())
logger.Alert("commands/reset.go - Error deleting", err.Error())
}
}
if err = resp.SetMessage("Le user bien été reset.").Send(); err != nil {
utils.SendAlert("commands/reset.go - Sending success (user)", err.Error())
logger.Alert("commands/reset.go - Sending success (user)", err.Error())
}
}