disgroove 2.2.7-dev.fca4921 → 2.2.7

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.
Files changed (35) hide show
  1. package/dist/lib/Client.d.ts +49 -13
  2. package/dist/lib/Client.js +99 -6
  3. package/dist/lib/constants.d.ts +29 -21
  4. package/dist/lib/constants.js +33 -24
  5. package/dist/lib/gateway/Shard.js +15 -0
  6. package/dist/lib/index.d.ts +1 -1
  7. package/dist/lib/index.js +1 -1
  8. package/dist/lib/rest/Endpoints.d.ts +4 -0
  9. package/dist/lib/rest/Endpoints.js +10 -1
  10. package/dist/lib/rest/RequestManager.d.ts +1 -3
  11. package/dist/lib/transformers/Components.d.ts +13 -3
  12. package/dist/lib/transformers/Components.js +277 -150
  13. package/dist/lib/transformers/Interactions.js +283 -38
  14. package/dist/lib/transformers/Lobbies.d.ts +7 -0
  15. package/dist/lib/transformers/Lobbies.js +38 -0
  16. package/dist/lib/transformers/Messages.d.ts +4 -3
  17. package/dist/lib/transformers/Messages.js +20 -34
  18. package/dist/lib/transformers/Roles.js +2 -2
  19. package/dist/lib/transformers/index.d.ts +2 -1
  20. package/dist/lib/transformers/index.js +2 -1
  21. package/dist/lib/types/components.d.ts +450 -0
  22. package/dist/lib/types/components.js +2 -0
  23. package/dist/lib/types/gateway-events.d.ts +23 -1
  24. package/dist/lib/types/guild.d.ts +7 -5
  25. package/dist/lib/types/interaction.d.ts +12 -8
  26. package/dist/lib/types/invite.d.ts +2 -2
  27. package/dist/lib/types/lobby.d.ts +29 -0
  28. package/dist/lib/types/lobby.js +2 -0
  29. package/dist/lib/types/message-components.d.ts +334 -118
  30. package/dist/lib/types/message.d.ts +3 -5
  31. package/dist/lib/types/role.d.ts +2 -2
  32. package/dist/lib/utils/formatters.d.ts +1 -1
  33. package/dist/lib/utils/formatters.js +1 -1
  34. package/dist/package.json +4 -4
  35. package/package.json +4 -4
