-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
discordeno.ts
301 lines (279 loc) · 11.6 KB
/
discordeno.ts
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
import { ApplicationCommandOption } from "../transformers/applicationCommandOption.ts";
import { ApplicationCommandOptionChoice } from "../transformers/applicationCommandOptionChoice.ts";
import { Embed } from "../transformers/embed.ts";
import {
AllowedMentionsTypes,
ApplicationCommandTypes,
ButtonStyles,
InteractionResponseTypes,
Localization,
MessageComponentTypes,
OverwriteTypes,
PermissionStrings,
TextStyles,
} from "./shared.ts";
export type MessageComponents = ActionRow[];
/** https://discord.com/developers/docs/interactions/message-components#actionrow */
export interface ActionRow {
/** Action rows are a group of buttons. */
type: MessageComponentTypes.ActionRow;
/** The components in this row */
components:
| [
| ButtonComponent
| InputTextComponent
| SelectMenuComponent
| SelectMenuChannelsComponent
| SelectMenuRolesComponent
| SelectMenuUsersComponent
| SelectMenuUsersAndRolesComponent,
]
| [ButtonComponent, ButtonComponent]
| [ButtonComponent, ButtonComponent, ButtonComponent]
| [ButtonComponent, ButtonComponent, ButtonComponent, ButtonComponent]
| [ButtonComponent, ButtonComponent, ButtonComponent, ButtonComponent, ButtonComponent];
}
/** https://discord.com/developers/docs/interactions/message-components#button-object-button-structure */
export interface ButtonComponent {
/** All button components have type 2 */
type: MessageComponentTypes.Button;
/** for what the button says (max 80 characters) */
label: string;
/** a dev-defined unique string sent on click (max 100 characters). type 5 Link buttons can not have a custom_id */
customId?: string;
/** For different styles/colors of the buttons */
style: ButtonStyles;
/** Emoji object that includes fields of name, id, and animated supporting unicode and custom emojis. */
emoji?: {
/** Emoji id */
id?: bigint;
/** Emoji name */
name?: string;
/** Whether this emoji is animated */
animated?: boolean;
};
/** optional url for link-style buttons that can navigate a user to the web. Only type 5 Link buttons can have a url */
url?: string;
/** Whether or not this button is disabled */
disabled?: boolean;
}
/** https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure */
export interface SelectMenuComponent {
/** SelectMenu Component is of type 3 */
type: MessageComponentTypes.SelectMenu;
/** A custom identifier for this component. Maximum 100 characters. */
customId: string;
/** A custom placeholder text if nothing is selected. Maximum 150 characters. */
placeholder?: string;
/** The minimum number of items that must be selected. Default 1. Between 1-25. */
minValues?: number;
/** The maximum number of items that can be selected. Default 1. Between 1-25. */
maxValues?: number;
/** The choices! Maximum of 25 items. */
options: SelectOption[];
/** Whether or not this select is disabled */
disabled?: boolean;
}
export interface SelectMenuUsersComponent {
/** SelectMenuChannels Component is of type 5 */
type: MessageComponentTypes.SelectMenuUsers;
/** A custom identifier for this component. Maximum 100 characters. */
customId: string;
/** A custom placeholder text if nothing is selected. Maximum 150 characters. */
placeholder?: string;
/** The minimum number of items that must be selected. Default 1. Between 1-25. */
minValues?: number;
/** The maximum number of items that can be selected. Default 1. Between 1-25. */
maxValues?: number;
/** Whether or not this select is disabled */
disabled?: boolean;
}
export interface SelectMenuRolesComponent {
/** SelectMenuChannels Component is of type 6 */
type: MessageComponentTypes.SelectMenuRoles;
/** A custom identifier for this component. Maximum 100 characters. */
customId: string;
/** A custom placeholder text if nothing is selected. Maximum 150 characters. */
placeholder?: string;
/** The minimum number of items that must be selected. Default 1. Between 1-25. */
minValues?: number;
/** The maximum number of items that can be selected. Default 1. Between 1-25. */
maxValues?: number;
/** Whether or not this select is disabled */
disabled?: boolean;
}
export interface SelectMenuUsersAndRolesComponent {
/** SelectMenuChannels Component is of type 7 */
type: MessageComponentTypes.SelectMenuUsersAndRoles;
/** A custom identifier for this component. Maximum 100 characters. */
customId: string;
/** A custom placeholder text if nothing is selected. Maximum 150 characters. */
placeholder?: string;
/** The minimum number of items that must be selected. Default 1. Between 1-25. */
minValues?: number;
/** The maximum number of items that can be selected. Default 1. Between 1-25. */
maxValues?: number;
/** The choices! Maximum of 25 items. */
options: SelectOption[];
/** Whether or not this select is disabled */
disabled?: boolean;
}
export interface SelectMenuChannelsComponent {
/** SelectMenuChannels Component is of type 8 */
type: MessageComponentTypes.SelectMenuChannels;
/** A custom identifier for this component. Maximum 100 characters. */
customId: string;
/** A custom placeholder text if nothing is selected. Maximum 150 characters. */
placeholder?: string;
/** The minimum number of items that must be selected. Default 1. Between 1-25. */
minValues?: number;
/** The maximum number of items that can be selected. Default 1. Between 1-25. */
maxValues?: number;
/** Whether or not this select is disabled */
disabled?: boolean;
}
export interface SelectOption {
/** The user-facing name of the option. Maximum 25 characters. */
label: string;
/** The dev-defined value of the option. Maximum 100 characters. */
value: string;
/** An additional description of the option. Maximum 50 characters. */
description?: string;
/** The id, name, and animated properties of an emoji. */
emoji?: {
/** Emoji id */
id?: bigint;
/** Emoji name */
name?: string;
/** Whether this emoji is animated */
animated?: boolean;
};
/** Will render this option as already-selected by default. */
default?: boolean;
}
/** https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure */
export interface InputTextComponent {
/** InputText Component is of type 4 */
type: MessageComponentTypes.InputText;
/** The style of the InputText */
style: TextStyles;
/** The customId of the InputText */
customId: string;
/** The label of the InputText. Maximum 45 characters */
label: string;
/** The placeholder of the InputText */
placeholder?: string;
/** The minimum length of the text the user has to provide */
minLength?: number;
/** The maximum length of the text the user has to provide */
maxLength?: number;
/** Whether or not this input is required. */
required?: boolean;
/** Pre-filled value for input text. */
value?: string;
}
/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object */
export interface AllowedMentions {
/** An array of allowed mention types to parse from the content. */
parse?: AllowedMentionsTypes[];
/** For replies, whether to mention the author of the message being replied to (default false) */
repliedUser?: boolean;
/** Array of role_ids to mention (Max size of 100) */
roles?: bigint[];
/** Array of user_ids to mention (Max size of 100) */
users?: bigint[];
}
export interface FileContent {
/** The file blob */
blob: Blob;
/** The name of the file */
name: string;
}
/** https://discord.com/developers/docs/resources/guild#search-guild-members-query-string-params */
export interface SearchMembers {
/** Query string to match username(s) and nickname(s) against */
query: string;
/** Max number of members to return (1-1000). Default: 1 */
limit?: number;
}
export type CreateApplicationCommand = CreateSlashApplicationCommand | CreateContextApplicationCommand;
/** https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params */
export interface CreateSlashApplicationCommand {
/**
* Name of command, 1-32 characters.
* `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
* If there is a lowercase variant of any letters used, you must use those.
* Characters with no lowercase variants and/or uncased letters are still allowed.
* ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
*/
name: string;
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
nameLocalizations?: Localization;
/** 1-100 character description */
description: string;
/** Localization object for the `description` field. Values follow the same restrictions as `description` */
descriptionLocalizations?: Localization;
/** Type of command, defaults `ApplicationCommandTypes.ChatInput` if not set */
type?: ApplicationCommandTypes;
/** Parameters for the command */
options?: ApplicationCommandOption[];
/** Set of permissions represented as a bit set */
defaultMemberPermissions?: PermissionStrings[];
/** Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible. */
dmPermission?: boolean;
}
/** https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params */
export interface CreateContextApplicationCommand
extends Omit<CreateSlashApplicationCommand, "options" | "description" | "descriptionLocalizations"> {
/** The type of the command */
type: ApplicationCommandTypes.Message | ApplicationCommandTypes.User;
}
export function isContextApplicationCommand(
command: CreateApplicationCommand,
): command is CreateContextApplicationCommand {
return command.type === ApplicationCommandTypes.Message || command.type === ApplicationCommandTypes.User;
}
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */
export interface InteractionResponse {
/** The type of response */
type: InteractionResponseTypes;
/** An optional response message */
data?: InteractionCallbackData;
}
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */
export interface InteractionCallbackData {
/** The message contents (up to 2000 characters) */
content?: string;
/** True if this is a TTS message */
tts?: boolean;
/** Embedded `rich` content (up to 6000 characters) */
embeds?: Embed[];
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions;
/** The contents of the file being sent */
file?: FileContent | FileContent[];
/** The customId you want to use for this modal response. */
customId?: string;
/** The title you want to use for this modal response. */
title?: string;
/** The components you would like to have sent in this message */
components?: MessageComponents;
/** Message flags combined as a bit field (only SUPPRESS_EMBEDS and EPHEMERAL can be set) */
flags?: number;
/** Autocomplete choices (max of 25 choices) */
choices?: ApplicationCommandOptionChoice[];
}
export interface WithReason {
/** The reason which should be added in the audit logs for doing this action. */
reason?: string;
}
export interface OverwriteReadable {
/** Role or user id */
id: bigint;
/** Either 0 (role) or 1 (member) */
type: OverwriteTypes;
/** Permission bit set */
allow?: PermissionStrings[];
/** Permission bit set */
deny?: PermissionStrings[];
}