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

View File

@@ -12,6 +12,7 @@ import (
"strings"
"time"
"github.com/bwmarrin/discordgo"
"github.com/rs/zerolog"
log "github.com/rs/zerolog/log"
)
@@ -301,3 +302,19 @@ func DumpResponse(res *http.Response) {
log.Info().Str("filename", filename).Str("content-type", contentType).Msg("Dumped response body")
}
// ResponseError responds to an interaction with an error message
// TODO: Improve with a proper embed and colors
func RespondError(session *discordgo.Session, interaction *discordgo.Interaction, message string, err error) {
// Optional: log the error
if err != nil {
log.Err(err).Msg(message)
}
session.InteractionRespond(interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: message,
},
})
}