fix(command): missing custom id for modal

This commit is contained in:
Anhgelus Morhtuuzh 2025-08-21 14:38:59 +02:00
parent 9a58e3db84
commit ecf41adc3c
Signed by: anhgelus
GPG key ID: CAD341EFA92DDDE5
5 changed files with 27 additions and 20 deletions

View file

@ -1,11 +1,12 @@
package config
import (
"strconv"
"github.com/anhgelus/gokord/cmd"
"github.com/anhgelus/gokord/component"
"github.com/anhgelus/gokord/logger"
"github.com/bwmarrin/discordgo"
"strconv"
)
const (
@ -14,11 +15,13 @@ const (
)
func HandleModifyPeriodicReduce(_ *discordgo.Session, _ *discordgo.InteractionCreate, _ discordgo.MessageComponentInteractionData, resp *cmd.ResponseBuilder) {
err := resp.IsModal().SetComponents(component.New().ForModal().Add(component.NewActionRow().Add(
component.NewTextInput(TimeReduceSet, "Jours avant la réduction", discordgo.TextInputShort).
SetMinLength(1).
SetMaxLength(3),
))).Send()
err := resp.IsModal().
SetCustomID(TimeReduceSet).
SetComponents(component.New().ForModal().Add(component.NewActionRow().ForModal().Add(
component.NewTextInput(TimeReduceSet, "Jours avant la réduction", discordgo.TextInputShort).
SetMinLength(1).
SetMaxLength(3),
))).Send()
if err != nil {
logger.Alert("config/xp_reduce.go - Sending modal for periodic reduce", err.Error())
}
@ -31,14 +34,14 @@ func HandleTimeReduceSet(_ *discordgo.Session, i *discordgo.InteractionCreate, d
if err != nil {
logger.Debug(err.Error())
if err = resp.SetMessage("Nombres de jours invalides. Merci de mettre un entier.").Send(); err != nil {
logger.Alert("config/channel.go - Sending bad input", err.Error())
logger.Alert("config/xp_reduce.go - Sending bad input", err.Error())
}
return
}
if days < 30 {
err = resp.SetMessage("Le nombre de jours est inférieur à 30.").Send()
if err != nil {
logger.Alert("commands/config.go - Days < 30 (fallback)", err.Error())
logger.Alert("config/xp_reduce.go - Days < 30 (fallback)", err.Error())
}
return
}
@ -47,11 +50,11 @@ func HandleTimeReduceSet(_ *discordgo.Session, i *discordgo.InteractionCreate, d
if err = cfg.Save(); err != nil {
logger.Alert("config/channel.go - Saving days xp remains", err.Error())
if err = resp.SetMessage("Erreur lors de la sauvegarde du salon").Send(); err != nil {
logger.Alert("config/channel.go - Sending error while saving days xp remains", err.Error())
logger.Alert("config/xp_reduce.go - Sending error while saving days xp remains", err.Error())
}
return
}
if err = resp.SetMessage("Modification sauvegardée.").Send(); err != nil {
logger.Alert("config/channel.go - Sending days saved", err.Error())
logger.Alert("config/xp_reduce.go - Sending days saved", err.Error())
}
}