refactor(commands): rename CommandFunc to InteractionHandler and make it private

This commit is contained in:
Guz
2024-11-18 17:42:01 -03:00
parent dfe40d9972
commit e5f7c26a6c

View File

@@ -14,7 +14,7 @@ type Command interface {
}
type (
CommandFunc = func(s *discordgo.Session, ic *discordgo.InteractionCreate) error
interactionHandler = func(s *discordgo.Session, ic *discordgo.InteractionCreate) error
commandName = string
commandId = string
)
@@ -56,7 +56,7 @@ func (h *CommandsHandler) UpdateCommands(
return err
}
handleFuncs := make(map[CommandName]CommandFunc, len(commandsMap))
commandInteractionHandlers := make(map[commandName]interactionHandler, len(commandsMap))
for _, cmd := range commandsMap {
var err error
@@ -92,11 +92,11 @@ func (h *CommandsHandler) UpdateCommands(
}
}
handleFuncs[appCmd.Name] = cmd.Handle
commandInteractionHandlers[appCmd.Name] = cmd.Handle
}
h.session.AddHandler(func(s *discordgo.Session, ic *discordgo.InteractionCreate) {
h.handleInteraction(handleFuncs, s, ic)
h.handleInteraction(commandInteractionHandlers, s, ic)
})
return nil