disgroove 2.2.7-dev.4cca8cf → 2.2.7-dev.5357ecd

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.
@@ -1,21 +1,29 @@
1
- import { ActionRow, Button, Container, RawActionRow, RawButton, RawContainer, RawFile, File, RawUnfurledMediaItem, UnfurledMediaItem, RawTextDisplay, TextDisplay, RawSeparator, Separator, RawSection, Section, Thumbnail, RawThumbnail, TextInput, RawTextInput, SelectMenu, RawSelectMenu, MediaGallery, RawMediaGallery } from "../types/message-components.js";
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 selectMenuFromRaw(selectMenu: RawSelectMenu): SelectMenu;
16
- static selectMenuToRaw(selectMenu: SelectMenu): RawSelectMenu;
17
23
  static separatorFromRaw(separator: RawSeparator): Separator;
18
24
  static separatorToRaw(separator: Separator): RawSeparator;
25
+ static stringSelectFromRaw(stringSelect: RawStringSelect): StringSelect;
26
+ static stringSelectToRaw(stringSelect: StringSelect): RawStringSelect;
19
27
  static textDisplayFromRaw(textDisplay: RawTextDisplay): TextDisplay;
20
28
  static textDisplayToRaw(textDisplay: TextDisplay): RawTextDisplay;
21
29
  static textInputFromRaw(textInput: RawTextInput): TextInput;
