/
pkg.go
40 lines (35 loc) · 1.12 KB
/
pkg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package customerrors
import (
e "errors"
"github.com/apex/log"
"github.com/bwmarrin/discordgo"
)
var (
ErrMissingName = e.New("Missing Name")
ErrMissingStart = e.New("Missing Start")
ErrMissingDuration = e.New("Missing Duration")
ErrMissingId = e.New("Missing Id")
ErrStartWrongFormat = e.New("Start is in wrong format")
)
func ErrorResponse(s *discordgo.Session, i *discordgo.Interaction, message string, errorCode *string) {
if message == "" {
message = "There was an error! Please try again in a fwe minutes or let the @Officers know"
}
if errorCode != nil {
message += "\n\nError code: " + *errorCode
}
if err := s.InteractionRespond(i, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Flags: discordgo.MessageFlagsEphemeral,
Content: message,
},
}); err != nil {
if _, err := s.FollowupMessageCreate(i, false, &discordgo.WebhookParams{
Content: message,
Flags: discordgo.MessageFlagsEphemeral,
}); err != nil {
log.WithError(err).Error("responding to event command interaction")
}
}
}