From b91d55bbb7496eb5232ef516ad345a350048b55e Mon Sep 17 00:00:00 2001 From: Zachary Myers Date: Wed, 14 Sep 2022 00:39:20 +0000 Subject: [PATCH] update router --- router.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/router.go b/router.go index 50d7ea9..75b72ab 100644 --- a/router.go +++ b/router.go @@ -1,8 +1,9 @@ package cmdlr3 import ( - "github.com/andersfylling/disgord" "log" + + "github.com/andersfylling/disgord" ) type Router struct { @@ -36,10 +37,10 @@ func (r *Router) InitializeCommands() disgord.HandlerReady { for i := range r.Commands { if err := r.Client.ApplicationCommand(user.ID).Global().Create(&disgord.CreateApplicationCommand{ - Type: disgord.ApplicationCommandType(r.Commands[i].Type), - Name: r.Commands[i].Name, - Description: r.Commands[i].Description, - Options: append(r.Commands[i].Options, r.Commands[i].ConvertSubcommandArray()...), + Type: disgord.ApplicationCommandType(r.Commands[i].Type), + Name: r.Commands[i].Name, + Description: r.Commands[i].Description, + Options: append(r.Commands[i].Options, r.Commands[i].ConvertSubcommandArray()...), }); err != nil { log.Fatal(err) } @@ -80,18 +81,15 @@ func (r *Router) Handler() disgord.HandlerInteractionCreate { } for _, cmd := range r.Commands { if h.Data.Name != "" && h.Data.Name == cmd.Name { - if h.Data.Options != nil { - subCmd := checkForSubCommand(cmd, h.Data.Options) - - if subCmd != nil { - subCmd.Handler(&SubCommandCtx{ - Client: r.Client, - Session: &s, - Interaction: h, - Command: subCmd, - Router: r, - }) - } + subCmd := checkForSubCommand(cmd, h.Data.Options) + if h.Data.Options != nil && subCmd != nil { + subCmd.Handler(&SubCommandCtx{ + Client: r.Client, + Session: &s, + Interaction: h, + Command: subCmd, + Router: r, + }) return }