@@ -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,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
- case constants_js_1.ComponentTypes.TextInput: {
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
- case constants_js_1.ComponentTypes.StringSelect: {
22
- return Components.selectMenuFromRaw(c);
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
- case constants_js_1.ComponentTypes.TextInput: {
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
- case constants_js_1.ComponentTypes.StringSelect: {
45
- return Components.selectMenuToRaw(c);
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,129 +241,97 @@ 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) {
293
+ let accessory;
294
+ switch (section.accessory.type) {
295
+ case constants_js_1.ComponentTypes.Button:
296
+ accessory = Components.buttonFromRaw(section.accessory);
297
+ break;
298
+ case constants_js_1.ComponentTypes.Thumbnail:
299
+ accessory = Components.thumbnailFromRaw(section.accessory);
300
+ break;
301
+ }
181
302
  return {
182
303
  type: section.type,
183
304
  id: section.id,
184
- components: [],
185
- accessory: section.accessory.type === constants_js_1.ComponentTypes.Button
186
- ? Components.buttonFromRaw(section.accessory)
187
- : Components.thumbnailFromRaw(section.accessory),
305
+ components: section.components.map((component) => {
306
+ switch (component.type) {
307
+ case constants_js_1.ComponentTypes.TextDisplay:
308
+ return Components.textDisplayFromRaw(component);
309
+ }
310
+ }),
311
+ accessory,
188
312
  };
189
313
  }
190
314
  static sectionToRaw(section) {
315
+ let accessory;
316
+ switch (section.accessory.type) {
317
+ case constants_js_1.ComponentTypes.Button:
318
+ accessory = Components.buttonToRaw(section.accessory);
319
+ break;
320
+ case constants_js_1.ComponentTypes.Thumbnail:
321
+ accessory = Components.thumbnailToRaw(section.accessory);
322
+ break;
323
+ }
191
324
  return {
192
325
  type: section.type,
193
326
  id: section.id,
194
- components: [],
195
- accessory: section.accessory.type === constants_js_1.ComponentTypes.Button
196
- ? Components.buttonToRaw(section.accessory)
197
- : Components.thumbnailToRaw(section.accessory),
198
- };
199
- }
200
- static selectMenuFromRaw(selectMenu) {
201
- switch (selectMenu.type) {
202
- case constants_js_1.ComponentTypes.ChannelSelect: {
203
- return {
204
- type: selectMenu.type,
205
- customID: selectMenu.custom_id,
206
- channelTypes: selectMenu.channel_types,
207
- placeholder: selectMenu.placeholder,
208
- defaultValues: selectMenu.default_values,
209
- minValues: selectMenu.min_values,
210
- maxValues: selectMenu.max_values,
211
- disabled: selectMenu.disabled,
212
- };
213
- }
214
- case constants_js_1.ComponentTypes.StringSelect: {
215
- return {
216
- type: selectMenu.type,
217
- customID: selectMenu.custom_id,
218
- placeholder: selectMenu.placeholder,
219
- options: selectMenu.options?.map((option) => ({
220
- label: option.label,
221
- value: option.value,
222
- description: option.description,
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
- }
251
- }
252
- static selectMenuToRaw(selectMenu) {
253
- switch (selectMenu.type) {
254
- case constants_js_1.ComponentTypes.ChannelSelect: {
255
- return {
256
- type: selectMenu.type,
257
- custom_id: selectMenu.customID,
258
- channel_types: selectMenu.channelTypes,
259
- placeholder: selectMenu.placeholder,
260
- default_values: selectMenu.defaultValues,
261
- min_values: selectMenu.minValues,
262
- max_values: selectMenu.maxValues,
263
- disabled: selectMenu.disabled,
264
- };
265
- }
266
- case constants_js_1.ComponentTypes.StringSelect: {
267
- return {
268
- type: selectMenu.type,
269
- custom_id: selectMenu.customID,
270
- placeholder: selectMenu.placeholder,
271
- options: selectMenu.options?.map((option) => ({
272
- label: option.label,
273
- value: option.value,
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
- }
327
+ components: section.components.map((component) => {
328
+ switch (component.type) {
329
+ case constants_js_1.ComponentTypes.TextDisplay:
330
+ return Components.textDisplayToRaw(component);
331
+ }
332
+ }),
333
+ accessory,
334
+ };
303
335
  }
304
336
  static separatorFromRaw(separator) {
305
337
  return {
@@ -317,6 +349,53 @@ class Components {
317
349
  spacing: separator.spacing,
318
350
  };
319
351
  }
352
+ static stringSelectFromRaw(stringSelect) {
353
+ return {
354
+ type: stringSelect.type,
355
+ id: stringSelect.id,
356
+ customID: stringSelect.custom_id,
357
+ placeholder: stringSelect.placeholder,
358
+ options: stringSelect.options?.map((option) => ({
359
+ label: option.label,
360
+ value: option.value,
361
+ description: option.description,
362
+ emoji: option.emoji !== undefined
363
+ ? {
364
+ name: option.emoji.name,
365
+ id: option.emoji.id,
366
+ animated: option.emoji.animated,
367
+ }
368
+ : undefined,
369
+ default: option.default,
370
+ })),
371
+ minValues: stringSelect.min_values,
372
+ maxValues: stringSelect.max_values,
373
+ disabled: stringSelect.disabled,
374
+ };
375
+ }
376
+ static stringSelectToRaw(stringSelect) {
377
+ return {
378
+ type: stringSelect.type,
379
+ custom_id: stringSelect.customID,
380
+ placeholder: stringSelect.placeholder,
381
+ options: stringSelect.options?.map((option) => ({
382
+ label: option.label,
383
+ value: option.value,
384
+ description: option.description,
385
+ emoji: option.emoji !== undefined
386
+ ? {
387
+ name: option.emoji.name,
388
+ id: option.emoji.id,
389
+ animated: option.emoji.animated,
390
+ }
391
+ : undefined,
392
+ default: option.default,
393
+ })),
394
+ min_values: stringSelect.minValues,
395
+ max_values: stringSelect.maxValues,
396
+ disabled: stringSelect.disabled,
397
+ };
398
+ }
320
399
  static textDisplayFromRaw(textDisplay) {
321
400
  return {
322
401
  type: textDisplay.type,
@@ -336,13 +415,13 @@ class Components {
336
415
  type: textInput.type,
337
416
  customID: textInput.custom_id,
338
417
  style: textInput.style,
339
- label: textInput.label,
340
418
  minLength: textInput.min_length,
341
419
  maxLength: textInput.max_length,
342
420
  required: textInput.required,
343
421
  value: textInput.value,
344
422
  placeholder: textInput.placeholder,
345
423
  id: textInput.id,
424
+ label: textInput.label,
346
425
  };
347
426
  }
348
427
  static textInputToRaw(textInput) {
@@ -350,13 +429,13 @@ class Components {
350
429
  type: textInput.type,
351
430
  custom_id: textInput.customID,
352
431
  style: textInput.style,
353
- label: textInput.label,
354
432
  min_length: textInput.minLength,
355
433
  max_length: textInput.maxLength,
356
434
  required: textInput.required,
357
435
  value: textInput.value,
358
436
  placeholder: textInput.placeholder,
359
437
  id: textInput.id,
438
+ label: textInput.label,
360
439
  };
361
440
  }
362
441
  static thumbnailFromRaw(thumbnail) {
@@ -395,5 +474,29 @@ class Components {
395
474
  content_type: unfurledMediaItem.contentType,
396
475
  };
397
476
  }
477
+ static userSelectFromRaw(userSelect) {
478
+ return {
479
+ type: userSelect.type,
480
+ id: userSelect.id,
481
+ customID: userSelect.custom_id,
482
+ placeholder: userSelect.placeholder,
483
+ defaultValues: userSelect.default_values,
484
+ minValues: userSelect.min_values,
485
+ maxValues: userSelect.max_values,
486
+ disabled: userSelect.disabled,
487
+ };
488
+ }
489
+ static userSelectToRaw(userSelect) {
490
+ return {
491
+ type: userSelect.type,
492
+ id: userSelect.id,
493
+ custom_id: userSelect.customID,
494
+ placeholder: userSelect.placeholder,
495
+ default_values: userSelect.defaultValues,
496
+ min_values: userSelect.minValues,
497
+ max_values: userSelect.maxValues,
498
+ disabled: userSelect.disabled,
499
+ };
500
+ }
398
501
  }
399
502
  exports.Components = Components;