disgroove 3.0.0-dev.32616ef → 3.0.0-dev.474d332

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,22 @@
1
+ import WebSocket from "ws";
2
+ import { GatewayOPCodes } from "../constants";
3
+ import type { GatewayPresenceUpdate, GatewayVoiceStateUpdate, Identify, RequestGuildMembers, RequestSoundboardSounds, Resume } from "../types/gateway-events";
4
+ export declare class Transmitter {
5
+ private ws;
6
+ constructor(ws: WebSocket | null);
7
+ send(op: GatewayOPCodes, data: unknown): void;
8
+ /** https://discord.com/developers/docs/topics/gateway-events#heartbeat */
9
+ heartbeat(lastSequence: number | null): void;
10
+ /** https://discord.com/developers/docs/topics/gateway-events#identify */
11
+ identify(options: Identify): void;
12
+ /** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
13
+ requestGuildMembers(options: RequestGuildMembers): void;
14
+ /** https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds */
15
+ requestSoundboardSounds(options: RequestSoundboardSounds): void;
16
+ /** https://discord.com/developers/docs/topics/gateway-events#resume */
17
+ resume(options: Resume): void;
18
+ /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
19
+ updatePresence(options: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>): void;
20
+ /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
21
+ updateVoiceState(options: GatewayVoiceStateUpdate): void;
22
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Transmitter = void 0;
7
+ const ws_1 = __importDefault(require("ws"));
8
+ const constants_1 = require("../constants");
9
+ class Transmitter {
10
+ ws;
11
+ constructor(ws) {
12
+ this.ws = ws;
13
+ }
14
+ send(op, data) {
15
+ if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
16
+ this.ws.send(JSON.stringify({
17
+ op,
18
+ d: data,
19
+ }));
20
+ }
21
+ }
22
+ /** https://discord.com/developers/docs/topics/gateway-events#heartbeat */
23
+ heartbeat(lastSequence) {
24
+ this.send(constants_1.GatewayOPCodes.Heartbeat, lastSequence);
25
+ }
26
+ /** https://discord.com/developers/docs/topics/gateway-events#identify */
27
+ identify(options) {
28
+ this.send(constants_1.GatewayOPCodes.Identify, {
29
+ token: options.token,
30
+ properties: {
31
+ os: options.properties.os,
32
+ browser: options.properties.browser,
33
+ device: options.properties.device,
34
+ },
35
+ compress: options.compress,
36
+ large_threshold: options.largeThreshold,
37
+ shard: options.shard,
38
+ presence: options.presence,
39
+ intents: options.intents,
40
+ });
41
+ }
42
+ /** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
43
+ requestGuildMembers(options) {
44
+ this.send(constants_1.GatewayOPCodes.RequestGuildMembers, {
45
+ guild_id: options.guildId,
46
+ query: options.query,
47
+ limit: options.limit,
48
+ presences: options.presences,
49
+ user_ids: options.userIds,
50
+ nonce: options.nonce,
51
+ });
52
+ }
53
+ /** https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds */
54
+ requestSoundboardSounds(options) {
55
+ this.send(constants_1.GatewayOPCodes.RequestSoundboardSounds, {
56
+ guild_ids: options.guildIds,
57
+ });
58
+ }
59
+ /** https://discord.com/developers/docs/topics/gateway-events#resume */
60
+ resume(options) {
61
+ this.send(constants_1.GatewayOPCodes.Resume, {
62
+ token: options.token,
63
+ session_id: options.sessionId,
64
+ seq: options.seq,
65
+ });
66
+ }
67
+ /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
68
+ updatePresence(options) {
69
+ this.send(constants_1.GatewayOPCodes.PresenceUpdate, {
70
+ since: options.status === constants_1.StatusTypes.Idle ? Date.now() : null,
71
+ activities: options.activities?.map((activity) => ({
72
+ name: activity.type === constants_1.ActivityType.Custom
73
+ ? "Custom Status"
74
+ : activity.name,
75
+ type: activity.type,
76
+ url: activity.url,
77
+ state: activity.state,
78
+ })),
79
+ status: options.status ?? constants_1.StatusTypes.Online,
80
+ afk: !!options.afk,
81
+ });
82
+ }
83
+ /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
84
+ updateVoiceState(options) {
85
+ this.send(constants_1.GatewayOPCodes.VoiceStateUpdate, {
86
+ guild_id: options.guildId,
87
+ channel_id: options.channelId,
88
+ self_mute: options.selfMute,
89
+ self_deaf: options.selfDeaf,
90
+ });
91
+ }
92
+ }
93
+ exports.Transmitter = Transmitter;
@@ -0,0 +1,22 @@
1
+ import WebSocket from "ws";
2
+ import { GatewayOPCodes } from "../constants";
3
+ import { GatewayPresenceUpdate, GatewayVoiceStateUpdate, Identify, RequestGuildMembers, RequestSoundboardSounds, Resume } from "../types/gateway-events";
4
+ export declare class WebSocketManager {
5
+ private ws;
6
+ constructor(ws: WebSocket | null);
7
+ send(op: GatewayOPCodes, data: unknown): void;
8
+ /** https://discord.com/developers/docs/topics/gateway-events#heartbeat */
9
+ heartbeat(lastSequence: number | null): void;
10
+ /** https://discord.com/developers/docs/topics/gateway-events#identify */
11
+ identify(options: Identify): void;
12
+ /** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
13
+ requestGuildMembers(options: RequestGuildMembers): void;
14
+ /** https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds */
15
+ requestSoundboardSounds(options: RequestSoundboardSounds): void;
16
+ /** https://discord.com/developers/docs/topics/gateway-events#resume */
17
+ resume(options: Resume): void;
18
+ /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
19
+ updatePresence(options: Partial<Pick<GatewayPresenceUpdate, "activities" | "status" | "afk">>): void;
20
+ /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
21
+ updateVoiceState(options: GatewayVoiceStateUpdate): void;
22
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WebSocketManager = void 0;
7
+ const ws_1 = __importDefault(require("ws"));
8
+ const constants_1 = require("../constants");
9
+ class WebSocketManager {
10
+ ws;
11
+ constructor(ws) {
12
+ this.ws = ws;
13
+ }
14
+ send(op, data) {
15
+ if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
16
+ this.ws.send(JSON.stringify({
17
+ op,
18
+ d: data,
19
+ }));
20
+ }
21
+ }
22
+ /** https://discord.com/developers/docs/topics/gateway-events#heartbeat */
23
+ heartbeat(lastSequence) {
24
+ this.send(constants_1.GatewayOPCodes.Heartbeat, lastSequence);
25
+ }
26
+ /** https://discord.com/developers/docs/topics/gateway-events#identify */
27
+ identify(options) {
28
+ this.send(constants_1.GatewayOPCodes.Identify, {
29
+ token: options.token,
30
+ properties: {
31
+ os: options.properties.os,
32
+ browser: options.properties.browser,
33
+ device: options.properties.device,
34
+ },
35
+ compress: options.compress,
36
+ large_threshold: options.largeThreshold,
37
+ shard: options.shard,
38
+ presence: options.presence,
39
+ intents: options.intents,
40
+ });
41
+ }
42
+ /** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
43
+ requestGuildMembers(options) {
44
+ this.send(constants_1.GatewayOPCodes.RequestGuildMembers, {
45
+ guild_id: options.guildId,
46
+ query: options.query,
47
+ limit: options.limit,
48
+ presences: options.presences,
49
+ user_ids: options.userIds,
50
+ nonce: options.nonce,
51
+ });
52
+ }
53
+ /** https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds */
54
+ requestSoundboardSounds(options) {
55
+ this.send(constants_1.GatewayOPCodes.RequestSoundboardSounds, {
56
+ guild_ids: options.guildIds,
57
+ });
58
+ }
59
+ /** https://discord.com/developers/docs/topics/gateway-events#resume */
60
+ resume(options) {
61
+ this.send(constants_1.GatewayOPCodes.Resume, {
62
+ token: options.token,
63
+ session_id: options.sessionId,
64
+ seq: options.seq,
65
+ });
66
+ }
67
+ /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
68
+ updatePresence(options) {
69
+ this.send(constants_1.GatewayOPCodes.PresenceUpdate, {
70
+ since: options.status === constants_1.StatusTypes.Idle ? Date.now() : null,
71
+ activities: options.activities?.map((activity) => ({
72
+ name: activity.type === constants_1.ActivityType.Custom
73
+ ? "Custom Status"
74
+ : activity.name,
75
+ type: activity.type,
76
+ url: activity.url,
77
+ state: activity.state,
78
+ })),
79
+ status: options.status ?? constants_1.StatusTypes.Online,
80
+ afk: !!options.afk,
81
+ });
82
+ }
83
+ /** https://discord.com/developers/docs/topics/gateway-events#update-voice-state */
84
+ updateVoiceState(options) {
85
+ this.send(constants_1.GatewayOPCodes.VoiceStateUpdate, {
86
+ guild_id: options.guildId,
87
+ channel_id: options.channelId,
88
+ self_mute: options.selfMute,
89
+ self_deaf: options.selfDeaf,
90
+ });
91
+ }
92
+ }
93
+ exports.WebSocketManager = WebSocketManager;
@@ -1,4 +1,4 @@
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/components";
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, RawFileUpload, FileUpload } from "../types/components";
2
2
  export declare class Components {
3
3
  static actionRowFromRaw(actionRow: RawActionRow): ActionRow;
4
4
  static actionRowToRaw(actionRow: ActionRow): RawActionRow;
@@ -10,6 +10,8 @@ export declare class Components {
10
10
  static containerToRaw(container: Container): RawContainer;
11
11
  static fileFromRaw(file: RawFile): File;
12
12
  static fileToRaw(file: File): RawFile;
13
+ static fileUploadFromRaw(fileUpload: RawFileUpload): FileUpload;
14
+ static fileUploadToRaw(fileUpload: FileUpload): RawFileUpload;
13
15
  static labelFromRaw(label: RawLabel): Label;
14
16
  static labelToRaw(label: Label): RawLabel;
15
17
  static mediaGalleryFromRaw(mediaGallery: RawMediaGallery): MediaGallery;
@@ -183,6 +183,26 @@ class Components {
183
183
  size: file.size,
184
184
  };
185
185
  }
186
+ static fileUploadFromRaw(fileUpload) {
187
+ return {
188
+ type: fileUpload.type,
189
+ id: fileUpload.id,
190
+ customId: fileUpload.custom_id,
191
+ minValues: fileUpload.min_values,
192
+ maxValues: fileUpload.max_values,
193
+ required: fileUpload.required,
194
+ };
195
+ }
196
+ static fileUploadToRaw(fileUpload) {
197
+ return {
198
+ type: fileUpload.type,
199
+ id: fileUpload.id,
200
+ custom_id: fileUpload.customId,
201
+ min_values: fileUpload.minValues,
202
+ max_values: fileUpload.maxValues,
203
+ required: fileUpload.required,
204
+ };
205
+ }
186
206
  static labelFromRaw(label) {
187
207
  let component;
188
208
  switch (label.component.type) {
@@ -204,6 +224,9 @@ class Components {
204
224
  case constants_1.ComponentTypes.ChannelSelect:
205
225
  component = Components.channelSelectFromRaw(label.component);
206
226
  break;
227
+ case constants_1.ComponentTypes.FileUpload:
228
+ component = Components.fileUploadFromRaw(label.component);
229
+ break;
207
230
  }
208
231
  return {
209
232
  type: label.type,
@@ -234,6 +257,9 @@ class Components {
234
257
  case constants_1.ComponentTypes.ChannelSelect:
235
258
  component = Components.channelSelectToRaw(label.component);
236
259
  break;
260
+ case constants_1.ComponentTypes.FileUpload:
261
+ component = Components.fileUploadToRaw(label.component);
262
+ break;
237
263
  }
238
264
  return {
239
265
  type: label.type,
@@ -128,6 +128,13 @@ class Interactions {
128
128
  resolved: this.resolvedDataFromRaw(c.resolved),
129
129
  values: c.values,
130
130
  };
131
+ case constants_1.ComponentTypes.FileUpload:
132
+ return {
133
+ type: c.type,
134
+ id: c.id,
135
+ customId: c.custom_id,
136
+ values: c.values,
137
+ };
131
138
  }
132
139
  }),
133
140
  };
@@ -196,6 +203,14 @@ class Interactions {
196
203
  values: component.component.values,
197
204
  };
198
205
  break;
206
+ case constants_1.ComponentTypes.FileUpload:
207
+ c = {
208
+ type: component.component.type,
209
+ id: component.component.id,
210
+ customId: component.component.custom_id,
211
+ values: component.component.values,
212
+ };
213
+ break;
199
214
  }
