-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.go
42 lines (34 loc) · 1.18 KB
/
defaults.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
41
42
package disroute
import "github.com/bwmarrin/discordgo"
var defaultResponseHandler = func(ctx *Ctx, resp *Response) {
if resp.Err != nil {
_ = ctx.Session().InteractionRespond(ctx.Interaction(), &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: resp.Err.Error(),
},
})
return
}
if resp.CustomResponse != nil {
_ = ctx.Session().InteractionRespond(ctx.Interaction(), resp.CustomResponse)
return
}
_ = ctx.Session().InteractionRespond(ctx.Interaction(), &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: resp.Message,
},
})
}
var defaultAutocompleteHandler = func(ctx *Ctx, choices []*discordgo.ApplicationCommandOptionChoice) {
_ = ctx.Session().InteractionRespond(ctx.Interaction(), &discordgo.InteractionResponse{
Type: discordgo.InteractionApplicationCommandAutocompleteResult,
Data: &discordgo.InteractionResponseData{
Choices: choices,
},
})
}
var defaultComponentKeyFunc = func(i *discordgo.Interaction) string {
return i.MessageComponentData().CustomID
}