From fde981eefc4ece7fbc8f328b8dded9d88e52ac8e Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Mon, 19 Aug 2024 20:22:28 -0300 Subject: [PATCH] refactor(commands): move Command struct to it's own file --- internals/discord/bot/commands/channels.go | 4 ---- internals/discord/bot/commands/commands.go | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 internals/discord/bot/commands/commands.go diff --git a/internals/discord/bot/commands/channels.go b/internals/discord/bot/commands/channels.go index caa4dea..eebc49e 100644 --- a/internals/discord/bot/commands/channels.go +++ b/internals/discord/bot/commands/channels.go @@ -6,10 +6,6 @@ import ( dgo "github.com/bwmarrin/discordgo" ) -type Command interface { - Info() *dgo.ApplicationCommand - Handle(s *dgo.Session, i *dgo.InteractionCreate) error -} type ManageChannel struct { db guilddb.GuildDB diff --git a/internals/discord/bot/commands/commands.go b/internals/discord/bot/commands/commands.go new file mode 100644 index 0000000..81b0ace --- /dev/null +++ b/internals/discord/bot/commands/commands.go @@ -0,0 +1,21 @@ +package commands + +import ( + dgo "github.com/bwmarrin/discordgo" +) + +type Command interface { + Info() *dgo.ApplicationCommand + Handle(s *dgo.Session, i *dgo.InteractionCreate) error +} +func getOptions(i *dgo.InteractionCreate) map[string]*dgo.ApplicationCommandInteractionDataOption { + opts := i.ApplicationCommandData().Options + m := make(map[string]*dgo.ApplicationCommandInteractionDataOption, len(opts)) + + for _, opt := range opts { + m[opt.Name] = opt + } + + return m +} +