disgroove 2.2.5 → 2.2.6-dev.3f22d60

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.
@@ -0,0 +1,399 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Components = void 0;
4
+ const constants_js_1 = require("../constants.js");
5
+ class Components {
6
+ static actionRowFromRaw(actionRow) {
7
+ return {
8
+ type: actionRow.type,
9
+ components: actionRow.components.map((c) => {
10
+ switch (c.type) {
11
+ case constants_js_1.ComponentTypes.Button: {
12
+ return Components.buttonFromRaw(c);
13
+ }
14
+ case constants_js_1.ComponentTypes.TextInput: {
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:
20
+ case constants_js_1.ComponentTypes.UserSelect:
21
+ case constants_js_1.ComponentTypes.StringSelect: {
22
+ return Components.selectMenuFromRaw(c);
23
+ }
24
+ }
25
+ }),
26
+ id: actionRow.id,
27
+ };
28
+ }
29
+ static actionRowToRaw(actionRow) {
30
+ return {
31
+ type: actionRow.type,
32
+ components: actionRow.components.map((c) => {
33
+ switch (c.type) {
34
+ case constants_js_1.ComponentTypes.Button: {
35
+ return Components.buttonToRaw(c);
36
+ }
37
+ case constants_js_1.ComponentTypes.TextInput: {
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:
43
+ case constants_js_1.ComponentTypes.UserSelect:
44
+ case constants_js_1.ComponentTypes.StringSelect: {
45
+ return Components.selectMenuToRaw(c);
46
+ }
47
+ }
48
+ }),
49
+ id: actionRow.id,
50
+ };
51
+ }
52
+ static buttonFromRaw(button) {
53
+ return {
54
+ type: button.type,
55
+ style: button.style,
56
+ label: button.label,
57
+ emoji: button.emoji,
58
+ customID: button.custom_id,
59
+ skuID: button.sku_id,
60
+ url: button.url,
61
+ disabled: button.disabled,
62
+ id: button.id,
63
+ };
64
+ }
65
+ static buttonToRaw(button) {
66
+ return {
67
+ type: button.type,
68
+ style: button.style,
69
+ label: button.label,
70
+ emoji: button.emoji,
71
+ custom_id: button.customID,
72
+ sku_id: button.skuID,
73
+ url: button.url,
74
+ disabled: button.disabled,
75
+ id: button.id,
76
+ };
77
+ }
78
+ static containerFromRaw(container) {
79
+ return {
80
+ type: container.type,
81
+ id: container.id,
82
+ components: container.components.map((c) => {
83
+ switch (c.type) {
84
+ case constants_js_1.ComponentTypes.ActionRow: {
85
+ return Components.actionRowFromRaw(c);
86
+ }
87
+ case constants_js_1.ComponentTypes.TextDisplay: {
88
+ return Components.textDisplayFromRaw(c);
89
+ }
90
+ case constants_js_1.ComponentTypes.Section: {
91
+ return Components.sectionFromRaw(c);
92
+ }
93
+ case constants_js_1.ComponentTypes.MediaGallery: {
94
+ return Components.mediaGalleryFromRaw(c);
95
+ }
96
+ case constants_js_1.ComponentTypes.File: {
97
+ return Components.fileFromRaw(c);
98
+ }
99
+ case constants_js_1.ComponentTypes.Separator: {
100
+ return Components.separatorFromRaw(c);
101
+ }
102
+ }
103
+ }),
104
+ accentColor: container.accent_color,
105
+ spoiler: container.spoiler,
106
+ };
107
+ }
108
+ static containerToRaw(container) {
109
+ return {
110
+ type: container.type,
111
+ id: container.id,
112
+ components: container.components.map((c) => {
113
+ switch (c.type) {
114
+ case constants_js_1.ComponentTypes.ActionRow: {
115
+ return Components.actionRowToRaw(c);
116
+ }
117
+ case constants_js_1.ComponentTypes.TextDisplay: {
118
+ return Components.textDisplayToRaw(c);
119
+ }
120
+ case constants_js_1.ComponentTypes.Section: {
121
+ return Components.sectionToRaw(c);
122
+ }
123
+ case constants_js_1.ComponentTypes.MediaGallery: {
124
+ return Components.mediaGalleryToRaw(c);
125
+ }
126
+ case constants_js_1.ComponentTypes.File: {
127
+ return Components.fileToRaw(c);
128
+ }
129
+ case constants_js_1.ComponentTypes.Separator: {
130
+ return Components.separatorToRaw(c);
131
+ }
132
+ }
133
+ }),
134
+ accent_color: container.accentColor,
135
+ spoiler: container.spoiler,
136
+ };
137
+ }
138
+ static fileFromRaw(file) {
139
+ return {
140
+ type: file.type,
141
+ id: file.id,
142
+ file: Components.unfurledMediaItemFromRaw(file.file),
143
+ spoiler: file.spoiler,
144
+ name: file.name,
145
+ size: file.size,
146
+ };
147
+ }
148
+ static fileToRaw(file) {
149
+ return {
150
+ type: file.type,
151
+ id: file.id,
152
+ file: Components.unfurledMediaItemToRaw(file.file),
153
+ spoiler: file.spoiler,
154
+ name: file.name,
155
+ size: file.size,
156
+ };
157
+ }
158
+ static mediaGalleryFromRaw(mediaGallery) {
159
+ return {
160
+ type: mediaGallery.type,
161
+ id: mediaGallery.id,
162
+ items: mediaGallery.items.map((item) => ({
163
+ media: Components.unfurledMediaItemFromRaw(item.media),
164
+ description: item.description,
165
+ spoiler: item.spoiler,
166
+ })),
167
+ };
168
+ }
169
+ static mediaGalleryToRaw(mediaGallery) {
170
+ return {
171
+ type: mediaGallery.type,
172
+ id: mediaGallery.id,
173
+ items: mediaGallery.items.map((item) => ({
174
+ media: Components.unfurledMediaItemToRaw(item.media),
175
+ description: item.description,
176
+ spoiler: item.spoiler,
177
+ })),
178
+ };
179
+ }
180
+ static sectionFromRaw(section) {
181
+ return {
182
+ type: section.type,
183
+ 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),
188
+ };
189
+ }
190
+ static sectionToRaw(section) {
191
+ return {
192
+ type: section.type,
193
+ 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
+ }
303
+ }
304
+ static separatorFromRaw(separator) {
305
+ return {
306
+ type: separator.type,
307
+ id: separator.id,
308
+ divider: separator.divider,
309
+ spacing: separator.spacing,
310
+ };
311
+ }
312
+ static separatorToRaw(separator) {
313
+ return {
314
+ type: separator.type,
315
+ id: separator.id,
316
+ divider: separator.divider,
317
+ spacing: separator.spacing,
318
+ };
319
+ }
320
+ static textDisplayFromRaw(textDisplay) {
321
+ return {
322
+ type: textDisplay.type,
323
+ id: textDisplay.id,
324
+ content: textDisplay.content,
325
+ };
326
+ }
327
+ static textDisplayToRaw(textDisplay) {
328
+ return {
329
+ type: textDisplay.type,
330
+ id: textDisplay.id,
331
+ content: textDisplay.content,
332
+ };
333
+ }
334
+ static textInputFromRaw(textInput) {
335
+ return {
336
+ type: textInput.type,
337
+ customID: textInput.custom_id,
338
+ style: textInput.style,
339
+ label: textInput.label,
340
+ minLength: textInput.min_length,
341
+ maxLength: textInput.max_length,
342
+ required: textInput.required,
343
+ value: textInput.value,
344
+ placeholder: textInput.placeholder,
345
+ id: textInput.id,
346
+ };
347
+ }
348
+ static textInputToRaw(textInput) {
349
+ return {
350
+ type: textInput.type,
351
+ custom_id: textInput.customID,
352
+ style: textInput.style,
353
+ label: textInput.label,
354
+ min_length: textInput.minLength,
355
+ max_length: textInput.maxLength,
356
+ required: textInput.required,
357
+ value: textInput.value,
358
+ placeholder: textInput.placeholder,
359
+ id: textInput.id,
360
+ };
361
+ }
362
+ static thumbnailFromRaw(thumbnail) {
363
+ return {
364
+ type: thumbnail.type,
365
+ id: thumbnail.id,
366
+ media: Components.unfurledMediaItemFromRaw(thumbnail.media),
367
+ description: thumbnail.description,
368
+ spoiler: thumbnail.spoiler,
369
+ };
370
+ }
371
+ static thumbnailToRaw(thumbnail) {
372
+ return {
373
+ type: thumbnail.type,
374
+ id: thumbnail.id,
375
+ media: Components.unfurledMediaItemToRaw(thumbnail.media),
376
+ description: thumbnail.description,
377
+ spoiler: thumbnail.spoiler,
378
+ };
379
+ }
380
+ static unfurledMediaItemFromRaw(unfurledMediaItem) {
381
+ return {
382
+ url: unfurledMediaItem.url,
383
+ proxyURL: unfurledMediaItem.proxy_url,
384
+ height: unfurledMediaItem.height,
385
+ width: unfurledMediaItem.width,
386
+ contentType: unfurledMediaItem.content_type,
387
+ };
388
+ }
389
+ static unfurledMediaItemToRaw(unfurledMediaItem) {
390
+ return {
391
+ url: unfurledMediaItem.url,
392
+ proxy_url: unfurledMediaItem.proxyURL,
393
+ height: unfurledMediaItem.height,
394
+ width: unfurledMediaItem.width,
395
+ content_type: unfurledMediaItem.contentType,
396
+ };
397
+ }
398
+ }
399
+ exports.Components = Components;
@@ -1,10 +1,9 @@
1
- import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message } from "../types/message";
2
- import type { RawActionRow, ActionRow } from "../types/message-components";
1
+ import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message, MessageTopLevelComponent, RawMessageTopLevelComponent } from "../types/message";
3
2
  export declare class Messages {
4
3
  static attachmentFromRaw(attachment: RawAttachment): Attachment;
5
4
  static attachmentToRaw(attachment: Attachment): RawAttachment;
6
- static componentsFromRaw(components: Array<RawActionRow>): Array<ActionRow>;
7
- static componentsToRaw(components: Array<ActionRow>): Array<RawActionRow>;
5
+ static componentsFromRaw(components: Array<RawMessageTopLevelComponent>): Array<MessageTopLevelComponent>;
6
+ static componentsToRaw(components: Array<MessageTopLevelComponent>): Array<RawMessageTopLevelComponent>;
8
7
  static embedFromRaw(embed: RawEmbed): Embed;
9
8
  static embedToRaw(embed: Embed): RawEmbed;
10
9
  static messageFromRaw(message: RawMessage): Message;
@@ -4,6 +4,7 @@ exports.Messages = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const Applications_1 = require("./Applications");
6
6
  const Channels_1 = require("./Channels");
7
+ const Components_js_1 = require("./Components.js");
7
8
  const Emojis_1 = require("./Emojis");
8
9
  const Guilds_1 = require("./Guilds");
9
10
  const Interactions_1 = require("./Interactions");
@@ -48,180 +49,58 @@ class Messages {
48
49
  };
49
50
  }