@@ -7,6 +7,7 @@ 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");
10
11
  class Interactions {
11
12
  static interactionCallbackResponseFromRaw(interactionCallbackResponse) {
12
13
  return {
@@ -57,32 +58,153 @@ class Interactions {
57
58
  type: interaction.type,
58
59
  data: interaction.data !== undefined
59
60
  ? {
60
- id: interaction.data.id,
61
- name: interaction.data.name,
62
- type: interaction.data.type,
63
- resolved: interaction.data.resolved !== undefined
61
+ id: interaction.data?.id,
62
+ name: interaction.data?.name,
63
+ type: interaction.data?.type,
64
+ resolved: interaction.data?.resolved !== undefined
64
65
  ? Interactions.resolvedDataFromRaw(interaction.data.resolved)
65
66
  : undefined,
66
- options: interaction.data.options,
67
- guildID: interaction.data.guild_id,
68
- targetID: interaction.data.target_id,
69
- customID: interaction.data.custom_id,
70
- componentType: interaction.data.component_type,
71
- values: interaction.data.values,
72
- components: interaction.data.components?.map((component) => ({
73
- type: component.type,
74
- components: component.components?.map((c) => ({
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
- })),
67
+ options: interaction.data?.options,
68
+ guildID: interaction.data?.guild_id,
69
+ targetID: interaction.data?.target_id,
70
+ customID: interaction.data?.custom_id,
71
+ componentType: interaction.data?.component_type,
72
+ values: interaction.data?.values,
73
+ components: interaction.data?.components?.map((component) => {
74
+ switch (component.type) {
75
+ case constants_1.ComponentTypes.ActionRow:
76
+ return {
77
+ type: constants_1.ComponentTypes.ActionRow,
78
+ components: component.components.map((c) => {
79
+ switch (c.type) {
80
+ case constants_1.ComponentTypes.TextInput:
81
+ return {
82
+ type: c.type,
83
+ id: c.id,
84
+ customID: c.custom_id,
85
+ value: c.value,
86
+ };
87
+ case constants_1.ComponentTypes.StringSelect:
88
+ return {
89
+ type: c.type,
90
+ componentType: c.component_type,
91
+ id: c.id,
92
+ customID: c.custom_id,
93
+ values: c.values,
94
+ };
95
+ case constants_1.ComponentTypes.UserSelect:
96
+ return {
97
+ type: c.type,
98
+ componentType: c.component_type,
99
+ id: c.id,
100
+ customID: c.custom_id,
101
+ resolved: this.resolvedDataFromRaw(c.resolved),
102
+ values: c.values,
103
+ };
104
+ case constants_1.ComponentTypes.RoleSelect:
105
+ return {
106
+ type: c.type,
107
+ componentType: c.component_type,
108
+ id: c.id,
109
+ customID: c.custom_id,
110
+ resolved: this.resolvedDataFromRaw(c.resolved),
111
+ values: c.values,
112
+ };
113
+ case constants_1.ComponentTypes.MentionableSelect:
114
+ return {
115
+ type: c.type,
116
+ componentType: c.component_type,
117
+ id: c.id,
118
+ customID: c.custom_id,
119
+ resolved: this.resolvedDataFromRaw(c.resolved),
120
+ values: c.values,
121
+ };
122
+ case constants_1.ComponentTypes.ChannelSelect:
123
+ return {
124
+ type: c.type,
125
+ componentType: c.component_type,
126
+ id: c.id,
127
+ customID: c.custom_id,
128
+ resolved: this.resolvedDataFromRaw(c.resolved),
129
+ values: c.values,
130
+ };
131
+ }
132
+ }),
133
+ };
134
+ case constants_1.ComponentTypes.TextDisplay:
135
+ return {
136
+ type: component.type,
137
+ id: component.id,
138
+ };
139
+ case constants_1.ComponentTypes.Label: {
140
+ let c;
141
+ switch (component.component.type) {
142
+ case constants_1.ComponentTypes.TextInput:
143
+ c = {
144
+ type: component.component.type,
145
+ id: component.component.id,
146
+ customID: component.component.custom_id,
147
+ value: component.component.value,
148
+ };
149
+ break;
150
+ case constants_1.ComponentTypes.StringSelect:
151
+ c = {
152
+ type: component.component.type,
153
+ componentType: component.component.component_type,
154
+ id: component.component.id,
155
+ customID: component.component.custom_id,
156
+ values: component.component.values,
157
+ };
158
+ break;
159
+ case constants_1.ComponentTypes.UserSelect:
160
+ c = {
161
+ type: component.component.type,
162
+ componentType: component.component.component_type,
163
+ id: component.component.id,
164
+ customID: component.component.custom_id,
165
+ resolved: this.resolvedDataFromRaw(component.component.resolved),
166
+ values: component.component.values,
167
+ };
168
+ break;
169
+ case constants_1.ComponentTypes.RoleSelect:
170
+ c = {
171
+ type: component.component.type,
172
+ componentType: component.component.component_type,
173
+ id: component.component.id,
174
+ customID: component.component.custom_id,
175
+ resolved: this.resolvedDataFromRaw(component.component.resolved),
176
+ values: component.component.values,
177
+ };
178
+ break;
179
+ case constants_1.ComponentTypes.MentionableSelect:
180
+ c = {
181
+ type: component.component.type,
182
+ componentType: component.component.component_type,
183
+ id: component.component.id,
184
+ customID: component.component.custom_id,
185
+ resolved: this.resolvedDataFromRaw(component.component.resolved),
186
+ values: component.component.values,
187
+ };
188
+ break;
189
+ case constants_1.ComponentTypes.ChannelSelect:
190
+ c = {
191
+ type: component.component.type,
192
+ componentType: component.component.component_type,
193
+ id: component.component.id,
194
+ customID: component.component.custom_id,
195
+ resolved: this.resolvedDataFromRaw(component.component.resolved),
196
+ values: component.component.values,
197
+ };
198
+ break;
199
+ }
200
+ return {
201
+ type: component.type,
202
+ id: component.id,
203
+ component: c,
204
+ };
205
+ }
206
+ }
207
+ }),
86
208
  }
87
209
  : undefined,
88
210
  guild: interaction.guild !== undefined
@@ -117,6 +239,7 @@ class Interactions {
117
239
  "1": interaction.authorizing_integration_owners[1],
118
240
  },
119
241
  context: interaction.context,
242
+ attachmentSizeLimit: interaction.attachment_size_limit,
120
243
  };
121
244
  }
122
245
  static interactionMetadataFromRaw(interactionMetadata) {
@@ -170,20 +293,141 @@ class Interactions {
170
293
  custom_id: interaction.data.customID,
171
294
  component_type: interaction.data.componentType,
172
295
  values: interaction.data.values,
173
- components: interaction.data.components?.map((component) => ({
174
- type: component.type,
175
- components: component.components?.map((c) => ({
176
- type: c.type,
177
- custom_id: c.customID,
178
- style: c.style,
179
- label: c.label,
180
- min_length: c.minLength,
181
- max_length: c.maxLength,
182
- required: c.required,
183
- value: c.value,
184
- placeholder: c.placeholder,
185
- })),
186
- })),
296
+ components: interaction.data?.components?.map((component) => {
297
+ switch (component.type) {
298
+ case constants_1.ComponentTypes.ActionRow:
299
+ return {
300
+ type: constants_1.ComponentTypes.ActionRow,
301
+ components: component.components.map((c) => {
302
+ switch (c.type) {
303
+ case constants_1.ComponentTypes.TextInput:
304
+ return {
305
+ type: c.type,
306
+ id: c.id,
307
+ custom_id: c.customID,
308
+ value: c.value,
309
+ };
310
+ case constants_1.ComponentTypes.StringSelect:
311
+ return {
312
+ type: c.type,
313
+ component_type: c.componentType,
314
+ id: c.id,
315
+ custom_id: c.customID,
316
+ values: c.values,
317
+ };
318
+ case constants_1.ComponentTypes.UserSelect:
319
+ return {
320
+ type: c.type,
321
+ component_type: c.componentType,
322
+ id: c.id,
323
+ custom_id: c.customID,
324
+ resolved: this.resolvedDataToRaw(c.resolved),
325
+ values: c.values,
326
+ };
327
+ case constants_1.ComponentTypes.RoleSelect:
328
+ return {
329
+ type: c.type,
330
+ component_type: c.componentType,
331
+ id: c.id,
332
+ custom_id: c.customID,
333
+ resolved: this.resolvedDataToRaw(c.resolved),
334
+ values: c.values,
335
+ };
336
+ case constants_1.ComponentTypes.MentionableSelect:
337
+ return {
338
+ type: c.type,
339
+ component_type: c.componentType,
340
+ id: c.id,
341
+ custom_id: c.customID,
342
+ resolved: this.resolvedDataToRaw(c.resolved),
343
+ values: c.values,
344
+ };
345
+ case constants_1.ComponentTypes.ChannelSelect:
346
+ return {
347
+ type: c.type,
348
+ component_type: c.componentType,
349
+ id: c.id,
350
+ custom_id: c.customID,
351
+ resolved: this.resolvedDataToRaw(c.resolved),
352
+ values: c.values,
353
+ };
354
+ }
355
+ }),
356
+ };
357
+ case constants_1.ComponentTypes.TextDisplay:
358
+ return {
359
+ type: component.type,
360
+ id: component.id,
361
+ };
362
+ case constants_1.ComponentTypes.Label: {
363
+ let c;
364
+ switch (component.component.type) {
365
+ case constants_1.ComponentTypes.TextInput:
366
+ c = {
367
+ type: component.component.type,
368
+ id: component.component.id,
369
+ custom_id: component.component.customID,
370
+ value: component.component.value,
371
+ };
372
+ break;
373
+ case constants_1.ComponentTypes.StringSelect:
374
+ c = {
375
+ type: component.component.type,
376
+ component_type: component.component.componentType,
377
+ id: component.component.id,
378
+ custom_id: component.component.customID,
379
+ values: component.component.values,
380
+ };
381
+ break;
382
+ case constants_1.ComponentTypes.UserSelect:
383
+ c = {
384
+ type: component.component.type,
385
+ component_type: component.component.componentType,
386
+ id: component.component.id,
387
+ custom_id: component.component.customID,
388
+ resolved: this.resolvedDataToRaw(component.component.resolved),
389
+ values: component.component.values,
390
+ };
391
+ break;
392
+ case constants_1.ComponentTypes.RoleSelect:
393
+ c = {
394
+ type: component.component.type,
395
+ component_type: component.component.componentType,
396
+ id: component.component.id,
397
+ custom_id: component.component.customID,
398
+ resolved: this.resolvedDataToRaw(component.component.resolved),
399
+ values: component.component.values,
400
+ };
401
+ break;
402
+ case constants_1.ComponentTypes.MentionableSelect:
403
+ c = {
404
+ type: component.component.type,
405
+ component_type: component.component.componentType,
406
+ id: component.component.id,
407
+ custom_id: component.component.customID,
408
+ resolved: this.resolvedDataToRaw(component.component.resolved),
409
+ values: component.component.values,
410
+ };
411
+ break;
412
+ case constants_1.ComponentTypes.ChannelSelect:
413
+ c = {
414
+ type: component.component.type,
415
+ component_type: component.component.componentType,
416
+ id: component.component.id,
417
+ custom_id: component.component.customID,
418
+ resolved: this.resolvedDataToRaw(component.component.resolved),
419
+ values: component.component.values,
420
+ };
421
+ break;
422
+ }
423
+ return {
424
+ type: component.type,
425
+ id: component.id,
426
+ component: c,
427
+ };
428
+ }
429
+ }
430
+ }),
187
431
  }
188
432
  : undefined,
189
433
  guild: interaction.guild !== undefined
@@ -218,6 +462,7 @@ class Interactions {
218
462
  "1": interaction.authorizingIntegrationOwners[1],
219
463
  },
220
464
  context: interaction.context,
465
+ attachment_size_limit: interaction.attachmentSizeLimit,
221
466
  };
222
467
  }
223
468
  static resolvedDataFromRaw(resolvedData) {
@@ -0,0 +1,7 @@
1
+ import type { Lobby, LobbyMember, RawLobby, RawLobbyMember } from "../types/lobby";
2
+ export declare class Lobbies {
3
+ static lobbyFromRaw(lobby: RawLobby): Lobby;
4
+ static lobbyMemberFromRaw(lobbyMember: RawLobbyMember): LobbyMember;
5
+ static lobbyMemberToRaw(lobbyMember: LobbyMember): RawLobbyMember;
6
+ static lobbyToRaw(lobby: Lobby): RawLobby;
7
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Lobbies = void 0;
4
+ class Lobbies {
5
+ static lobbyFromRaw(lobby) {
6
+ return {
7
+ id: lobby.id,
8
+ applicationID: lobby.application_id,
9
+ metadata: lobby.metadata,
10
+ members: lobby.members,
11
+ linkedChannel: lobby.linked_channel,
12
+ };
13
+ }
14
+ static lobbyMemberFromRaw(lobbyMember) {
15
+ return {
16
+ id: lobbyMember.id,
17
+ metadata: lobbyMember.metadata,
18
+ flags: lobbyMember.flags,
19
+ };
20
+ }
21
+ static lobbyMemberToRaw(lobbyMember) {
22
+ return {
23
+ id: lobbyMember.id,
24
+ metadata: lobbyMember.metadata,
25
+ flags: lobbyMember.flags,
26
+ };
27
+ }
28
+ static lobbyToRaw(lobby) {
29
+ return {
30
+ id: lobby.id,
31
+ application_id: lobby.applicationID,
32
+ metadata: lobby.metadata,
33
+ members: lobby.members,
34
+ linked_channel: lobby.linkedChannel,
35
+ };
36
+ }
37
+ }
38
+ exports.Lobbies = Lobbies;
@@ -1,9 +1,10 @@
1
- import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message, MessageTopLevelComponent, RawMessageTopLevelComponent } from "../types/message";
1
+ import { RawAttachment, Attachment, RawEmbed, Embed, RawMessage, Message } from "../types/message";
2
+ import type { ActionRow, Container, File, MediaGallery, RawActionRow, RawContainer, RawFile, RawMediaGallery, RawSection, RawSeparator, RawTextDisplay, Section, Separator, TextDisplay } from "../types/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<RawMessageTopLevelComponent>): Array<MessageTopLevelComponent>;
6
- static componentsToRaw(components: Array<MessageTopLevelComponent>): Array<RawMessageTopLevelComponent>;
6
+ static componentsFromRaw(components: Array<RawActionRow | RawSection | RawTextDisplay | RawMediaGallery | RawFile | RawSeparator | RawContainer>): Array<ActionRow | Section | TextDisplay | MediaGallery | File | Separator | Container>;
7
+ static componentsToRaw(components: Array<ActionRow | Section | TextDisplay | MediaGallery | File | Separator | Container>): Array<RawActionRow | RawSection | RawTextDisplay | 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,40 @@ 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
- case constants_1.ComponentTypes.TextDisplay: {
56
+ case constants_1.ComponentTypes.Section:
57
+ return Components_js_1.Components.sectionFromRaw(component);
58
+ case constants_1.ComponentTypes.TextDisplay:
58
59
  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: {
60
+ case constants_1.ComponentTypes.MediaGallery:
61
+ return Components_js_1.Components.mediaGalleryFromRaw(component);
62
+ case constants_1.ComponentTypes.File:
64
63
  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: {
64
+ case constants_1.ComponentTypes.Separator:
70
65
  return Components_js_1.Components.separatorFromRaw(component);
71
- }
72
- case constants_1.ComponentTypes.MediaGallery: {
73
- return Components_js_1.Components.mediaGalleryFromRaw(component);
74
- }
66
+ case constants_1.ComponentTypes.Container:
67
+ return Components_js_1.Components.containerFromRaw(component);
75
68
  }
76
69
  });
77
70
  }
78
71
  static componentsToRaw(components) {
79
72
  return components.map((component) => {
80
73
  switch (component.type) {
81
- case constants_1.ComponentTypes.ActionRow: {
74
+ case constants_1.ComponentTypes.ActionRow:
82
75
  return Components_js_1.Components.actionRowToRaw(component);
83
- }
84
- case constants_1.ComponentTypes.TextDisplay: {
76
+ case constants_1.ComponentTypes.Section:
77
+ return Components_js_1.Components.sectionToRaw(component);
78
+ case constants_1.ComponentTypes.TextDisplay:
85
79
  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: {
80
+ case constants_1.ComponentTypes.MediaGallery:
81
+ return Components_js_1.Components.mediaGalleryToRaw(component);
82
+ case constants_1.ComponentTypes.File:
91
83
  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: {
84
+ case constants_1.ComponentTypes.Separator:
97
85
  return Components_js_1.Components.separatorToRaw(component);
98
- }
99
- case constants_1.ComponentTypes.MediaGallery: {
100
- return Components_js_1.Components.mediaGalleryToRaw(component);
101
- }
86
+ case constants_1.ComponentTypes.Container:
87
+ return Components_js_1.Components.containerToRaw(component);
102
88
  }
103
89
  });
104
90
  }
@@ -10,7 +10,7 @@ class Roles {
10
10
  colors: {
11
11
  primaryColor: role.colors.primary_color,
12
12
  secondaryColor: role.colors.secondary_color,
13
- tertiaryColors: role.colors.tertiary_colors,
13
+ tertiaryColor: role.colors.tertiary_color,
14
14
  },
15
15
  hoist: role.hoist,
16
16
  icon: role.icon,
@@ -40,7 +40,7 @@ class Roles {
40
40
  colors: {
41
41
  primary_color: role.colors.primaryColor,
42
42
  secondary_color: role.colors.secondaryColor,
43
- tertiary_colors: role.colors.tertiaryColors,
43
+ tertiary_color: role.colors.tertiaryColor,
44
44
  },
45
45
  hoist: role.hoist,
46
46
  icon: role.icon,
@@ -4,7 +4,7 @@ export * from "./Applications";
4
4
  export * from "./AuditLogs";
5
5
  export * from "./AutoModeration";
6
6
  export * from "./Channels";
7
- export * from "./Components.js";
7
+ export * from "./Components";
8
8
  export * from "./Emojis";
9
9
  export * from "./Entitlements";
10
10
  export * from "./Guilds";
@@ -12,6 +12,7 @@ export * from "./GuildScheduledEvents";
12
12
  export * from "./GuildTemplates";
13
13
  export * from "./Interactions";
14
14
  export * from "./Invites";
15
+ export * from "./Lobbies";
15
16
  export * from "./Messages";
16
17
  export * from "./Polls";
17
18
  export * from "./Presences";
@@ -20,7 +20,7 @@ __exportStar(require("./Applications"), exports);
20
20
  __exportStar(require("./AuditLogs"), exports);
21
21
  __exportStar(require("./AutoModeration"), exports);
22
22
  __exportStar(require("./Channels"), exports);
23
- __exportStar(require("./Components.js"), exports);
23
+ __exportStar(require("./Components"), exports);
24
24
  __exportStar(require("./Emojis"), exports);
25
25
  __exportStar(require("./Entitlements"), exports);
26
26
  __exportStar(require("./Guilds"), exports);
@@ -28,6 +28,7 @@ __exportStar(require("./GuildScheduledEvents"), exports);
28
28
  __exportStar(require("./GuildTemplates"), exports);
29
29
  __exportStar(require("./Interactions"), exports);
30
30
  __exportStar(require("./Invites"), exports);
31
+ __exportStar(require("./Lobbies"), exports);
31
32
  __exportStar(require("./Messages"), exports);
32
33
  __exportStar(require("./Polls"), exports);
33
34
  __exportStar(require("./Presences"), exports);