200
215
  return {
201
216
  type: component.type,
@@ -351,6 +366,13 @@ class Interactions {
351
366
  resolved: this.resolvedDataToRaw(c.resolved),
352
367
  values: c.values,
353
368
  };
369
+ case constants_1.ComponentTypes.FileUpload:
370
+ return {
371
+ type: c.type,
372
+ id: c.id,
373
+ custom_id: c.customId,
374
+ values: c.values,
375
+ };
354
376
  }
355
377
  }),
356
378
  };
@@ -419,6 +441,14 @@ class Interactions {
419
441
  values: component.component.values,
420
442
  };
421
443
  break;
444
+ case constants_1.ComponentTypes.FileUpload:
445
+ c = {
446
+ type: component.component.type,
447
+ id: component.component.id,
448
+ custom_id: component.component.customId,
449
+ values: component.component.values,
450
+ };
451
+ break;
422
452
  }
423
453
  return {
424
454
  type: component.type,
@@ -1,5 +1,5 @@
1
- import type { RawPresenceUpdateEventFields, PresenceUpdateEventFields } from "../types/gateway-events";
1
+ import type { RawPresenceUpdateEvent, PresenceUpdateEvent } from "../types/gateway-events";
2
2
  export declare class Presences {
3
- static presenceFromRaw(presence: RawPresenceUpdateEventFields): PresenceUpdateEventFields;
4
- static presenceToRaw(presence: PresenceUpdateEventFields): RawPresenceUpdateEventFields;
3
+ static presenceFromRaw(presence: RawPresenceUpdateEvent): PresenceUpdateEvent;
4
+ static presenceToRaw(presence: PresenceUpdateEvent): RawPresenceUpdateEvent;
5
5
  }
@@ -222,13 +222,29 @@ export interface RawLabel {
222
222
  id?: number;
223
223
  label: string;
224
224
  description?: string;
225
- component: RawTextInput | RawStringSelect | RawUserSelect | RawRoleSelect | RawMentionableSelect | RawChannelSelect;
225
+ component: RawTextInput | RawStringSelect | RawUserSelect | RawRoleSelect | RawMentionableSelect | RawChannelSelect | RawFileUpload;
226
226
  }
227
227
  /** https://discord.com/developers/docs/components/reference#label-label-interaction-response-structure */
228
228
  export interface RawLabelInteractionResponse {
229
229
  type: ComponentTypes.Label;
230
230
  id: number;
231
- component: RawTextInputInteractionResponse | RawStringSelectInteractionResponse | RawUserSelectInteractionResponse | RawRoleSelectInteractionResponse | RawMentionableSelectInteractionResponse | RawChannelSelectInteractionResponse;
231
+ component: RawTextInputInteractionResponse | RawStringSelectInteractionResponse | RawUserSelectInteractionResponse | RawRoleSelectInteractionResponse | RawMentionableSelectInteractionResponse | RawChannelSelectInteractionResponse | RawFileUploadInteractionResponse;
232
+ }
233
+ /** https://discord.com/developers/docs/components/reference#file-upload-file-upload-structure */
234
+ export interface RawFileUpload {
235
+ type: ComponentTypes.FileUpload;
236
+ id?: number;
237
+ custom_id: string;
238
+ min_values?: number;
239
+ max_values?: number;
240
+ required?: boolean;
241
+ }
242
+ /** https://discord.com/developers/docs/components/reference#file-upload-file-upload-interaction-response-structure */
243
+ export interface RawFileUploadInteractionResponse {
244
+ type: ComponentTypes.FileUpload;
245
+ id: number;
246
+ custom_id: string;
247
+ values: Array<snowflake>;
232
248
  }
233
249
  /** https://discord.com/developers/docs/components/reference#unfurled-media-item-unfurled-media-item-structure */
234
250
  export interface RawUnfurledMediaItem {
@@ -459,13 +475,29 @@ export interface Label {
459
475
  id?: number;
460
476
  label: string;
461
477
  description?: string;
462
- component: TextInput | StringSelect | UserSelect | RoleSelect | MentionableSelect | ChannelSelect;
478
+ component: TextInput | StringSelect | UserSelect | RoleSelect | MentionableSelect | ChannelSelect | FileUpload;
463
479
  }
464
480
  /** https://discord.com/developers/docs/components/reference#label-label-interaction-response-structure */
465
481
  export interface LabelInteractionResponse {
466
482
  type: ComponentTypes.Label;
467
483
  id: number;
468
- component: TextInputInteractionResponse | StringSelectInteractionResponse | UserSelectInteractionResponse | RoleSelectInteractionResponse | MentionableSelectInteractionResponse | ChannelSelectInteractionResponse;
484
+ component: TextInputInteractionResponse | StringSelectInteractionResponse | UserSelectInteractionResponse | RoleSelectInteractionResponse | MentionableSelectInteractionResponse | ChannelSelectInteractionResponse | FileUploadInteractionResponse;
485
+ }
486
+ /** https://discord.com/developers/docs/components/reference#file-upload-file-upload-structure */
487
+ export interface FileUpload {
488
+ type: ComponentTypes.FileUpload;
489
+ id?: number;
490
+ customId: string;
491
+ minValues?: number;
492
+ maxValues?: number;
493
+ required?: boolean;
494
+ }
495
+ /** https://discord.com/developers/docs/components/reference#file-upload-file-upload-interaction-response-structure */
496
+ export interface FileUploadInteractionResponse {
497
+ type: ComponentTypes.FileUpload;
498
+ id: number;
499
+ customId: string;
500
+ values: Array<snowflake>;
469
501
  }
470
502
  /** https://discord.com/developers/docs/components/reference#unfurled-media-item-unfurled-media-item-structure */
471
503
  export interface UnfurledMediaItem {