aboutsummaryrefslogtreecommitdiff
path: root/commands/config.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me>2024-04-15 16:56:01 +0200
committerAnhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me>2024-04-15 16:56:01 +0200
commit2b285f45234a8b6709ed1adf4ff151f028b51eff (patch)
treeaf3321961e58a9686b49efa564aec2194111af8d /commands/config.go
parenta8c0a395acc257ac019851f69d9913fd3fa51c9f (diff)
feat(config): fallback channel
Diffstat (limited to 'commands/config.go')
-rw-r--r--commands/config.go38
1 files changed, 37 insertions, 1 deletions
diff --git a/commands/config.go b/commands/config.go
index e663b40..62b7710 100644
--- a/commands/config.go
+++ b/commands/config.go
@@ -44,6 +44,11 @@ func ConfigShow(s *discordgo.Session, i *discordgo.InteractionCreate) {
Color: utils.Success,
Fields: []*discordgo.MessageEmbedField{
{
+ Name: "Salons par défaut",
+ Value: fmt.Sprintf("<#%s>", cfg.FallbackChannel),
+ Inline: false,
+ },
+ {
Name: "Rôles liés aux niveaux",
Value: roles,
Inline: false,
@@ -172,7 +177,7 @@ func ConfigChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
if !ok {
err := resp.Message("Le salon n'a pas été renseigné.").Send()
if err != nil {
- utils.SendAlert("commands/config.go - Channel not set", err.Error())
+ utils.SendAlert("commands/config.go - Channel not set (disabled)", err.Error())
}
return
}
@@ -211,3 +216,34 @@ func ConfigChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
utils.SendAlert("commands/config.go - Modification saved message", err.Error())
}
}
+
+func ConfigFallbackChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
+ optMap := utils.GenerateOptionMapForSubcommand(i)
+ resp := utils.ResponseBuilder{C: s, I: i}
+ resp.IsEphemeral()
+ // verify every args
+ salon, ok := optMap["channel"]
+ if !ok {
+ err := resp.Message("Le salon n'a pas été renseigné.").Send()
+ if err != nil {
+ utils.SendAlert("commands/config.go - Channel not set (fallback)", err.Error())
+ }
+ return
+ }
+ channel := salon.ChannelValue(s)
+ if channel.Type != discordgo.ChannelTypeGuildText {
+ err := resp.Message("Le salon n'est pas un salon textuel.").Send()
+ if err != nil {
+ utils.SendAlert("commands/config.go - Invalid channel type", err.Error())
+ }
+ return
+ }
+ cfg := config.GetGuildConfig(i.GuildID)
+ cfg.FallbackChannel = channel.ID
+ // save
+ cfg.Save()
+ err := resp.Message("Salon enregistré.").Send()
+ if err != nil {
+ utils.SendAlert("commands/config.go - Channel saved message", err.Error())
+ }
+}