/
application.go
198 lines (173 loc) · 8.91 KB
/
application.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package discord
import (
"encoding/json"
"time"
)
// application.go represents the application object and integrations.
// ApplicationTeamMemberState represents the state of a member in a team.
type ApplicationTeamMemberState uint8
const (
ApplicationTeamMemberStateInvited ApplicationTeamMemberState = 1 + iota
ApplicationTeamMemberStateAccepted
)
// ApplicationCommandType represents the different types of application command.
type ApplicationCommandType uint8
const (
ApplicationCommandTypeChatInput ApplicationCommandType = 1 + iota
ApplicationCommandTypeUser
ApplicationCommandTypeMessage
)
// ApplicationCommandOptionType represents the different types of options.
type ApplicationCommandOptionType uint8
const (
ApplicationCommandOptionTypeSubCommand ApplicationCommandOptionType = 1 + iota
ApplicationCommandOptionTypeSubCommandGroup
ApplicationCommandOptionTypeString
ApplicationCommandOptionTypeInteger
ApplicationCommandOptionTypeBoolean
ApplicationCommandOptionTypeUser
ApplicationCommandOptionTypeChannel
ApplicationCommandOptionTypeRole
ApplicationCommandOptionTypeMentionable
ApplicationCommandOptionTypeNumber
ApplicationCommandOptionTypeAttachment
)
// ApplicationCommandPermissionType represents the target for a command permission.
type ApplicationCommandPermissionType uint8
const (
ApplicationCommandPermissionTypeRole ApplicationCommandPermissionType = 1 + iota
ApplicationCommandPermissionTypeUser
)
// IntegrationType represents the type of integration.
type IntegrationType string
const (
IntegrationTypeTwitch IntegrationType = "twitch"
IntegrationTypeYoutube IntegrationType = "youtube"
IntegrationTypeDiscord IntegrationType = "discord"
)
// IntegrationExpireBehavior represents the integration expiration.
type IntegrationExpireBehavior uint8
const (
IntegrationExpireBehaviorRemoveRole IntegrationExpireBehavior = iota
IntegrationExpireBehaviorKick
)
// Application response from REST.
type Application struct {
Owner *User `json:"owner,omitempty"`
Bot *User `json:"bot,omitempty"`
PrimarySKUID *Snowflake `json:"primary_sku_id,omitempty"`
GuildID *Snowflake `json:"guild_id,omitempty"`
Team *ApplicationTeam `json:"team,omitempty"`
PrivacyPolicyURL string `json:"privacy_policy_url,omitempty"`
TermsOfServiceURL string `json:"terms_of_service,omitempty"`
VerifyKey string `json:"verify_key"`
Description string `json:"description"`
Icon string `json:"icon,omitempty"`
Slug string `json:"slug,omitempty"`
CoverImage string `json:"cover_image,omitempty"`
Name string `json:"name"`
RPCOrigins []string `json:"rpc_origins,omitempty"`
ID Snowflake `json:"id"`
Flags int32 `json:"flags,omitempty"`
BotRequireCodeGrant bool `json:"bot_require_code_grant"`
BotPublic bool `json:"bot_public"`
}
// ApplicationTeam represents the team of an application.
type ApplicationTeam struct {
Icon string `json:"icon,omitempty"`
Name string `json:"name"`
Members []*ApplicationTeamMember `json:"members"`
ID Snowflake `json:"id"`
OwnerUserID Snowflake `json:"owner_user_id"`
}
// ApplicationTeamMembers represents a member of a team.
type ApplicationTeamMember struct {
User User `json:"user"`
MembershipState *ApplicationTeamMemberState `json:"membership_state"`
Permissions []string `json:"permissions"`
TeamID Snowflake `json:"team_id"`
}
// ApplicationCommand represents an application's command.
type ApplicationCommand struct {
DefaultMemberPermission *Int64 `json:"default_member_permissions,omitempty"`
Type *ApplicationCommandType `json:"type,omitempty"`
ApplicationID *Snowflake `json:"application_id,omitempty"`
GuildID *Snowflake `json:"guild_id,omitempty"`
NameLocalizations map[string]string `json:"name_localizations,omitempty"`
DescriptionLocalizations map[string]string `json:"description_localizations,omitempty"`
ID *Snowflake `json:"id,omitempty"`
DMPermission *bool `json:"dm_permission,omitempty"`
DefaultPermission *bool `json:"default_permission,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Options []*ApplicationCommandOption `json:"options,omitempty"`
Version Int64 `json:"version,omitempty"`
}
// GuildApplicationCommandPermissions represent a guilds application permissions.
type GuildApplicationCommandPermissions struct {
Permissions []*ApplicationCommandPermissions `json:"permissions"`
ID Snowflake `json:"id"`
ApplicationID Snowflake `json:"application_id"`
GuildID Snowflake `json:"guild_id"`
}
// ApplicationCommandPermissions represents the rules for enabling or disabling a command.
type ApplicationCommandPermissions struct {
ID Snowflake `json:"id"`
Type ApplicationCommandPermissionType `json:"type"`
Allowed bool `json:"permission"`
}
// ApplicationCommandOption represents the options for an application command.
type ApplicationCommandOption struct {
MinValue *int32 `json:"min_value,omitempty"`
Autocomplete *bool `json:"autocomplete,omitempty"`
NameLocalizations map[string]string `json:"name_localizations,omitempty"`
MaxLength *int32 `json:"max_length,omitempty"`
DescriptionLocalizations map[string]string `json:"description_localizations,omitempty"`
MinLength *int32 `json:"min_length,omitempty"`
MaxValue *int32 `json:"max_value,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name"`
ChannelTypes []ChannelType `json:"channel_types,omitempty"`
Options []*ApplicationCommandOption `json:"options,omitempty"`
Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"`
Required bool `json:"required,omitempty"`
Type ApplicationCommandOptionType `json:"type"`
}
// ApplicationCommandOptionChoice represents the different choices.
type ApplicationCommandOptionChoice struct {
Name string `json:"name"`
NameLocalizations map[string]string `json:"name_localizations,omitempty"`
Value json.RawMessage `json:"value"`
}
// ApplicationSelectOption represents the structure of select options.
type ApplicationSelectOption struct {
Emoji *Emoji `json:"emoji,omitempty"`
Label string `json:"label"`
Value string `json:"value"`
Description string `json:"description,omitempty"`
Default bool `json:"default,omitempty"`
}
// Integration represents the structure of an integration.
type Integration struct {
SyncedAt time.Time `json:"synced_at,omitempty"`
ExpireBehavior *IntegrationExpireBehavior `json:"expire_behavior,omitempty"`
User *User `json:"user,omitempty"`
Application *Application `json:"application,omitempty"`
GuildID *Snowflake `json:"guild_id,omitempty"`
RoleID *Snowflake `json:"role_id,omitempty"`
Account IntegrationAccount `json:"account"`
Type IntegrationType `json:"type"`
Name string `json:"name"`
ID Snowflake `json:"id"`
ExpireGracePeriod int32 `json:"expire_grace_period,omitempty"`
SubscriberCount int32 `json:"subscriber_count,omitempty"`
EnableEmoticons bool `json:"enable_emoticons"`
Syncing bool `json:"syncing"`
Revoked bool `json:"revoked"`
Enabled bool `json:"enabled"`
}
// IntegrationAccount represents the account of the integration.
type IntegrationAccount struct {
ID string `json:"id"`
Name string `json:"name"`
}