Return commands at handler level, work on TermCommand implementation/definition

This commit is contained in:
2024-01-17 23:57:22 -06:00
parent 2ad241a475
commit d03490ad4d
3 changed files with 65 additions and 18 deletions

10
main.go
View File

@@ -156,12 +156,18 @@ func main() {
log.Info().Str("name", name).Str("user", interaction.Member.User.Username).Dict("options", options).Msg("Command Invoked")
// Call handler
handler(internalSession, interaction)
err := handler(internalSession, interaction)
// Log error
if err != nil {
// TODO: Find a way to merge the response with the handler's error
log.Error().Str("commandName", name).Err(err).Msg("Command Handler Error")
}
} else {
log.Error().Str("commandName", name).Msg("Command Interaction Has No Handler")
// Respond with error
RespondError(internalSession, interaction.Interaction, "Command not found", nil)
RespondError(internalSession, interaction.Interaction, "Unexpected Error: interaction has no handler", nil)
}
})