mirror of
https://github.com/Xevion/banner.git
synced 2025-12-07 11:14:26 -06:00
Return commands at handler level, work on TermCommand implementation/definition
This commit is contained in:
17
helpers.go
17
helpers.go
@@ -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,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user