disgroove 3.0.0-dev.72bf12 → 3.0.0-dev.7dc321a

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,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
  }