fix(command): missing custom id for modal
This commit is contained in:
parent
9a58e3db84
commit
ecf41adc3c
5 changed files with 27 additions and 20 deletions
|
@ -1,11 +1,12 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/anhgelus/gokord/cmd"
|
"github.com/anhgelus/gokord/cmd"
|
||||||
"github.com/anhgelus/gokord/component"
|
"github.com/anhgelus/gokord/component"
|
||||||
"github.com/anhgelus/gokord/logger"
|
"github.com/anhgelus/gokord/logger"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -14,11 +15,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func HandleModifyPeriodicReduce(_ *discordgo.Session, _ *discordgo.InteractionCreate, _ discordgo.MessageComponentInteractionData, resp *cmd.ResponseBuilder) {
|
func HandleModifyPeriodicReduce(_ *discordgo.Session, _ *discordgo.InteractionCreate, _ discordgo.MessageComponentInteractionData, resp *cmd.ResponseBuilder) {
|
||||||
err := resp.IsModal().SetComponents(component.New().ForModal().Add(component.NewActionRow().Add(
|
err := resp.IsModal().
|
||||||
component.NewTextInput(TimeReduceSet, "Jours avant la réduction", discordgo.TextInputShort).
|
SetCustomID(TimeReduceSet).
|
||||||
SetMinLength(1).
|
SetComponents(component.New().ForModal().Add(component.NewActionRow().ForModal().Add(
|
||||||
SetMaxLength(3),
|
component.NewTextInput(TimeReduceSet, "Jours avant la réduction", discordgo.TextInputShort).
|
||||||
))).Send()
|
SetMinLength(1).
|
||||||
|
SetMaxLength(3),
|
||||||
|
))).Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Alert("config/xp_reduce.go - Sending modal for periodic reduce", err.Error())
|
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 {
|
if err != nil {
|
||||||
logger.Debug(err.Error())
|
logger.Debug(err.Error())
|
||||||
if err = resp.SetMessage("Nombres de jours invalides. Merci de mettre un entier.").Send(); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
if days < 30 {
|
if days < 30 {
|
||||||
err = resp.SetMessage("Le nombre de jours est inférieur à 30.").Send()
|
err = resp.SetMessage("Le nombre de jours est inférieur à 30.").Send()
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -47,11 +50,11 @@ func HandleTimeReduceSet(_ *discordgo.Session, i *discordgo.InteractionCreate, d
|
||||||
if err = cfg.Save(); err != nil {
|
if err = cfg.Save(); err != nil {
|
||||||
logger.Alert("config/channel.go - Saving days xp remains", err.Error())
|
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 {
|
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
|
return
|
||||||
}
|
}
|
||||||
if err = resp.SetMessage("Modification sauvegardée.").Send(); err != nil {
|
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,14 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/anhgelus/gokord"
|
"github.com/anhgelus/gokord"
|
||||||
"github.com/anhgelus/gokord/cmd"
|
"github.com/anhgelus/gokord/cmd"
|
||||||
"github.com/anhgelus/gokord/component"
|
"github.com/anhgelus/gokord/component"
|
||||||
"github.com/anhgelus/gokord/logger"
|
"github.com/anhgelus/gokord/logger"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type XpRole struct {
|
type XpRole struct {
|
||||||
|
@ -52,7 +53,7 @@ func HandleModifyXpRole(_ *discordgo.Session, _ *discordgo.InteractionCreate, _
|
||||||
),
|
),
|
||||||
)).Send()
|
)).Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Alert("config/guild.go - Sending config", err.Error())
|
logger.Alert("config/xp_reduce.go - Sending config", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +64,8 @@ func HandleXpRoleAddEdit(_ *discordgo.Session, _ *discordgo.InteractionCreate, d
|
||||||
}
|
}
|
||||||
err := resp.IsModal().
|
err := resp.IsModal().
|
||||||
SetTitle("Role").
|
SetTitle("Role").
|
||||||
SetComponents(component.New().ForModal().Add(component.NewActionRow().Add(
|
SetCustomID(cID).
|
||||||
|
SetComponents(component.New().ForModal().Add(component.NewActionRow().ForModal().Add(
|
||||||
component.NewTextInput(cID, "Niveau", discordgo.TextInputShort).
|
component.NewTextInput(cID, "Niveau", discordgo.TextInputShort).
|
||||||
SetPlaceholder("5").
|
SetPlaceholder("5").
|
||||||
IsRequired().
|
IsRequired().
|
||||||
|
@ -72,7 +74,7 @@ func HandleXpRoleAddEdit(_ *discordgo.Session, _ *discordgo.InteractionCreate, d
|
||||||
))).
|
))).
|
||||||
Send()
|
Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Alert("config/guild.go - Sending modal to add/edit", err.Error())
|
logger.Alert("config/xp_reduce.go - Sending modal to add/edit", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +144,7 @@ func HandleXpRoleDel(_ *discordgo.Session, _ *discordgo.InteractionCreate, _ dis
|
||||||
SetComponents(component.New().Add(component.NewActionRow().Add(component.NewRoleSelect(XpRoleDelRole)))).
|
SetComponents(component.New().Add(component.NewActionRow().Add(component.NewRoleSelect(XpRoleDelRole)))).
|
||||||
Send()
|
Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Alert("config/guild.go - Sending response to del", err.Error())
|
logger.Alert("config/xp_reduce.go - Sending response to del", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,10 +206,10 @@ func HandleXpRoleLevel(_ *discordgo.Session, i *discordgo.InteractionCreate, dat
|
||||||
SetComponents(component.New().Add(component.NewActionRow().Add(component.NewRoleSelect(cID)))).
|
SetComponents(component.New().Add(component.NewActionRow().Add(component.NewRoleSelect(cID)))).
|
||||||
Send()
|
Send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Alert("config/guild.go - Sending response to add/edit", err.Error())
|
logger.Alert("config/xp_reduce.go - Sending response to add/edit", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getKeyConfigRole(i *discordgo.InteractionCreate) string {
|
func getKeyConfigRole(i *discordgo.InteractionCreate) string {
|
||||||
return fmt.Sprintf("r:%s:%s", i.GuildID, i.User.ID)
|
return fmt.Sprintf("r:%s:%s", i.GuildID, i.Member.User.ID)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ func LevelXP(level uint) uint {
|
||||||
func TimeStampNDaysBefore(n uint) string {
|
func TimeStampNDaysBefore(n uint) string {
|
||||||
var unix time.Time
|
var unix time.Time
|
||||||
if gokord.Debug {
|
if gokord.Debug {
|
||||||
unix = time.Unix(time.Now().Unix()-int64(n), 0) // reduce time for debug
|
unix = time.Unix(time.Now().Unix()-int64(n)*6, 0) // reduce time for debug
|
||||||
} else {
|
} else {
|
||||||
unix = time.Unix(time.Now().Unix()-int64(n*24*60*60), 0)
|
unix = time.Unix(time.Now().Unix()-int64(n*24*60*60), 0)
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module github.com/anhgelus/les-copaings-bot
|
||||||
go 1.24
|
go 1.24
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/anhgelus/gokord v0.11.1-0.20250821115246-50e5f7d17717
|
github.com/anhgelus/gokord v0.11.1-0.20250821122244-0aee6c37eef6
|
||||||
github.com/bwmarrin/discordgo v0.29.0
|
github.com/bwmarrin/discordgo v0.29.0
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4
|
github.com/pelletier/go-toml/v2 v2.2.4
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -14,6 +14,8 @@ github.com/anhgelus/gokord v0.11.1-0.20250807111049-5de23912c524 h1:mK7UtqJPNYhS
|
||||||
github.com/anhgelus/gokord v0.11.1-0.20250807111049-5de23912c524/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
|
github.com/anhgelus/gokord v0.11.1-0.20250807111049-5de23912c524/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
|
||||||
github.com/anhgelus/gokord v0.11.1-0.20250821115246-50e5f7d17717 h1:KfcBHUpwbffRO6aIITq7iN7cP7KcKmUnIE+eWiwsYYw=
|
github.com/anhgelus/gokord v0.11.1-0.20250821115246-50e5f7d17717 h1:KfcBHUpwbffRO6aIITq7iN7cP7KcKmUnIE+eWiwsYYw=
|
||||||
github.com/anhgelus/gokord v0.11.1-0.20250821115246-50e5f7d17717/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
|
github.com/anhgelus/gokord v0.11.1-0.20250821115246-50e5f7d17717/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
|
||||||
|
github.com/anhgelus/gokord v0.11.1-0.20250821122244-0aee6c37eef6 h1:4eO/9UqTPfrKyss2CeLafeKeR06bgoFihudKOdLpWpI=
|
||||||
|
github.com/anhgelus/gokord v0.11.1-0.20250821122244-0aee6c37eef6/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue