forked from bwmarrin/discordgo
/
interaction.go
123 lines (105 loc) · 5.16 KB
/
interaction.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package discordgo
import (
"time"
)
// InteractionDeadline is a deadline for responding to an interaction, if you haven't responded in the time, you won't be able to respond later.
const InteractionDeadline = time.Second * 3
// ApplicationCommand is representing application's slash command.
type ApplicationCommand struct {
ID string `json:"id,omitempty"`
ApplicationID string `json:"application_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Options []*ApplicationCommandOption `json:"options,omitempty"`
}
// ApplicationCommandOptionType is type of an slash-command's option.
type ApplicationCommandOptionType uint8
// Application command option types.
const (
_ = ApplicationCommandOptionType(iota)
ApplicationCommandOptionSubCommand
ApplicationCommandOptionSubCommandGroup
ApplicationCommandOptionString
ApplicationCommandOptionInteger
ApplicationCommandOptionBoolean
ApplicationCommandOptionUser
ApplicationCommandOptionChannel
ApplicationCommandOptionRole
)
// ApplicationCommandOption is representing an option/subcommand/subcommands group.
type ApplicationCommandOption struct {
Type ApplicationCommandOptionType `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Default bool `json:"default,omitempty"`
Required bool `json:"required,omitempty"`
Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"`
Options []*ApplicationCommandOption `json:"options,omitempty"`
}
// ApplicationCommandOptionChoice is representing slash-command's option choice.
type ApplicationCommandOptionChoice struct {
Name string `json:"name,omitempty"`
Value interface{} `json:"value,omitempty"`
}
// InteractionType is representing interaction type.
type InteractionType uint8
const (
_ = InteractionType(iota)
// InteractionPing is type of interaction for ping.
InteractionPing
// InteractionApplicationCommand is type of interaction for application commands.
InteractionApplicationCommand
)
// Interaction is representing interaction with application.
type Interaction struct {
ID string `json:"id"`
Type InteractionType `json:"type"`
Data ApplicationCommandInteractionData `json:"data"`
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
Member *Member `json:"member"`
Token string `json:"token"`
Version int `json:"version"`
}
// ApplicationCommandInteractionData is representing interaction data for application command.
type ApplicationCommandInteractionData struct {
ID string
Name string
Options []*ApplicationCommandInteractionDataOption
}
// ApplicationCommandInteractionDataOption is representing an option of application's command.
type ApplicationCommandInteractionDataOption struct {
Name string `json:"name,omitempty"`
// Contains the value specified by InteractionType
Value interface{} `json:"value,omitempty"`
Options []*ApplicationCommandInteractionDataOption `json:"options,omitempty"`
}
// InteractionResponseType is type of interaction response.
type InteractionResponseType uint8
// Interaction response types.
const (
_ = InteractionResponseType(iota)
// InteractionResponsePong is an interaction response type when you need to just ACK a "Ping".
InteractionResponsePong
// InteractionResponsePong is an interaction response type when you need to ACK a command without sending a message, eating the user's input.
InteractionResponseAcknowledge
// InteractionResponsePong is an interaction response type when you need to respond with a message, eating the user's input.
InteractionResponseChannelMessage
// InteractionResponsePong is an interaction response type when you need to respond with a message, showing the user's input.
InteractionResponseChannelMessageWithSource
// InteractionResponsePong is an interaction response type when you need to ACK a command without sending a message, showing the user's input.
InteractionResponseACKWithSource
)
// InteractionResponse is representing response for interaction with application.
type InteractionResponse struct {
Type InteractionResponseType `json:"type,omitempty"`
Data *InteractionApplicationCommandResponseData `json:"data,omitempty"`
}
// InteractionApplicationCommandResponseData is callback data for application command interaction.
type InteractionApplicationCommandResponseData struct {
TTS bool `json:"tts,omitempty"`
Content string `json:"content,omitempty"`
Embeds []*MessageEmbed `json:"embeds,omitempty"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Flags uint64 `json:"flags,omitempty"` // NOTE: Undocumented feature, be careful with it.
}