50
51
  static componentsFromRaw(components) {
51
- return components.map((component) => ({
52
- type: component.type,
53
- components: component.components.map((c) => {
54
- switch (c.type) {
55
- case constants_1.ComponentTypes.Button: {
56
- return {
57
- type: c.type,
58
- style: c.style,
59
- label: c.label,
60
- emoji: c.emoji !== undefined
61
- ? {
62
- name: c.emoji.name,
63
- id: c.emoji.id,
64
- animated: c.emoji.animated,
65
- }
66
- : undefined,
67
- customID: c.custom_id,
68
- skuID: c.sku_id,
69
- url: c.url,
70
- disabled: c.disabled,
71
- };
72
- }
73
- case constants_1.ComponentTypes.TextInput: {
74
- return {
75
- type: c.type,
76
- customID: c.custom_id,
77
- style: c.style,
78
- label: c.label,
79
- minLength: c.min_length,
80
- maxLength: c.max_length,
81
- required: c.required,
82
- value: c.value,
83
- placeholder: c.placeholder,
84
- };
85
- }
86
- case constants_1.ComponentTypes.ChannelSelect: {
87
- return {
88
- type: c.type,
89
- customID: c.custom_id,
90
- channelTypes: c.channel_types,
91
- placeholder: c.placeholder,
92
- defaultValues: c.default_values,
93
- minValues: c.min_values,
94
- maxValues: c.max_values,
95
- disabled: c.disabled,
96
- };
97
- }
98
- case constants_1.ComponentTypes.StringSelect: {
99
- return {
100
- type: c.type,
101
- customID: c.custom_id,
102
- placeholder: c.placeholder,
103
- options: c.options?.map((option) => ({
104
- label: option.label,
105
- value: option.value,
106
- description: option.description,
107
- emoji: option.emoji !== undefined
108
- ? {
109
- name: option.emoji.name,
110
- id: option.emoji.id,
111
- animated: option.emoji.animated,
112
- }
113
- : undefined,
114
- default: option.default,
115
- })),
116
- minValues: c.min_values,
117
- maxValues: c.max_values,
118
- disabled: c.disabled,
119
- };
120
- }
121
- case constants_1.ComponentTypes.MentionableSelect:
122
- case constants_1.ComponentTypes.RoleSelect:
123
- case constants_1.ComponentTypes.UserSelect: {
124
- return {
125
- type: c.type,
126
- customID: c.custom_id,
127
- placeholder: c.placeholder,
128
- defaultValues: c.default_values,
129
- minValues: c.min_values,
130
- maxValues: c.max_values,
131
- disabled: c.disabled,
132
- };
133
- }
52
+ return components.map((component) => {
53
+ switch (component.type) {
54
+ case constants_1.ComponentTypes.ActionRow: {
55
+ return Components_js_1.Components.actionRowFromRaw(component);
134
56
  }
135
- }),
136
- }));
57
+ case constants_1.ComponentTypes.TextDisplay: {
58
+ return Components_js_1.Components.textDisplayFromRaw(component);
59
+ }
60
+ case constants_1.ComponentTypes.Container: {
61
+ return Components_js_1.Components.containerFromRaw(component);
62
+ }
63
+ case constants_1.ComponentTypes.File: {
64
+ 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: {
70
+ return Components_js_1.Components.separatorFromRaw(component);
71
+ }
72
+ case constants_1.ComponentTypes.MediaGallery: {
73
+ return Components_js_1.Components.mediaGalleryFromRaw(component);
74
+ }
75
+ }
76
+ });
137
77
  }
138
78
  static componentsToRaw(components) {
139
- return components.map((component) => ({
140
- type: component.type,
141
- components: component.components.map((c) => {
142
- switch (c.type) {
143
- case constants_1.ComponentTypes.Button: {
144
- return {
145
- type: c.type,
146
- style: c.style,
147
- label: c.label,
148
- emoji: c.emoji !== undefined
149
- ? {
150
- name: c.emoji.name,
151
- id: c.emoji.id,
152
- animated: c.emoji.animated,
153
- }
154
- : undefined,
155
- custom_id: c.customID,
156
- sku_id: c.skuID,
157
- url: c.url,
158
- disabled: c.disabled,
159
- };
160
- }
161
- case constants_1.ComponentTypes.TextInput: {
162
- return {
163
- type: c.type,
164
- custom_id: c.customID,
165
- style: c.style,
166
- label: c.label,
167
- min_length: c.minLength,
168
- max_length: c.maxLength,
169
- required: c.required,
170
- value: c.value,
171
- placeholder: c.placeholder,
172
- };
173
- }
174
- case constants_1.ComponentTypes.ChannelSelect: {
175
- return {
176
- type: c.type,
177
- custom_id: c.customID,
178
- channel_types: c.channelTypes,
179
- placeholder: c.placeholder,
180
- default_values: c.defaultValues,
181
- min_values: c.minValues,
182
- max_values: c.maxValues,
183
- disabled: c.disabled,
184
- };
185
- }
186
- case constants_1.ComponentTypes.StringSelect: {
187
- return {
188
- type: c.type,
189
- custom_id: c.customID,
190
- placeholder: c.placeholder,
191
- options: c.options?.map((option) => ({
192
- label: option.label,
193
- value: option.value,
194
- description: option.description,
195
- emoji: option.emoji !== undefined
196
- ? {
197
- name: option.emoji.name,
198
- id: option.emoji.id,
199
- animated: option.emoji.animated,
200
- }
201
- : undefined,
202
- default: option.default,
203
- })),
204
- min_values: c.minValues,
205
- max_values: c.maxValues,
206
- disabled: c.disabled,
207
- };
208
- }
209
- case constants_1.ComponentTypes.MentionableSelect:
210
- case constants_1.ComponentTypes.RoleSelect:
211
- case constants_1.ComponentTypes.UserSelect: {
212
- return {
213
- type: c.type,
214
- custom_id: c.customID,
215
- placeholder: c.placeholder,
216
- default_values: c.defaultValues,
217
- min_values: c.minValues,
218
- max_values: c.maxValues,
219
- disabled: c.disabled,
220
- };
221
- }
79
+ return components.map((component) => {
80
+ switch (component.type) {
81
+ case constants_1.ComponentTypes.ActionRow: {
82
+ return Components_js_1.Components.actionRowToRaw(component);
83
+ }
84
+ case constants_1.ComponentTypes.TextDisplay: {
85
+ return Components_js_1.Components.textDisplayToRaw(component);
86
+ }
87
+ case constants_1.ComponentTypes.Container: {
88
+ return Components_js_1.Components.containerToRaw(component);
89
+ }
90
+ case constants_1.ComponentTypes.File: {
91
+ 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: {
97
+ return Components_js_1.Components.separatorToRaw(component);
98
+ }
99
+ case constants_1.ComponentTypes.MediaGallery: {
100
+ return Components_js_1.Components.mediaGalleryToRaw(component);
222
101
  }
223
- }),
224
- }));
102
+ }
103
+ });
225
104
  }
226
105
  static embedFromRaw(embed) {
227
106
  return {
@@ -1,5 +1,7 @@
1
- import type { RawUser, User } from "../types/user";
1
+ import type { Nameplate, RawNameplate, RawUser, User } from "../types/user";
2
2
  export declare class Users {
3
+ static nameplateFromRaw(nameplate: RawNameplate): Nameplate;
4
+ static nameplateToRaw(nameplate: Nameplate): RawNameplate;
3
5
  static userFromRaw(user: RawUser): User;
4
6
  static userToRaw(user: User): RawUser;
5
7
  }