disgroove 2.2.7-dev.4cca8cf → 2.2.7-dev.64580a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/Client.d.ts +12 -10
- package/dist/lib/Client.js +42 -2
- package/dist/lib/constants.d.ts +24 -21
- package/dist/lib/constants.js +26 -23
- package/dist/lib/gateway/Shard.js +14 -0
- package/dist/lib/transformers/Components.d.ts +13 -3
- package/dist/lib/transformers/Components.js +201 -124
- package/dist/lib/transformers/Interactions.js +32 -38
- package/dist/lib/transformers/Messages.d.ts +4 -3
- package/dist/lib/transformers/Messages.js +48 -34
- package/dist/lib/types/gateway-events.d.ts +20 -0
- package/dist/lib/types/interaction.d.ts +6 -12
- package/dist/lib/types/message-components.d.ts +219 -122
- package/dist/lib/types/message.d.ts +3 -5
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -8,19 +8,20 @@ class Components {
|
|
|
8
8
|
type: actionRow.type,
|
|
9
9
|
components: actionRow.components.map((c) => {
|
|
10
10
|
switch (c.type) {
|
|
11
|
-
case constants_js_1.ComponentTypes.Button:
|
|
11
|
+
case constants_js_1.ComponentTypes.Button:
|
|
12
12
|
return Components.buttonFromRaw(c);
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
14
|
+
return Components.stringSelectFromRaw(c);
|
|
15
|
+
case constants_js_1.ComponentTypes.TextInput:
|
|
15
16
|
return Components.textInputFromRaw(c);
|
|
16
|
-
}
|
|
17
|
-
case constants_js_1.ComponentTypes.ChannelSelect:
|
|
18
|
-
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
19
|
-
case constants_js_1.ComponentTypes.RoleSelect:
|
|
20
17
|
case constants_js_1.ComponentTypes.UserSelect:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
return Components.userSelectFromRaw(c);
|
|
19
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
|
20
|
+
return Components.roleSelectFromRaw(c);
|
|
21
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
22
|
+
return Components.mentionableSelectFromRaw(c);
|
|
23
|
+
case constants_js_1.ComponentTypes.ChannelSelect:
|
|
24
|
+
return Components.channelSelectFromRaw(c);
|
|
24
25
|
}
|
|
25
26
|
}),
|
|
26
27
|
id: actionRow.id,
|
|
@@ -31,19 +32,20 @@ class Components {
|
|
|
31
32
|
type: actionRow.type,
|
|
32
33
|
components: actionRow.components.map((c) => {
|
|
33
34
|
switch (c.type) {
|
|
34
|
-
case constants_js_1.ComponentTypes.Button:
|
|
35
|
+
case constants_js_1.ComponentTypes.Button:
|
|
35
36
|
return Components.buttonToRaw(c);
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
38
|
+
return Components.stringSelectToRaw(c);
|
|
39
|
+
case constants_js_1.ComponentTypes.TextInput:
|
|
38
40
|
return Components.textInputToRaw(c);
|
|
39
|
-
}
|
|
40
|
-
case constants_js_1.ComponentTypes.ChannelSelect:
|
|
41
|
-
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
42
|
-
case constants_js_1.ComponentTypes.RoleSelect:
|
|
43
41
|
case constants_js_1.ComponentTypes.UserSelect:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
return Components.userSelectToRaw(c);
|
|
43
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
|
44
|
+
return Components.roleSelectToRaw(c);
|
|
45
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
46
|
+
return Components.mentionableSelectToRaw(c);
|
|
47
|
+
case constants_js_1.ComponentTypes.ChannelSelect:
|
|
48
|
+
return Components.channelSelectToRaw(c);
|
|
47
49
|
}
|
|
48
50
|
}),
|
|
49
51
|
id: actionRow.id,
|
|
@@ -75,6 +77,32 @@ class Components {
|
|
|
75
77
|
id: button.id,
|
|
76
78
|
};
|
|
77
79
|
}
|
|
80
|
+
static channelSelectFromRaw(channelSelect) {
|
|
81
|
+
return {
|
|
82
|
+
type: channelSelect.type,
|
|
83
|
+
id: channelSelect.id,
|
|
84
|
+
customID: channelSelect.custom_id,
|
|
85
|
+
channelTypes: channelSelect.channel_types,
|
|
86
|
+
placeholder: channelSelect.placeholder,
|
|
87
|
+
defaultValues: channelSelect.default_values,
|
|
88
|
+
minValues: channelSelect.min_values,
|
|
89
|
+
maxValues: channelSelect.max_values,
|
|
90
|
+
disabled: channelSelect.disabled,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
static channelSelectToRaw(channelSelect) {
|
|
94
|
+
return {
|
|
95
|
+
type: channelSelect.type,
|
|
96
|
+
id: channelSelect.id,
|
|
97
|
+
custom_id: channelSelect.customID,
|
|
98
|
+
channel_types: channelSelect.channelTypes,
|
|
99
|
+
placeholder: channelSelect.placeholder,
|
|
100
|
+
default_values: channelSelect.defaultValues,
|
|
101
|
+
min_values: channelSelect.minValues,
|
|
102
|
+
max_values: channelSelect.maxValues,
|
|
103
|
+
disabled: channelSelect.disabled,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
78
106
|
static containerFromRaw(container) {
|
|
79
107
|
return {
|
|
80
108
|
type: container.type,
|
|
@@ -155,6 +183,42 @@ class Components {
|
|
|
155
183
|
size: file.size,
|
|
156
184
|
};
|
|
157
185
|
}
|
|
186
|
+
static labelFromRaw(label) {
|
|
187
|
+
let component;
|
|
188
|
+
switch (label.component.type) {
|
|
189
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
190
|
+
component = Components.stringSelectFromRaw(label.component);
|
|
191
|
+
break;
|
|
192
|
+
case constants_js_1.ComponentTypes.TextInput:
|
|
193
|
+
component = Components.textInputFromRaw(label.component);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
type: label.type,
|
|
198
|
+
id: label.id,
|
|
199
|
+
label: label.label,
|
|
200
|
+
description: label.description,
|
|
201
|
+
component,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
static labelToRaw(label) {
|
|
205
|
+
let component;
|
|
206
|
+
switch (label.component.type) {
|
|
207
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
208
|
+
component = Components.stringSelectToRaw(label.component);
|
|
209
|
+
break;
|
|
210
|
+
case constants_js_1.ComponentTypes.TextInput:
|
|
211
|
+
component = Components.textInputToRaw(label.component);
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
type: label.type,
|
|
216
|
+
id: label.id,
|
|
217
|
+
label: label.label,
|
|
218
|
+
description: label.description,
|
|
219
|
+
component,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
158
222
|
static mediaGalleryFromRaw(mediaGallery) {
|
|
159
223
|
return {
|
|
160
224
|
type: mediaGallery.type,
|
|
@@ -177,6 +241,54 @@ class Components {
|
|
|
177
241
|
})),
|
|
178
242
|
};
|
|
179
243
|
}
|
|
244
|
+
static mentionableSelectFromRaw(mentionableSelect) {
|
|
245
|
+
return {
|
|
246
|
+
type: mentionableSelect.type,
|
|
247
|
+
id: mentionableSelect.id,
|
|
248
|
+
customID: mentionableSelect.custom_id,
|
|
249
|
+
placeholder: mentionableSelect.placeholder,
|
|
250
|
+
defaultValues: mentionableSelect.default_values,
|
|
251
|
+
minValues: mentionableSelect.min_values,
|
|
252
|
+
maxValues: mentionableSelect.max_values,
|
|
253
|
+
disabled: mentionableSelect.disabled,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
static mentionableSelectToRaw(mentionableSelect) {
|
|
257
|
+
return {
|
|
258
|
+
type: mentionableSelect.type,
|
|
259
|
+
id: mentionableSelect.id,
|
|
260
|
+
custom_id: mentionableSelect.customID,
|
|
261
|
+
placeholder: mentionableSelect.placeholder,
|
|
262
|
+
default_values: mentionableSelect.defaultValues,
|
|
263
|
+
min_values: mentionableSelect.minValues,
|
|
264
|
+
max_values: mentionableSelect.maxValues,
|
|
265
|
+
disabled: mentionableSelect.disabled,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
static roleSelectFromRaw(roleSelect) {
|
|
269
|
+
return {
|
|
270
|
+
type: roleSelect.type,
|
|
271
|
+
id: roleSelect.id,
|
|
272
|
+
customID: roleSelect.custom_id,
|
|
273
|
+
placeholder: roleSelect.placeholder,
|
|
274
|
+
defaultValues: roleSelect.default_values,
|
|
275
|
+
minValues: roleSelect.min_values,
|
|
276
|
+
maxValues: roleSelect.max_values,
|
|
277
|
+
disabled: roleSelect.disabled,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
static roleSelectToRaw(roleSelect) {
|
|
281
|
+
return {
|
|
282
|
+
type: roleSelect.type,
|
|
283
|
+
id: roleSelect.id,
|
|
284
|
+
custom_id: roleSelect.customID,
|
|
285
|
+
placeholder: roleSelect.placeholder,
|
|
286
|
+
default_values: roleSelect.defaultValues,
|
|
287
|
+
min_values: roleSelect.minValues,
|
|
288
|
+
max_values: roleSelect.maxValues,
|
|
289
|
+
disabled: roleSelect.disabled,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
180
292
|
static sectionFromRaw(section) {
|
|
181
293
|
return {
|
|
182
294
|
type: section.type,
|
|
@@ -197,109 +309,52 @@ class Components {
|
|
|
197
309
|
: Components.thumbnailToRaw(section.accessory),
|
|
198
310
|
};
|
|
199
311
|
}
|
|
200
|
-
static
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
emoji: option.emoji !== undefined
|
|
224
|
-
? {
|
|
225
|
-
name: option.emoji.name,
|
|
226
|
-
id: option.emoji.id,
|
|
227
|
-
animated: option.emoji.animated,
|
|
228
|
-
}
|
|
229
|
-
: undefined,
|
|
230
|
-
default: option.default,
|
|
231
|
-
})),
|
|
232
|
-
minValues: selectMenu.min_values,
|
|
233
|
-
maxValues: selectMenu.max_values,
|
|
234
|
-
disabled: selectMenu.disabled,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
238
|
-
case constants_js_1.ComponentTypes.RoleSelect:
|
|
239
|
-
case constants_js_1.ComponentTypes.UserSelect: {
|
|
240
|
-
return {
|
|
241
|
-
type: selectMenu.type,
|
|
242
|
-
customID: selectMenu.custom_id,
|
|
243
|
-
placeholder: selectMenu.placeholder,
|
|
244
|
-
defaultValues: selectMenu.default_values,
|
|
245
|
-
minValues: selectMenu.min_values,
|
|
246
|
-
maxValues: selectMenu.max_values,
|
|
247
|
-
disabled: selectMenu.disabled,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
}
|
|
312
|
+
static stringSelectFromRaw(stringSelect) {
|
|
313
|
+
return {
|
|
314
|
+
type: stringSelect.type,
|
|
315
|
+
id: stringSelect.id,
|
|
316
|
+
customID: stringSelect.custom_id,
|
|
317
|
+
placeholder: stringSelect.placeholder,
|
|
318
|
+
options: stringSelect.options?.map((option) => ({
|
|
319
|
+
label: option.label,
|
|
320
|
+
value: option.value,
|
|
321
|
+
description: option.description,
|
|
322
|
+
emoji: option.emoji !== undefined
|
|
323
|
+
? {
|
|
324
|
+
name: option.emoji.name,
|
|
325
|
+
id: option.emoji.id,
|
|
326
|
+
animated: option.emoji.animated,
|
|
327
|
+
}
|
|
328
|
+
: undefined,
|
|
329
|
+
default: option.default,
|
|
330
|
+
})),
|
|
331
|
+
minValues: stringSelect.min_values,
|
|
332
|
+
maxValues: stringSelect.max_values,
|
|
333
|
+
disabled: stringSelect.disabled,
|
|
334
|
+
};
|
|
251
335
|
}
|
|
252
|
-
static
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
description: option.description,
|
|
275
|
-
emoji: option.emoji !== undefined
|
|
276
|
-
? {
|
|
277
|
-
name: option.emoji.name,
|
|
278
|
-
id: option.emoji.id,
|
|
279
|
-
animated: option.emoji.animated,
|
|
280
|
-
}
|
|
281
|
-
: undefined,
|
|
282
|
-
default: option.default,
|
|
283
|
-
})),
|
|
284
|
-
min_values: selectMenu.minValues,
|
|
285
|
-
max_values: selectMenu.maxValues,
|
|
286
|
-
disabled: selectMenu.disabled,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
290
|
-
case constants_js_1.ComponentTypes.RoleSelect:
|
|
291
|
-
case constants_js_1.ComponentTypes.UserSelect: {
|
|
292
|
-
return {
|
|
293
|
-
type: selectMenu.type,
|
|
294
|
-
custom_id: selectMenu.customID,
|
|
295
|
-
placeholder: selectMenu.placeholder,
|
|
296
|
-
default_values: selectMenu.defaultValues,
|
|
297
|
-
min_values: selectMenu.minValues,
|
|
298
|
-
max_values: selectMenu.maxValues,
|
|
299
|
-
disabled: selectMenu.disabled,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
}
|
|
336
|
+
static stringSelectToRaw(stringSelect) {
|
|
337
|
+
return {
|
|
338
|
+
type: stringSelect.type,
|
|
339
|
+
custom_id: stringSelect.customID,
|
|
340
|
+
placeholder: stringSelect.placeholder,
|
|
341
|
+
options: stringSelect.options?.map((option) => ({
|
|
342
|
+
label: option.label,
|
|
343
|
+
value: option.value,
|
|
344
|
+
description: option.description,
|
|
345
|
+
emoji: option.emoji !== undefined
|
|
346
|
+
? {
|
|
347
|
+
name: option.emoji.name,
|
|
348
|
+
id: option.emoji.id,
|
|
349
|
+
animated: option.emoji.animated,
|
|
350
|
+
}
|
|
351
|
+
: undefined,
|
|
352
|
+
default: option.default,
|
|
353
|
+
})),
|
|
354
|
+
min_values: stringSelect.minValues,
|
|
355
|
+
max_values: stringSelect.maxValues,
|
|
356
|
+
disabled: stringSelect.disabled,
|
|
357
|
+
};
|
|
303
358
|
}
|
|
304
359
|
static separatorFromRaw(separator) {
|
|
305
360
|
return {
|
|
@@ -336,7 +391,6 @@ class Components {
|
|
|
336
391
|
type: textInput.type,
|
|
337
392
|
customID: textInput.custom_id,
|
|
338
393
|
style: textInput.style,
|
|
339
|
-
label: textInput.label,
|
|
340
394
|
minLength: textInput.min_length,
|
|
341
395
|
maxLength: textInput.max_length,
|
|
342
396
|
required: textInput.required,
|
|
@@ -350,7 +404,6 @@ class Components {
|
|
|
350
404
|
type: textInput.type,
|
|
351
405
|
custom_id: textInput.customID,
|
|
352
406
|
style: textInput.style,
|
|
353
|
-
label: textInput.label,
|
|
354
407
|
min_length: textInput.minLength,
|
|
355
408
|
max_length: textInput.maxLength,
|
|
356
409
|
required: textInput.required,
|
|
@@ -395,5 +448,29 @@ class Components {
|
|
|
395
448
|
content_type: unfurledMediaItem.contentType,
|
|
396
449
|
};
|
|
397
450
|
}
|
|
451
|
+
static userSelectFromRaw(userSelect) {
|
|
452
|
+
return {
|
|
453
|
+
type: userSelect.type,
|
|
454
|
+
id: userSelect.id,
|
|
455
|
+
customID: userSelect.custom_id,
|
|
456
|
+
placeholder: userSelect.placeholder,
|
|
457
|
+
defaultValues: userSelect.default_values,
|
|
458
|
+
minValues: userSelect.min_values,
|
|
459
|
+
maxValues: userSelect.max_values,
|
|
460
|
+
disabled: userSelect.disabled,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
static userSelectToRaw(userSelect) {
|
|
464
|
+
return {
|
|
465
|
+
type: userSelect.type,
|
|
466
|
+
id: userSelect.id,
|
|
467
|
+
custom_id: userSelect.customID,
|
|
468
|
+
placeholder: userSelect.placeholder,
|
|
469
|
+
default_values: userSelect.defaultValues,
|
|
470
|
+
min_values: userSelect.minValues,
|
|
471
|
+
max_values: userSelect.maxValues,
|
|
472
|
+
disabled: userSelect.disabled,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
398
475
|
}
|
|
399
476
|
exports.Components = Components;
|
|
@@ -7,6 +7,8 @@ const Users_1 = require("./Users");
|
|
|
7
7
|
const Entitlements_1 = require("./Entitlements");
|
|
8
8
|
const Roles_1 = require("./Roles");
|
|
9
9
|
const Messages_1 = require("./Messages");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const Components_1 = require("./Components");
|
|
10
12
|
class Interactions {
|
|
11
13
|
static interactionCallbackResponseFromRaw(interactionCallbackResponse) {
|
|
12
14
|
return {
|
|
@@ -57,32 +59,28 @@ class Interactions {
|
|
|
57
59
|
type: interaction.type,
|
|
58
60
|
data: interaction.data !== undefined
|
|
59
61
|
? {
|
|
60
|
-
id: interaction.data
|
|
61
|
-
name: interaction.data
|
|
62
|
-
type: interaction.data
|
|
63
|
-
resolved: interaction.data
|
|
62
|
+
id: interaction.data?.id,
|
|
63
|
+
name: interaction.data?.name,
|
|
64
|
+
type: interaction.data?.type,
|
|
65
|
+
resolved: interaction.data?.resolved !== undefined
|
|
64
66
|
? Interactions.resolvedDataFromRaw(interaction.data.resolved)
|
|
65
67
|
: undefined,
|
|
66
|
-
options: interaction.data
|
|
67
|
-
guildID: interaction.data
|
|
68
|
-
targetID: interaction.data
|
|
69
|
-
customID: interaction.data
|
|
70
|
-
componentType: interaction.data
|
|
71
|
-
values: interaction.data
|
|
72
|
-
components: interaction.data
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value: c.value,
|
|
83
|
-
placeholder: c.placeholder,
|
|
84
|
-
})),
|
|
85
|
-
})),
|
|
68
|
+
options: interaction.data?.options,
|
|
69
|
+
guildID: interaction.data?.guild_id,
|
|
70
|
+
targetID: interaction.data?.target_id,
|
|
71
|
+
customID: interaction.data?.custom_id,
|
|
72
|
+
componentType: interaction.data?.component_type,
|
|
73
|
+
values: interaction.data?.values,
|
|
74
|
+
components: interaction.data?.components?.map((component) => {
|
|
75
|
+
switch (component.type) {
|
|
76
|
+
case constants_1.ComponentTypes.ActionRow:
|
|
77
|
+
return Components_1.Components.actionRowFromRaw(component);
|
|
78
|
+
case constants_1.ComponentTypes.TextDisplay:
|
|
79
|
+
return Components_1.Components.textDisplayFromRaw(component);
|
|
80
|
+
case constants_1.ComponentTypes.Label:
|
|
81
|
+
return Components_1.Components.labelFromRaw(component);
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
86
84
|
}
|
|
87
85
|
: undefined,
|
|
88
86
|
guild: interaction.guild !== undefined
|
|
@@ -170,20 +168,16 @@ class Interactions {
|
|
|
170
168
|
custom_id: interaction.data.customID,
|
|
171
169
|
component_type: interaction.data.componentType,
|
|
172
170
|
values: interaction.data.values,
|
|
173
|
-
components: interaction.data
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
value: c.value,
|
|
184
|
-
placeholder: c.placeholder,
|
|
185
|
-
})),
|
|
186
|
-
})),
|
|
171
|
+
components: interaction.data?.components?.map((component) => {
|
|
172
|
+
switch (component.type) {
|
|
173
|
+
case constants_1.ComponentTypes.ActionRow:
|
|
174
|
+
return Components_1.Components.actionRowToRaw(component);
|
|
175
|
+
case constants_1.ComponentTypes.TextDisplay:
|
|
176
|
+
return Components_1.Components.textDisplayToRaw(component);
|
|
177
|
+
case constants_1.ComponentTypes.Label:
|
|
178
|
+
return Components_1.Components.labelToRaw(component);
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
187
181
|
}
|
|
188
182
|
: undefined,
|
|
189
183
|
guild: interaction.guild !== undefined
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message
|
|
1
|
+
import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message } from "../types/message";
|
|
2
|
+
import type { ActionRow, Button, ChannelSelect, Container, File, MediaGallery, MentionableSelect, RawActionRow, RawButton, RawChannelSelect, RawContainer, RawFile, RawMediaGallery, RawMentionableSelect, RawRoleSelect, RawSection, RawSeparator, RawStringSelect, RawTextDisplay, RawThumbnail, RawUserSelect, RoleSelect, Section, Separator, StringSelect, TextDisplay, Thumbnail, UserSelect } from "../types/message-components";
|
|
2
3
|
export declare class Messages {
|
|
3
4
|
static attachmentFromRaw(attachment: RawAttachment): Attachment;
|
|
4
5
|
static attachmentToRaw(attachment: Attachment): RawAttachment;
|
|
5
|
-
static componentsFromRaw(components: Array<
|
|
6
|
-
static componentsToRaw(components: Array<
|
|
6
|
+
static componentsFromRaw(components: Array<RawActionRow | RawButton | RawStringSelect | RawUserSelect | RawRoleSelect | RawMentionableSelect | RawChannelSelect | RawSection | RawTextDisplay | RawThumbnail | RawMediaGallery | RawFile | RawSeparator | RawContainer>): Array<ActionRow | Button | StringSelect | UserSelect | RoleSelect | MentionableSelect | ChannelSelect | Section | TextDisplay | Thumbnail | MediaGallery | File | Separator | Container>;
|
|
7
|
+
static componentsToRaw(components: Array<ActionRow | Button | StringSelect | UserSelect | RoleSelect | MentionableSelect | ChannelSelect | Section | TextDisplay | Thumbnail | MediaGallery | File | Separator | Container>): Array<RawActionRow | RawButton | RawStringSelect | RawUserSelect | RawRoleSelect | RawMentionableSelect | RawChannelSelect | RawSection | RawTextDisplay | RawThumbnail | RawMediaGallery | RawFile | RawSeparator | RawContainer>;
|
|
7
8
|
static embedFromRaw(embed: RawEmbed): Embed;
|
|
8
9
|
static embedToRaw(embed: Embed): RawEmbed;
|
|
9
10
|
static messageFromRaw(message: RawMessage): Message;
|
|
@@ -51,54 +51,68 @@ class Messages {
|
|
|
51
51
|
static componentsFromRaw(components) {
|
|
52
52
|
return components.map((component) => {
|
|
53
53
|
switch (component.type) {
|
|
54
|
-
case constants_1.ComponentTypes.ActionRow:
|
|
54
|
+
case constants_1.ComponentTypes.ActionRow:
|
|
55
55
|
return Components_js_1.Components.actionRowFromRaw(component);
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
case constants_1.ComponentTypes.Button:
|
|
57
|
+
return Components_js_1.Components.buttonFromRaw(component);
|
|
58
|
+
case constants_1.ComponentTypes.StringSelect:
|
|
59
|
+
return Components_js_1.Components.stringSelectFromRaw(component);
|
|
60
|
+
case constants_1.ComponentTypes.UserSelect:
|
|
61
|
+
return Components_js_1.Components.userSelectFromRaw(component);
|
|
62
|
+
case constants_1.ComponentTypes.RoleSelect:
|
|
63
|
+
return Components_js_1.Components.roleSelectFromRaw(component);
|
|
64
|
+
case constants_1.ComponentTypes.MentionableSelect:
|
|
65
|
+
return Components_js_1.Components.mentionableSelectFromRaw(component);
|
|
66
|
+
case constants_1.ComponentTypes.ChannelSelect:
|
|
67
|
+
return Components_js_1.Components.channelSelectFromRaw(component);
|
|
68
|
+
case constants_1.ComponentTypes.Section:
|
|
69
|
+
return Components_js_1.Components.sectionFromRaw(component);
|
|
70
|
+
case constants_1.ComponentTypes.TextDisplay:
|
|
58
71
|
return Components_js_1.Components.textDisplayFromRaw(component);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
case constants_1.ComponentTypes.File:
|
|
72
|
+
case constants_1.ComponentTypes.Thumbnail:
|
|
73
|
+
return Components_js_1.Components.thumbnailFromRaw(component);
|
|
74
|
+
case constants_1.ComponentTypes.MediaGallery:
|
|
75
|
+
return Components_js_1.Components.mediaGalleryFromRaw(component);
|
|
76
|
+
case constants_1.ComponentTypes.File:
|
|
64
77
|
return Components_js_1.Components.fileFromRaw(component);
|
|
65
|
-
|
|
66
|
-
case constants_1.ComponentTypes.Section: {
|
|
67
|
-
return Components_js_1.Components.sectionFromRaw(component);
|
|
68
|
-
}
|
|
69
|
-
case constants_1.ComponentTypes.Separator: {
|
|
78
|
+
case constants_1.ComponentTypes.Separator:
|
|
70
79
|
return Components_js_1.Components.separatorFromRaw(component);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return Components_js_1.Components.mediaGalleryFromRaw(component);
|
|
74
|
-
}
|
|
80
|
+
case constants_1.ComponentTypes.Container:
|
|
81
|
+
return Components_js_1.Components.containerFromRaw(component);
|
|
75
82
|
}
|
|
76
83
|
});
|
|
77
84
|
}
|
|
78
85
|
static componentsToRaw(components) {
|
|
79
86
|
return components.map((component) => {
|
|
80
87
|
switch (component.type) {
|
|
81
|
-
case constants_1.ComponentTypes.ActionRow:
|
|
88
|
+
case constants_1.ComponentTypes.ActionRow:
|
|
82
89
|
return Components_js_1.Components.actionRowToRaw(component);
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
case constants_1.ComponentTypes.Button:
|
|
91
|
+
return Components_js_1.Components.buttonToRaw(component);
|
|
92
|
+
case constants_1.ComponentTypes.StringSelect:
|
|
93
|
+
return Components_js_1.Components.stringSelectToRaw(component);
|
|
94
|
+
case constants_1.ComponentTypes.UserSelect:
|
|
95
|
+
return Components_js_1.Components.userSelectToRaw(component);
|
|
96
|
+
case constants_1.ComponentTypes.RoleSelect:
|
|
97
|
+
return Components_js_1.Components.roleSelectToRaw(component);
|
|
98
|
+
case constants_1.ComponentTypes.MentionableSelect:
|
|
99
|
+
return Components_js_1.Components.mentionableSelectToRaw(component);
|
|
100
|
+
case constants_1.ComponentTypes.ChannelSelect:
|
|
101
|
+
return Components_js_1.Components.channelSelectToRaw(component);
|
|
102
|
+
case constants_1.ComponentTypes.Section:
|
|
103
|
+
return Components_js_1.Components.sectionToRaw(component);
|
|
104
|
+
case constants_1.ComponentTypes.TextDisplay:
|
|
85
105
|
return Components_js_1.Components.textDisplayToRaw(component);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
case constants_1.ComponentTypes.File:
|
|
106
|
+
case constants_1.ComponentTypes.Thumbnail:
|
|
107
|
+
return Components_js_1.Components.thumbnailToRaw(component);
|
|
108
|
+
case constants_1.ComponentTypes.MediaGallery:
|
|
109
|
+
return Components_js_1.Components.mediaGalleryToRaw(component);
|
|
110
|
+
case constants_1.ComponentTypes.File:
|
|
91
111
|
return Components_js_1.Components.fileToRaw(component);
|
|
92
|
-
|
|
93
|
-
case constants_1.ComponentTypes.Section: {
|
|
94
|
-
return Components_js_1.Components.sectionToRaw(component);
|
|
95
|
-
}
|
|
96
|
-
case constants_1.ComponentTypes.Separator: {
|
|
112
|
+
case constants_1.ComponentTypes.Separator:
|
|
97
113
|
return Components_js_1.Components.separatorToRaw(component);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return Components_js_1.Components.mediaGalleryToRaw(component);
|
|
101
|
-
}
|
|
114
|
+
case constants_1.ComponentTypes.Container:
|
|
115
|
+
return Components_js_1.Components.containerToRaw(component);
|
|
102
116
|
}
|
|
103
117
|
});
|
|
104
118
|
}
|
|
@@ -375,6 +375,17 @@ export interface RawMessagePollVoteRemoveFields {
|
|
|
375
375
|
guild_id?: snowflake;
|
|
376
376
|
answer_id: number;
|
|
377
377
|
}
|
|
378
|
+
/** https://discord.com/developers/docs/events/gateway-events#rate-limited-rate-limited-fields */
|
|
379
|
+
export interface RawRateLimitedFields {
|
|
380
|
+
opcode: GatewayOPCodes;
|
|
381
|
+
retry_after: number;
|
|
382
|
+
meta: RawRequestGuildMembersRateLimitMetadata;
|
|
383
|
+
}
|
|
384
|
+
/** https://discord.com/developers/docs/events/gateway-events#rate-limited-rate-limit-metadata-for-opcode-structure */
|
|
385
|
+
export interface RawRequestGuildMembersRateLimitMetadata {
|
|
386
|
+
guild_id: snowflake;
|
|
387
|
+
nonce?: string;
|
|
388
|
+
}
|
|
378
389
|
export interface Payload {
|
|
379
390
|
op: GatewayOPCodes;
|
|
380
391
|
d: any | null;
|
|
@@ -691,3 +702,12 @@ export interface MessagePollVoteRemoveFields {
|
|
|
691
702
|
guildID?: snowflake;
|
|
692
703
|
answerID: number;
|
|
693
704
|
}
|
|
705
|
+
export interface RateLimitedFields {
|
|
706
|
+
opcode: GatewayOPCodes;
|
|
707
|
+
retryAfter: number;
|
|
708
|
+
meta: RequestGuildMembersRateLimitMetadata;
|
|
709
|
+
}
|
|
710
|
+
export interface RequestGuildMembersRateLimitMetadata {
|
|
711
|
+
guildID: snowflake;
|
|
712
|
+
nonce?: string;
|
|
713
|
+
}
|