From ebab5cd09f73cd68089f59a68431bbc283fba30b Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 21 Aug 2025 13:33:17 +0200 Subject: [PATCH] feat(command): do not use new components --- commands/config.go | 53 +++++++++++++++++++++++++++++++++++++--------- config/guild.go | 7 +++--- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/commands/config.go b/commands/config.go index b6e6854..b62d413 100644 --- a/commands/config.go +++ b/commands/config.go @@ -2,13 +2,14 @@ package commands import ( "fmt" + "strings" + "github.com/anhgelus/gokord/cmd" "github.com/anhgelus/gokord/component" "github.com/anhgelus/gokord/logger" "github.com/anhgelus/les-copaings-bot/config" "github.com/anhgelus/les-copaings-bot/exp" "github.com/bwmarrin/discordgo" - "strings" ) const ( @@ -48,15 +49,40 @@ func Config(_ *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMa } else { defaultChan = fmt.Sprintf("<#%s>", cfg.FallbackChannel) } + //comp := component.New(). + // Add(component.NewTextDisplay("# Config")). + // Add(component.NewTextDisplay("**Salon par défaut**\n" + defaultChan)). + // Add(component.NewSeparator()). + // Add(component.NewTextDisplay("**Rôles liés aux niveaux**\n" + roles)). + // Add(component.NewSeparator()). + // Add(component.NewTextDisplay("**Salons désactivés**\n" + chans)). + // Add(component.NewSeparator()). + // Add(component.NewTextDisplay(fmt.Sprintf("**%s**\n%d", "Jours avant la réduction", cfg.DaysXPRemains))). + // Add(component.NewActionRow().Add(component.NewStringSelect(ConfigModify). + // SetPlaceholder("Modifier..."). + // AddOption( + // component.NewSelectOption("Rôles liés à l'XP", config.ModifyXpRole). + // SetDescription("Gère les rôles liés à l'XP"). + // SetEmoji(&discordgo.ComponentEmoji{Name: "🏅"}), + // ). + // AddOption( + // component.NewSelectOption("Salons désactivés", config.ModifyDisChannel). + // SetDescription("Gère les salons désactivés"). + // SetEmoji(&discordgo.ComponentEmoji{Name: "❌"}), + // ). + // AddOption( + // // I don't have a better idea for this... + // component.NewSelectOption("Salons par défaut", config.ModifyFallbackChannel). + // SetDescription("Spécifie le salon par défaut"). + // SetEmoji(&discordgo.ComponentEmoji{Name: "💾"}), + // ). + // AddOption( + // component.NewSelectOption("Temps avec la réduction", config.ModifyTimeReduce). + // SetDescription("Gère le temps avant la réduction d'XP"). + // SetEmoji(&discordgo.ComponentEmoji{Name: "⌛"}), + // ), + // )) comp := component.New(). - Add(component.NewTextDisplay("# Config")). - Add(component.NewTextDisplay("**Salon par défaut**\n" + defaultChan)). - Add(component.NewSeparator()). - Add(component.NewTextDisplay("**Rôles liés aux niveaux**\n" + roles)). - Add(component.NewSeparator()). - Add(component.NewTextDisplay("**Salons désactivés**\n" + chans)). - Add(component.NewSeparator()). - Add(component.NewTextDisplay(fmt.Sprintf("**%s**\n%d", "Jours avant la réduction", cfg.DaysXPRemains))). Add(component.NewActionRow().Add(component.NewStringSelect(ConfigModify). SetPlaceholder("Modifier..."). AddOption( @@ -81,7 +107,14 @@ func Config(_ *discordgo.Session, i *discordgo.InteractionCreate, _ cmd.OptionMa SetEmoji(&discordgo.ComponentEmoji{Name: "⌛"}), ), )) - err := resp.SetComponents(comp).IsEphemeral().Send() + msg := fmt.Sprintf( + "# Config\n**Salon par défaut**\n%s\n\n**Rôles liés aux niveaux**\n%s\n\n**Salons désactivés**\n%s\n\n**Jours avant la réduction**\n%d", + defaultChan, + roles, + chans, + cfg.DaysXPRemains, + ) + err := resp.SetComponents(comp).SetMessage(msg).IsEphemeral().Send() if err != nil { logger.Alert("config/guild.go - Sending config", err.Error()) } diff --git a/config/guild.go b/config/guild.go index 3071d95..8384d5b 100644 --- a/config/guild.go +++ b/config/guild.go @@ -1,9 +1,9 @@ package config import ( - "github.com/anhgelus/gokord" - "github.com/anhgelus/gokord/logger" "strings" + + "github.com/anhgelus/gokord" ) type GuildConfig struct { @@ -18,8 +18,7 @@ type GuildConfig struct { func GetGuildConfig(guildID string) *GuildConfig { cfg := GuildConfig{GuildID: guildID} if err := cfg.Load(); err != nil { - logger.Alert("config/guild.go - Loading guild config", err.Error(), "guild_id", guildID) - return nil + panic(err) } return &cfg }