aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--main.go23
3 files changed, 22 insertions, 5 deletions
diff --git a/go.mod b/go.mod
index 2a9e497..abd4668 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/anhgelus/les-copaings-bot
go 1.24
require (
- github.com/anhgelus/gokord v0.11.1-0.20250807111049-5de23912c524
+ github.com/anhgelus/gokord v0.11.1-0.20250821115246-50e5f7d17717
github.com/bwmarrin/discordgo v0.29.0
github.com/joho/godotenv v1.5.1
github.com/pelletier/go-toml/v2 v2.2.4
diff --git a/go.sum b/go.sum
index df19706..288f1ba 100644
--- a/go.sum
+++ b/go.sum
@@ -12,6 +12,8 @@ github.com/anhgelus/gokord v0.11.1-0.20250806143823-567c33f63688 h1:0ngeLQxHr80X
github.com/anhgelus/gokord v0.11.1-0.20250806143823-567c33f63688/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
github.com/anhgelus/gokord v0.11.1-0.20250807111049-5de23912c524 h1:mK7UtqJPNYhStRVeZ2N4c89tjlhlRZX0LcLs7TAB34I=
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/go.mod h1:4xpwLzIG34/XG9QZiPsnYScQhckiCpQMAI0CjP0Nc2k=
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/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
diff --git a/main.go b/main.go
index 0c45e6a..684ff6e 100644
--- a/main.go
+++ b/main.go
@@ -138,8 +138,26 @@ func main() {
}
// interaction: /config
+ bot.HandleMessageComponent(func(s *discordgo.Session, i *discordgo.InteractionCreate, data discordgo.MessageComponentInteractionData, resp *cmd.ResponseBuilder) {
+ if len(data.Values) != 1 {
+ logger.Alert("main.go - Handle config modify", "invalid data values", "values", data.Values)
+ return
+ }
+ switch data.Values[0] {
+ case config.ModifyXpRole:
+ config.HandleModifyXpRole(s, i, data, resp)
+ case config.ModifyFallbackChannel:
+ config.HandleModifyFallbackChannel(s, i, data, resp)
+ case config.ModifyDisChannel:
+ config.HandleModifyDisChannel(s, i, data, resp)
+ case config.ModifyTimeReduce:
+ config.HandleModifyPeriodicReduce(s, i, data, resp)
+ default:
+ logger.Alert("main.go - Detecting value", "unkown value", "value", data.Values[0])
+ return
+ }
+ }, commands.ConfigModify)
// xp role related
- bot.HandleMessageComponent(config.HandleModifyXpRole, config.ModifyXpRole)
bot.HandleMessageComponent(config.HandleXpRoleAddEdit, config.XpRoleAdd)
bot.HandleMessageComponent(config.HandleXpRoleAddEdit, config.XpRoleEdit)
bot.HandleMessageComponent(config.HandleXpRoleAddRole, config.XpRoleAddRole)
@@ -149,15 +167,12 @@ func main() {
bot.HandleModal(config.HandleXpRoleLevel, config.XpRoleAddLevel)
bot.HandleModal(config.HandleXpRoleLevel, config.XpRoleEditLevel)
// channel related
- bot.HandleMessageComponent(config.HandleModifyFallbackChannel, config.ModifyFallbackChannel)
bot.HandleMessageComponent(config.HandleFallbackChannelSet, config.FallbackChannelSet)
- bot.HandleMessageComponent(config.HandleModifyDisChannel, config.ModifyDisChannel)
bot.HandleMessageComponent(config.HandleDisChannel, config.DisChannelAdd)
bot.HandleMessageComponent(config.HandleDisChannel, config.DisChannelDel)
bot.HandleMessageComponent(config.HandleDisChannelAddSet, config.DisChannelAddSet)
bot.HandleMessageComponent(config.HandleDisChannelDelSet, config.DisChannelDelSet)
// reduce related
- bot.HandleMessageComponent(config.HandleModifyPeriodicReduce, config.ModifyTimeReduce)
bot.HandleModal(config.HandleTimeReduceSet, config.TimeReduceSet)
// xp handlers