Skip to content

Commit

Permalink
update router
Browse files Browse the repository at this point in the history
  • Loading branch information
zackartz committed Sep 14, 2022
1 parent 0a82d6c commit b91d55b
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions router.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package cmdlr3

import (
"github.com/andersfylling/disgord"
"log"

"github.com/andersfylling/disgord"
)

type Router struct {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit b91d55b

Please sign in to comment.