himbot/lib/errors.go

28 lines
749 B
Go
Raw Permalink Normal View History

package lib
import (
2024-10-22 12:24:02 -06:00
"fmt"
"log"
2024-10-22 12:24:02 -06:00
"github.com/bwmarrin/discordgo"
)
2024-10-22 12:24:02 -06:00
// respondWithError sends an error message as a response to the interaction
func RespondWithError(s *discordgo.Session, i *discordgo.InteractionCreate, message string) {
log.Printf("Responding with error: %s", message)
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: message,
Flags: discordgo.MessageFlagsEphemeral,
},
})
if err != nil {
log.Printf("Error sending error response: %v", err)
}
2024-10-22 12:24:02 -06:00
}
2024-10-22 12:24:02 -06:00
func ThrowWithError(command, message string) error {
return fmt.Errorf("error in command '%s': %s", command, message)
}