aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/config.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/commands/config.go b/commands/config.go
index 14e4691..23a0add 100644
--- a/commands/config.go
+++ b/commands/config.go
@@ -102,73 +102,3 @@ func Config(_ *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMa
logger.Alert("config/guild.go - Sending config", err.Error())
}
}
-
-func ConfigChannel(s *discordgo.Session, i *discordgo.InteractionCreate, optMap cmd.OptionMap, resp *cmd.ResponseBuilder) {
- resp.IsEphemeral()
- // verify every args
- t, ok := optMap["type"]
- if !ok {
- err := resp.SetMessage("Le type d'action n'a pas été renseigné.").Send()
- if err != nil {
- logger.Alert("commands/config.go - Action type not set", err.Error())
- }
- return
- }
- ts := t.StringValue()
- salon, ok := optMap["channel"]
- if !ok {
- err := resp.SetMessage("Le salon n'a pas été renseigné.").Send()
- if err != nil {
- logger.Alert("commands/config.go - Channel not set (disabled)", err.Error())
- }
- return
- }
- channel := salon.ChannelValue(s)
- cfg := config.GetGuildConfig(i.GuildID)
- switch ts {
- case "add":
- if strings.Contains(cfg.DisabledChannels, channel.ID) {
- err := resp.SetMessage("Le salon est déjà dans la liste des salons désactivés").Send()
- if err != nil {
- logger.Alert("commands/config.go - Channel already disabled", err.Error())
- }
- return
- }
- cfg.DisabledChannels += channel.ID + ";"
- case "del":
- if !strings.Contains(cfg.DisabledChannels, channel.ID) {
- err := resp.SetMessage("Le salon n'est pas désactivé").Send()
- if err != nil {
- logger.Alert("commands/config.go - Channel not disabled", err.Error())
- }
- return
- }
- cfg.DisabledChannels = strings.ReplaceAll(cfg.DisabledChannels, channel.ID+";", "")
- default:
- err := resp.SetMessage("Le type d'action n'est pas valide.").Send()
- if err != nil {
- logger.Alert("commands/config.go - Invalid action type", err.Error())
- }
- return
- }
- // save
- err := cfg.Save()
- if err != nil {
- logger.Alert(
- "commands/config.go - Saving config",
- err.Error(),
- "guild_id",
- i.GuildID,
- "type",
- ts,
- "channel_id",
- channel.ID,
- )
- err = resp.SetMessage("Il y a eu une erreur lors de la modification de de la base de données.").Send()
- } else {
- err = resp.SetMessage("Modification sauvegardé.").Send()
- }
- if err != nil {
- logger.Alert("commands/config.go - Modification saved message", err.Error())
- }
-}