disgroove 2.2.6-dev.fd02f21 → 2.2.7-dev.045389f
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 +14 -52
- package/dist/lib/Client.js +42 -59
- package/dist/lib/constants.d.ts +28 -22
- package/dist/lib/constants.js +29 -23
- package/dist/lib/gateway/Shard.js +14 -0
- package/dist/lib/rest/RequestManager.d.ts +1 -3
- package/dist/lib/transformers/Components.d.ts +13 -3
- package/dist/lib/transformers/Components.js +199 -126
- 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/invite.d.ts +2 -2
- package/dist/lib/types/message-components.d.ts +219 -122
- package/dist/lib/types/message.d.ts +3 -5
- package/dist/package.json +6 -6
- package/package.json +6 -6
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { ActionRow, Button, Container, RawActionRow, RawButton, RawContainer, RawFile, File, RawUnfurledMediaItem, UnfurledMediaItem, RawTextDisplay, TextDisplay, RawSeparator, Separator, RawSection, Section, Thumbnail, RawThumbnail, TextInput, RawTextInput,
|
|
1
|
+
import { ActionRow, Button, Container, RawActionRow, RawButton, RawContainer, RawFile, File, RawUnfurledMediaItem, UnfurledMediaItem, RawTextDisplay, TextDisplay, RawSeparator, Separator, RawSection, Section, Thumbnail, RawThumbnail, TextInput, RawTextInput, MediaGallery, RawMediaGallery, RawStringSelect, StringSelect, RawUserSelect, UserSelect, RawRoleSelect, RoleSelect, RawMentionableSelect, MentionableSelect, RawChannelSelect, ChannelSelect, RawLabel, Label } from "../types/message-components.js";
|
|
2
2
|
export declare class Components {
|
|
3
3
|
static actionRowFromRaw(actionRow: RawActionRow): ActionRow;
|
|
4
4
|
static actionRowToRaw(actionRow: ActionRow): RawActionRow;
|
|
5
5
|
static buttonFromRaw(button: RawButton): Button;
|
|
6
6
|
static buttonToRaw(button: Button): RawButton;
|
|
7
|
+
static channelSelectFromRaw(channelSelect: RawChannelSelect): ChannelSelect;
|
|
8
|
+
static channelSelectToRaw(channelSelect: ChannelSelect): RawChannelSelect;
|
|
7
9
|
static containerFromRaw(container: RawContainer): Container;
|
|
8
10
|
static containerToRaw(container: Container): RawContainer;
|
|
9
11
|
static fileFromRaw(file: RawFile): File;
|
|
10
12
|
static fileToRaw(file: File): RawFile;
|
|
13
|
+
static labelFromRaw(label: RawLabel): Label;
|
|
14
|
+
static labelToRaw(label: Label): RawLabel;
|
|
11
15
|
static mediaGalleryFromRaw(mediaGallery: RawMediaGallery): MediaGallery;
|
|
12
16
|
static mediaGalleryToRaw(mediaGallery: MediaGallery): RawMediaGallery;
|
|
17
|
+
static mentionableSelectFromRaw(mentionableSelect: RawMentionableSelect): MentionableSelect;
|
|
18
|
+
static mentionableSelectToRaw(mentionableSelect: MentionableSelect): RawMentionableSelect;
|
|
19
|
+
static roleSelectFromRaw(roleSelect: RawRoleSelect): RoleSelect;
|
|
20
|
+
static roleSelectToRaw(roleSelect: RoleSelect): RawRoleSelect;
|
|
13
21
|
static sectionFromRaw(section: RawSection): Section;
|
|
14
22
|
static sectionToRaw(section: Section): RawSection;
|
|
15
|
-
static
|
|
16
|
-
static
|
|
23
|
+
static stringSelectFromRaw(stringSelect: RawStringSelect): StringSelect;
|
|
24
|
+
static stringSelectToRaw(stringSelect: StringSelect): RawStringSelect;
|
|
17
25
|
static separatorFromRaw(separator: RawSeparator): Separator;
|
|
18
26
|
static separatorToRaw(separator: Separator): RawSeparator;
|
|
19
27
|
static textDisplayFromRaw(textDisplay: RawTextDisplay): TextDisplay;
|
|
@@ -24,4 +32,6 @@ export declare class Components {
|
|
|
24
32
|
static thumbnailToRaw(thumbnail: Thumbnail): RawThumbnail;
|
|
25
33
|
static unfurledMediaItemFromRaw(unfurledMediaItem: RawUnfurledMediaItem): UnfurledMediaItem;
|
|
26
34
|
static unfurledMediaItemToRaw(unfurledMediaItem: UnfurledMediaItem): RawUnfurledMediaItem;
|
|
35
|
+
static userSelectFromRaw(userSelect: RawUserSelect): UserSelect;
|
|
36
|
+
static userSelectToRaw(userSelect: UserSelect): RawUserSelect;
|
|
27
37
|
}
|
|
@@ -8,19 +8,18 @@ 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
|
-
|
|
15
|
-
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:
|
|
13
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
14
|
+
return Components.stringSelectFromRaw(c);
|
|
20
15
|
case constants_js_1.ComponentTypes.UserSelect:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
return Components.userSelectFromRaw(c);
|
|
17
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
|
18
|
+
return Components.roleSelectFromRaw(c);
|
|
19
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
20
|
+
return Components.mentionableSelectFromRaw(c);
|
|
21
|
+
case constants_js_1.ComponentTypes.ChannelSelect:
|
|
22
|
+
return Components.channelSelectFromRaw(c);
|
|
24
23
|
}
|
|
25
24
|
}),
|
|
26
25
|
id: actionRow.id,
|
|
@@ -31,19 +30,18 @@ class Components {
|
|
|
31
30
|
type: actionRow.type,
|
|
32
31
|
components: actionRow.components.map((c) => {
|
|
33
32
|
switch (c.type) {
|
|
34
|
-
case constants_js_1.ComponentTypes.Button:
|
|
33
|
+
case constants_js_1.ComponentTypes.Button:
|
|
35
34
|
return Components.buttonToRaw(c);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
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:
|
|
35
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
36
|
+
return Components.stringSelectToRaw(c);
|
|
43
37
|
case constants_js_1.ComponentTypes.UserSelect:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
return Components.userSelectToRaw(c);
|
|
39
|
+
case constants_js_1.ComponentTypes.RoleSelect:
|
|
40
|
+
return Components.roleSelectToRaw(c);
|
|
41
|
+
case constants_js_1.ComponentTypes.MentionableSelect:
|
|
42
|
+
return Components.mentionableSelectToRaw(c);
|
|
43
|
+
case constants_js_1.ComponentTypes.ChannelSelect:
|
|
44
|
+
return Components.channelSelectToRaw(c);
|
|
47
45
|
}
|
|
48
46
|
}),
|
|
49
47
|
id: actionRow.id,
|
|
@@ -75,6 +73,32 @@ class Components {
|
|
|
75
73
|
id: button.id,
|
|
76
74
|
};
|
|
77
75
|
}
|
|
76
|
+
static channelSelectFromRaw(channelSelect) {
|
|
77
|
+
return {
|
|
78
|
+
type: channelSelect.type,
|
|
79
|
+
id: channelSelect.id,
|
|
80
|
+
customID: channelSelect.custom_id,
|
|
81
|
+
channelTypes: channelSelect.channel_types,
|
|
82
|
+
placeholder: channelSelect.placeholder,
|
|
83
|
+
defaultValues: channelSelect.default_values,
|
|
84
|
+
minValues: channelSelect.min_values,
|
|
85
|
+
maxValues: channelSelect.max_values,
|
|
86
|
+
disabled: channelSelect.disabled,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
static channelSelectToRaw(channelSelect) {
|
|
90
|
+
return {
|
|
91
|
+
type: channelSelect.type,
|
|
92
|
+
id: channelSelect.id,
|
|
93
|
+
custom_id: channelSelect.customID,
|
|
94
|
+
channel_types: channelSelect.channelTypes,
|
|
95
|
+
placeholder: channelSelect.placeholder,
|
|
96
|
+
default_values: channelSelect.defaultValues,
|
|
97
|
+
min_values: channelSelect.minValues,
|
|
98
|
+
max_values: channelSelect.maxValues,
|
|
99
|
+
disabled: channelSelect.disabled,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
78
102
|
static containerFromRaw(container) {
|
|
79
103
|
return {
|
|
80
104
|
type: container.type,
|
|
@@ -155,6 +179,42 @@ class Components {
|
|
|
155
179
|
size: file.size,
|
|
156
180
|
};
|
|
157
181
|
}
|
|
182
|
+
static labelFromRaw(label) {
|
|
183
|
+
let component;
|
|
184
|
+
switch (label.component.type) {
|
|
185
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
186
|
+
component = Components.stringSelectFromRaw(label.component);
|
|
187
|
+
break;
|
|
188
|
+
case constants_js_1.ComponentTypes.TextInput:
|
|
189
|
+
component = Components.textInputFromRaw(label.component);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
type: label.type,
|
|
194
|
+
id: label.id,
|
|
195
|
+
label: label.label,
|
|
196
|
+
description: label.description,
|
|
197
|
+
component,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
static labelToRaw(label) {
|
|
201
|
+
let component;
|
|
202
|
+
switch (label.component.type) {
|
|
203
|
+
case constants_js_1.ComponentTypes.StringSelect:
|
|
204
|
+
component = Components.stringSelectToRaw(label.component);
|
|
205
|
+
break;
|
|
206
|
+
case constants_js_1.ComponentTypes.TextInput:
|
|
207
|
+
component = Components.textInputToRaw(label.component);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
type: label.type,
|
|
212
|
+
id: label.id,
|
|
213
|
+
label: label.label,
|
|
214
|
+
description: label.description,
|
|
215
|
+
component,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
158
218
|
static mediaGalleryFromRaw(mediaGallery) {
|
|
159
219
|
return {
|
|
160
220
|
type: mediaGallery.type,
|
|
@@ -177,6 +237,54 @@ class Components {
|
|
|
177
237
|
})),
|
|
178
238
|
};
|
|
179
239
|
}
|
|
240
|
+
static mentionableSelectFromRaw(mentionableSelect) {
|
|
241
|
+
return {
|
|
242
|
+
type: mentionableSelect.type,
|
|
243
|
+
id: mentionableSelect.id,
|
|
244
|
+
customID: mentionableSelect.custom_id,
|
|
245
|
+
placeholder: mentionableSelect.placeholder,
|
|
246
|
+
defaultValues: mentionableSelect.default_values,
|
|
247
|
+
minValues: mentionableSelect.min_values,
|
|
248
|
+
maxValues: mentionableSelect.max_values,
|
|
249
|
+
disabled: mentionableSelect.disabled,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
static mentionableSelectToRaw(mentionableSelect) {
|
|
253
|
+
return {
|
|
254
|
+
type: mentionableSelect.type,
|
|
255
|
+
id: mentionableSelect.id,
|
|
256
|
+
custom_id: mentionableSelect.customID,
|
|
257
|
+
placeholder: mentionableSelect.placeholder,
|
|
258
|
+
default_values: mentionableSelect.defaultValues,
|
|
259
|
+
min_values: mentionableSelect.minValues,
|
|
260
|
+
max_values: mentionableSelect.maxValues,
|
|
261
|
+
disabled: mentionableSelect.disabled,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
static roleSelectFromRaw(roleSelect) {
|
|
265
|
+
return {
|
|
266
|
+
type: roleSelect.type,
|
|
267
|
+
id: roleSelect.id,
|
|
268
|
+
customID: roleSelect.custom_id,
|
|
269
|
+
placeholder: roleSelect.placeholder,
|
|
270
|
+
defaultValues: roleSelect.default_values,
|
|
271
|
+
minValues: roleSelect.min_values,
|
|
272
|
+
maxValues: roleSelect.max_values,
|
|
273
|
+
disabled: roleSelect.disabled,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
static roleSelectToRaw(roleSelect) {
|
|
277
|
+
return {
|
|
278
|
+
type: roleSelect.type,
|
|
279
|
+
id: roleSelect.id,
|
|
280
|
+
custom_id: roleSelect.customID,
|
|
281
|
+
placeholder: roleSelect.placeholder,
|
|
282
|
+
default_values: roleSelect.defaultValues,
|
|
283
|
+
min_values: roleSelect.minValues,
|
|
284
|
+
max_values: roleSelect.maxValues,
|
|
285
|
+
disabled: roleSelect.disabled,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
180
288
|
static sectionFromRaw(section) {
|
|
181
289
|
return {
|
|
182
290
|
type: section.type,
|
|
@@ -197,109 +305,52 @@ class Components {
|
|
|
197
305
|
: Components.thumbnailToRaw(section.accessory),
|
|
198
306
|
};
|
|
199
307
|
}
|
|
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
|
-
}
|
|
308
|
+
static stringSelectFromRaw(stringSelect) {
|
|
309
|
+
return {
|
|
310
|
+
type: stringSelect.type,
|
|
311
|
+
id: stringSelect.id,
|
|
312
|
+
customID: stringSelect.custom_id,
|
|
313
|
+
placeholder: stringSelect.placeholder,
|
|
314
|
+
options: stringSelect.options?.map((option) => ({
|
|
315
|
+
label: option.label,
|
|
316
|
+
value: option.value,
|
|
317
|
+
description: option.description,
|
|
318
|
+
emoji: option.emoji !== undefined
|
|
319
|
+
? {
|
|
320
|
+
name: option.emoji.name,
|
|
321
|
+
id: option.emoji.id,
|
|
322
|
+
animated: option.emoji.animated,
|
|
323
|
+
}
|
|
324
|
+
: undefined,
|
|
325
|
+
default: option.default,
|
|
326
|
+
})),
|
|
327
|
+
minValues: stringSelect.min_values,
|
|
328
|
+
maxValues: stringSelect.max_values,
|
|
329
|
+
disabled: stringSelect.disabled,
|
|
330
|
+
};
|
|
251
331
|
}
|
|
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
|
-
}
|
|
332
|
+
static stringSelectToRaw(stringSelect) {
|
|
333
|
+
return {
|
|
334
|
+
type: stringSelect.type,
|
|
335
|
+
custom_id: stringSelect.customID,
|
|
336
|
+
placeholder: stringSelect.placeholder,
|
|
337
|
+
options: stringSelect.options?.map((option) => ({
|
|
338
|
+
label: option.label,
|
|
339
|
+
value: option.value,
|
|
340
|
+
description: option.description,
|
|
341
|
+
emoji: option.emoji !== undefined
|
|
342
|
+
? {
|
|
343
|
+
name: option.emoji.name,
|
|
344
|
+
id: option.emoji.id,
|
|
345
|
+
animated: option.emoji.animated,
|
|
346
|
+
}
|
|
347
|
+
: undefined,
|
|
348
|
+
default: option.default,
|
|
349
|
+
})),
|
|
350
|
+
min_values: stringSelect.minValues,
|
|
351
|
+
max_values: stringSelect.maxValues,
|
|
352
|
+
disabled: stringSelect.disabled,
|
|
353
|
+
};
|
|
303
354
|
}
|
|
304
355
|
static separatorFromRaw(separator) {
|
|
305
356
|
return {
|
|
@@ -336,7 +387,6 @@ class Components {
|
|
|
336
387
|
type: textInput.type,
|
|
337
388
|
customID: textInput.custom_id,
|
|
338
389
|
style: textInput.style,
|
|
339
|
-
label: textInput.label,
|
|
340
390
|
minLength: textInput.min_length,
|
|
341
391
|
maxLength: textInput.max_length,
|
|
342
392
|
required: textInput.required,
|
|
@@ -350,7 +400,6 @@ class Components {
|
|
|
350
400
|
type: textInput.type,
|
|
351
401
|
custom_id: textInput.customID,
|
|
352
402
|
style: textInput.style,
|
|
353
|
-
label: textInput.label,
|
|
354
403
|
min_length: textInput.minLength,
|
|
355
404
|
max_length: textInput.maxLength,
|
|
356
405
|
required: textInput.required,
|
|
@@ -395,5 +444,29 @@ class Components {
|
|
|
395
444
|
content_type: unfurledMediaItem.contentType,
|
|
396
445
|
};
|
|
397
446
|
}
|
|
447
|
+
static userSelectFromRaw(userSelect) {
|
|
448
|
+
return {
|
|
449
|
+
type: userSelect.type,
|
|
450
|
+
id: userSelect.id,
|
|
451
|
+
customID: userSelect.custom_id,
|
|
452
|
+
placeholder: userSelect.placeholder,
|
|
453
|
+
defaultValues: userSelect.default_values,
|
|
454
|
+
minValues: userSelect.min_values,
|
|
455
|
+
maxValues: userSelect.max_values,
|
|
456
|
+
disabled: userSelect.disabled,
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
static userSelectToRaw(userSelect) {
|
|
460
|
+
return {
|
|
461
|
+
type: userSelect.type,
|
|
462
|
+
id: userSelect.id,
|
|
463
|
+
custom_id: userSelect.customID,
|
|
464
|
+
placeholder: userSelect.placeholder,
|
|
465
|
+
default_values: userSelect.defaultValues,
|
|
466
|
+
min_values: userSelect.minValues,
|
|
467
|
+
max_values: userSelect.maxValues,
|
|
468
|
+
disabled: userSelect.disabled,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
398
471
|
}
|
|
399
472
|
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.StringSelect:
|
|
77
|
+
return Components_1.Components.stringSelectFromRaw(component);
|
|
78
|
+
case constants_1.ComponentTypes.TextInput:
|
|
79
|
+
return Components_1.Components.textInputFromRaw(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.StringSelect:
|
|
174
|
+
return Components_1.Components.stringSelectToRaw(component);
|
|
175
|
+
case constants_1.ComponentTypes.TextInput:
|
|
176
|
+
return Components_1.Components.textInputToRaw(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
|
}
|