disgroove 2.2.2-dev.23938d8 → 2.2.2-dev.90b732e
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.
- package/README.md +4 -2
- package/dist/lib/Client.d.ts +62 -56
- package/dist/lib/Client.js +186 -185
- package/dist/lib/constants.d.ts +83 -72
- package/dist/lib/constants.js +86 -73
- package/dist/lib/gateway/Shard.d.ts +1 -1
- package/dist/lib/gateway/Shard.js +198 -175
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/rest/Endpoints.d.ts +1 -1
- package/dist/lib/rest/Endpoints.js +3 -3
- package/dist/lib/rest/RequestManager.d.ts +1 -1
- package/dist/lib/rest/RequestManager.js +1 -1
- package/dist/lib/rest/index.d.ts +0 -1
- package/dist/lib/rest/index.js +1 -2
- package/dist/lib/transformers/Applications.d.ts +8 -0
- package/dist/lib/transformers/Applications.js +211 -0
- package/dist/lib/transformers/AuditLogs.d.ts +7 -0
- package/dist/lib/transformers/AuditLogs.js +97 -0
- package/dist/lib/transformers/AutoModeration.d.ts +5 -0
- package/dist/lib/transformers/AutoModeration.js +64 -0
- package/dist/lib/transformers/Channels.d.ts +16 -0
- package/dist/lib/transformers/Channels.js +676 -0
- package/dist/lib/transformers/Emojis.d.ts +5 -0
- package/dist/lib/transformers/Emojis.js +31 -0
- package/dist/lib/transformers/Entitlements.d.ts +7 -0
- package/dist/lib/transformers/Entitlements.js +58 -0
- package/dist/lib/transformers/GuildScheduledEvents.d.ts +5 -0
- package/dist/lib/transformers/GuildScheduledEvents.js +51 -0
- package/dist/lib/transformers/GuildTemplates.d.ts +5 -0
- package/dist/lib/transformers/GuildTemplates.js +38 -0
- package/dist/lib/transformers/Guilds.d.ts +12 -0
- package/dist/lib/transformers/Guilds.js +248 -0
- package/dist/lib/transformers/Interactions.d.ts +10 -0
- package/dist/lib/transformers/Interactions.js +273 -0
- package/dist/lib/transformers/Invites.d.ts +5 -0
- package/dist/lib/transformers/Invites.js +79 -0
- package/dist/lib/transformers/Polls.d.ts +5 -0
- package/dist/lib/transformers/Polls.js +50 -0
- package/dist/lib/transformers/Presences.d.ts +8 -0
- package/dist/lib/transformers/Presences.js +108 -0
- package/dist/lib/transformers/Roles.d.ts +5 -0
- package/dist/lib/transformers/Roles.js +56 -0
- package/dist/lib/transformers/SKUs.d.ts +5 -0
- package/dist/lib/transformers/SKUs.js +26 -0
- package/dist/lib/transformers/StageInstances.d.ts +5 -0
- package/dist/lib/transformers/StageInstances.js +28 -0
- package/dist/lib/transformers/Stickers.d.ts +5 -0
- package/dist/lib/transformers/Stickers.js +41 -0
- package/dist/lib/transformers/Teams.d.ts +5 -0
- package/dist/lib/transformers/Teams.js +35 -0
- package/dist/lib/transformers/Users.d.ts +5 -0
- package/dist/lib/transformers/Users.js +48 -0
- package/dist/lib/transformers/Voice.d.ts +5 -0
- package/dist/lib/transformers/Voice.js +45 -0
- package/dist/lib/transformers/Webhooks.d.ts +5 -0
- package/dist/lib/transformers/Webhooks.js +51 -0
- package/dist/lib/transformers/index.d.ts +21 -0
- package/dist/lib/transformers/index.js +37 -0
- package/dist/lib/types/entitlements.d.ts +0 -6
- package/dist/lib/types/gateway-events.d.ts +21 -8
- package/dist/lib/types/interaction.d.ts +1 -1
- package/dist/lib/types/sku.d.ts +0 -12
- package/dist/lib/utils/Util.d.ts +1 -91
- package/dist/lib/utils/Util.js +2 -2167
- package/dist/lib/utils/errors.d.ts +3 -3
- package/dist/lib/utils/errors.js +6 -8
- package/dist/lib/utils/formatters.d.ts +9 -0
- package/dist/lib/utils/formatters.js +38 -0
- package/dist/lib/utils/index.d.ts +2 -0
- package/dist/lib/utils/index.js +15 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/lib/types/voice-connections.d.ts +0 -64
- package/dist/lib/types/voice-connections.js +0 -2
- package/dist/lib/voice/VoiceConnection.d.ts +0 -57
- package/dist/lib/voice/VoiceConnection.js +0 -150
- package/dist/lib/voice/VoiceConnectionManager.d.ts +0 -19
- package/dist/lib/voice/VoiceConnectionManager.js +0 -66
- package/dist/lib/voice/index.d.ts +0 -2
- package/dist/lib/voice/index.js +0 -18
- /package/dist/lib/{rest → utils}/CDN.d.ts +0 -0
- /package/dist/lib/{rest → utils}/CDN.js +0 -0
@@ -4,15 +4,15 @@ export declare class RESTError extends Error {
|
|
4
4
|
method: string;
|
5
5
|
endpoint: string;
|
6
6
|
constructor(code: JSONErrorCodes, message: string, errors: Record<string, unknown>, method: string, endpoint: string);
|
7
|
-
flattenErrors(errors: Record<string, unknown> | undefined, prefix?: string): string;
|
7
|
+
static flattenErrors(errors: Record<string, unknown> | undefined, prefix?: string): string;
|
8
8
|
}
|
9
9
|
export declare class HTTPError extends Error {
|
10
10
|
name: string;
|
11
11
|
method: string;
|
12
12
|
endpoint: string;
|
13
|
-
constructor(status: number, statusText: string, method: string, endpoint: string);
|
13
|
+
constructor(status: number, statusText: string, errors: Record<string, unknown>, method: string, endpoint: string);
|
14
14
|
}
|
15
15
|
export declare class GatewayError extends Error {
|
16
16
|
name: string;
|
17
|
-
constructor(
|
17
|
+
constructor(code: number, reason: string);
|
18
18
|
}
|
package/dist/lib/utils/errors.js
CHANGED
@@ -6,12 +6,11 @@ class RESTError extends Error {
|
|
6
6
|
method;
|
7
7
|
endpoint;
|
8
8
|
constructor(code, message, errors, method, endpoint) {
|
9
|
-
super();
|
9
|
+
super(`[${code}] ${message}\n${RESTError.flattenErrors(errors)}`);
|
10
10
|
this.method = method;
|
11
11
|
this.endpoint = endpoint;
|
12
|
-
this.message = `[${code}] ${message}\n${this.flattenErrors(errors)}`;
|
13
12
|
}
|
14
|
-
flattenErrors(errors, prefix = "") {
|
13
|
+
static flattenErrors(errors, prefix = "") {
|
15
14
|
let result = "";
|
16
15
|
if (errors) {
|
17
16
|
for (const [key, value] of Object.entries(errors)) {
|
@@ -39,18 +38,17 @@ class HTTPError extends Error {
|
|
39
38
|
name = "HTTPError";
|
40
39
|
method;
|
41
40
|
endpoint;
|
42
|
-
constructor(status, statusText, method, endpoint) {
|
43
|
-
super();
|
41
|
+
constructor(status, statusText, errors, method, endpoint) {
|
42
|
+
super(`[${status}] ${statusText}\n${RESTError.flattenErrors(errors)}`);
|
44
43
|
this.method = method;
|
45
44
|
this.endpoint = endpoint;
|
46
|
-
this.message = `[${status}] ${statusText}`;
|
47
45
|
}
|
48
46
|
}
|
49
47
|
exports.HTTPError = HTTPError;
|
50
48
|
class GatewayError extends Error {
|
51
49
|
name = "GatewayError";
|
52
|
-
constructor(
|
53
|
-
super(
|
50
|
+
constructor(code, reason) {
|
51
|
+
super(`[${code}] ${reason}`);
|
54
52
|
}
|
55
53
|
}
|
56
54
|
exports.GatewayError = GatewayError;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { GuildNavigationTypes, TimestampStyles } from "../constants";
|
2
|
+
import type { snowflake } from "../types/common";
|
3
|
+
export declare function userMention(userID: snowflake): string;
|
4
|
+
export declare function channelMention(channelID: snowflake): string;
|
5
|
+
export declare function roleMention(roleID: snowflake): string;
|
6
|
+
export declare function slashCommandMention(commandName: string, commandID: snowflake, subCommandName: string, subCommandGroupName: string): string;
|
7
|
+
export declare function customEmoji(emojiName: string, emojiID: snowflake, animated?: boolean): string;
|
8
|
+
export declare function unixTimestamp(time: number, style?: TimestampStyles): string;
|
9
|
+
export declare function guildNavigation(guildID: snowflake, type: GuildNavigationTypes): string;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* https://discord.com/developers/docs/reference#message-formatting */
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.guildNavigation = exports.unixTimestamp = exports.customEmoji = exports.slashCommandMention = exports.roleMention = exports.channelMention = exports.userMention = void 0;
|
5
|
+
function userMention(userID) {
|
6
|
+
return `<@${userID}>`;
|
7
|
+
}
|
8
|
+
exports.userMention = userMention;
|
9
|
+
function channelMention(channelID) {
|
10
|
+
return `<#${channelID}>`;
|
11
|
+
}
|
12
|
+
exports.channelMention = channelMention;
|
13
|
+
function roleMention(roleID) {
|
14
|
+
return `<@&${roleID}>`;
|
15
|
+
}
|
16
|
+
exports.roleMention = roleMention;
|
17
|
+
function slashCommandMention(commandName, commandID, subCommandName, subCommandGroupName) {
|
18
|
+
return subCommandName
|
19
|
+
? subCommandGroupName
|
20
|
+
? `</${commandName} ${subCommandGroupName} ${subCommandName}:${commandID}>`
|
21
|
+
: `</${commandName} ${subCommandName}:${commandID}>`
|
22
|
+
: `</${commandName}:${commandID}>`;
|
23
|
+
}
|
24
|
+
exports.slashCommandMention = slashCommandMention;
|
25
|
+
function customEmoji(emojiName, emojiID, animated) {
|
26
|
+
return animated
|
27
|
+
? `<a:${emojiName}:${emojiID}>`
|
28
|
+
: `<:${emojiName}:${emojiID}>`;
|
29
|
+
}
|
30
|
+
exports.customEmoji = customEmoji;
|
31
|
+
function unixTimestamp(time, style) {
|
32
|
+
return style ? `<t:${time}:${style}>` : `<t:${time}>`;
|
33
|
+
}
|
34
|
+
exports.unixTimestamp = unixTimestamp;
|
35
|
+
function guildNavigation(guildID, type) {
|
36
|
+
return `<${guildID}:${type}>`;
|
37
|
+
}
|
38
|
+
exports.guildNavigation = guildNavigation;
|
package/dist/lib/utils/index.js
CHANGED
@@ -10,9 +10,24 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
11
11
|
o[k2] = m[k];
|
12
12
|
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
27
|
};
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.CDN = void 0;
|
30
|
+
exports.CDN = __importStar(require("./CDN"));
|
17
31
|
__exportStar(require("./errors"), exports);
|
32
|
+
__exportStar(require("./formatters"), exports);
|
18
33
|
__exportStar(require("./Util"), exports);
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
@@ -1,64 +0,0 @@
|
|
1
|
-
import type { snowflake } from "./common";
|
2
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
3
|
-
export interface RawVoiceIdentifyPayload {
|
4
|
-
server_id: snowflake;
|
5
|
-
user_id: snowflake;
|
6
|
-
session_id: string;
|
7
|
-
token: string;
|
8
|
-
}
|
9
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload */
|
10
|
-
export interface RawVoiceReadyPayload {
|
11
|
-
ssrc: number;
|
12
|
-
ip: string;
|
13
|
-
port: number;
|
14
|
-
modes: Array<string>;
|
15
|
-
}
|
16
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection-example-resume-connection-payload */
|
17
|
-
export interface RawResumeConnectionPayload {
|
18
|
-
server_id: snowflake;
|
19
|
-
session_id: string;
|
20
|
-
token: string;
|
21
|
-
}
|
22
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload */
|
23
|
-
export interface RawSelectProtocolPayload {
|
24
|
-
protocol: string;
|
25
|
-
data: {
|
26
|
-
address: string;
|
27
|
-
port: number;
|
28
|
-
mode: string;
|
29
|
-
};
|
30
|
-
}
|
31
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-session-description-payload */
|
32
|
-
export interface RawSessionDescriptionPayload {
|
33
|
-
mode: string;
|
34
|
-
secret_key: Array<number>;
|
35
|
-
}
|
36
|
-
export interface VoiceIdentifyPayload {
|
37
|
-
serverID: snowflake;
|
38
|
-
userID: snowflake;
|
39
|
-
sessionID: string;
|
40
|
-
token: string;
|
41
|
-
}
|
42
|
-
export interface VoiceReadyPayload {
|
43
|
-
ssrc: number;
|
44
|
-
ip: string;
|
45
|
-
port: number;
|
46
|
-
modes: Array<string>;
|
47
|
-
}
|
48
|
-
export interface ResumeConnectionPayload {
|
49
|
-
serverID: snowflake;
|
50
|
-
sessionID: string;
|
51
|
-
token: string;
|
52
|
-
}
|
53
|
-
export interface SelectProtocolPayload {
|
54
|
-
protocol: string;
|
55
|
-
data: {
|
56
|
-
address: string;
|
57
|
-
port: number;
|
58
|
-
mode: string;
|
59
|
-
};
|
60
|
-
}
|
61
|
-
export interface SessionDescriptionPayload {
|
62
|
-
mode: string;
|
63
|
-
secretKey: Array<number>;
|
64
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import WebSocket from "ws";
|
3
|
-
import type { snowflake } from "../types/common";
|
4
|
-
import EventEmitter from "node:events";
|
5
|
-
import type { ResumeConnectionPayload, SelectProtocolPayload, SessionDescriptionPayload, VoiceIdentifyPayload, VoiceReadyPayload } from "../types/voice-connections";
|
6
|
-
export declare class VoiceConnection extends EventEmitter {
|
7
|
-
ws: WebSocket;
|
8
|
-
endpoint: string;
|
9
|
-
serverID: snowflake;
|
10
|
-
userID: snowflake;
|
11
|
-
sessionID: string;
|
12
|
-
token: string;
|
13
|
-
private heartbeatInterval;
|
14
|
-
ssrc: number;
|
15
|
-
constructor(endpoint: string, options: VoiceIdentifyPayload);
|
16
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
17
|
-
connect(): void;
|
18
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
19
|
-
disconnect(): void;
|
20
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
21
|
-
heartbeat(): void;
|
22
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
23
|
-
identify(options: VoiceIdentifyPayload): void;
|
24
|
-
private onWebSocketOpen;
|
25
|
-
private onWebSocketMessage;
|
26
|
-
private onWebSocketError;
|
27
|
-
private onWebSocketClose;
|
28
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
29
|
-
resume(options: ResumeConnectionPayload): void;
|
30
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
31
|
-
selectProtocol(options: SelectProtocolPayload): void;
|
32
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
33
|
-
speaking(speaking: number): void;
|
34
|
-
}
|
35
|
-
export declare interface VoiceConnection extends EventEmitter {
|
36
|
-
addListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
37
|
-
emit<K extends keyof VoiceConnectionEvents>(eventName: K, ...args: VoiceConnectionEvents[K]): boolean;
|
38
|
-
listenerCount(eventName: keyof VoiceConnectionEvents): number;
|
39
|
-
listeners(eventName: keyof VoiceConnectionEvents): Array<Function>;
|
40
|
-
off<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
41
|
-
on<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
42
|
-
once<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
43
|
-
prependListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
44
|
-
prependOnceListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
45
|
-
rawListeners(eventName: keyof VoiceConnectionEvents): Array<Function>;
|
46
|
-
removeAllListeners(event?: keyof VoiceConnectionEvents): this;
|
47
|
-
removeListener<K extends keyof VoiceConnectionEvents>(eventName: K, listener: (...args: VoiceConnectionEvents[K]) => void): this;
|
48
|
-
}
|
49
|
-
export interface VoiceConnectionEvents {
|
50
|
-
ready: [voiceServer: VoiceReadyPayload];
|
51
|
-
sessionDescription: [session: SessionDescriptionPayload];
|
52
|
-
speaking: [speaking: number];
|
53
|
-
heartbeatACK: [heartbeat: number];
|
54
|
-
hello: [];
|
55
|
-
resumed: [];
|
56
|
-
clientDisconnect: [];
|
57
|
-
}
|
@@ -1,150 +0,0 @@
|
|
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.VoiceConnection = void 0;
|
7
|
-
const ws_1 = __importDefault(require("ws"));
|
8
|
-
const constants_1 = require("../constants");
|
9
|
-
const utils_1 = require("../utils");
|
10
|
-
const node_events_1 = __importDefault(require("node:events"));
|
11
|
-
class VoiceConnection extends node_events_1.default {
|
12
|
-
ws;
|
13
|
-
endpoint;
|
14
|
-
serverID;
|
15
|
-
userID;
|
16
|
-
sessionID;
|
17
|
-
token;
|
18
|
-
heartbeatInterval;
|
19
|
-
ssrc;
|
20
|
-
constructor(endpoint, options) {
|
21
|
-
super();
|
22
|
-
this.ws = new ws_1.default(`wss://${endpoint}?v=4`);
|
23
|
-
this.endpoint = endpoint;
|
24
|
-
this.serverID = options.serverID;
|
25
|
-
this.userID = options.userID;
|
26
|
-
this.sessionID = options.sessionID;
|
27
|
-
this.token = options.token;
|
28
|
-
}
|
29
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
30
|
-
connect() {
|
31
|
-
this.ws.on("open", () => this.onWebSocketOpen());
|
32
|
-
this.ws.on("message", (data) => this.onWebSocketMessage(data));
|
33
|
-
this.ws.on("error", (err) => this.onWebSocketError(err));
|
34
|
-
this.ws.on("close", (code, reason) => this.onWebSocketClose(code, reason));
|
35
|
-
}
|
36
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
37
|
-
disconnect() {
|
38
|
-
if (this.heartbeatInterval) {
|
39
|
-
clearInterval(this.heartbeatInterval);
|
40
|
-
this.heartbeatInterval = null;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
44
|
-
heartbeat() {
|
45
|
-
this.ws.send(JSON.stringify({
|
46
|
-
op: constants_1.VoiceOPCodes.Heartbeat,
|
47
|
-
d: Date.now(),
|
48
|
-
}));
|
49
|
-
}
|
50
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
51
|
-
identify(options) {
|
52
|
-
this.ws.send(JSON.stringify({
|
53
|
-
op: constants_1.VoiceOPCodes.Identify,
|
54
|
-
d: {
|
55
|
-
server_id: options.serverID,
|
56
|
-
user_id: options.userID,
|
57
|
-
session_id: options.sessionID,
|
58
|
-
token: options.token,
|
59
|
-
},
|
60
|
-
}));
|
61
|
-
}
|
62
|
-
onWebSocketOpen() {
|
63
|
-
this.identify({
|
64
|
-
serverID: this.serverID,
|
65
|
-
userID: this.userID,
|
66
|
-
sessionID: this.sessionID,
|
67
|
-
token: this.token,
|
68
|
-
});
|
69
|
-
}
|
70
|
-
onWebSocketMessage(data) {
|
71
|
-
const packet = JSON.parse(data.toString());
|
72
|
-
switch (packet.op) {
|
73
|
-
case constants_1.VoiceOPCodes.Ready:
|
74
|
-
{
|
75
|
-
this.ssrc = packet.d.ssrc;
|
76
|
-
this.emit("ready", {
|
77
|
-
ssrc: packet.d.ssrc,
|
78
|
-
ip: packet.d.ip,
|
79
|
-
port: packet.d.port,
|
80
|
-
modes: packet.d.modes,
|
81
|
-
});
|
82
|
-
}
|
83
|
-
break;
|
84
|
-
case constants_1.VoiceOPCodes.SessionDescription:
|
85
|
-
this.emit("sessionDescription", {
|
86
|
-
mode: packet.d.mode,
|
87
|
-
secretKey: packet.d.secret_key,
|
88
|
-
});
|
89
|
-
break;
|
90
|
-
case constants_1.VoiceOPCodes.Speaking:
|
91
|
-
this.emit("speaking", packet.d.speaking);
|
92
|
-
break;
|
93
|
-
case constants_1.VoiceOPCodes.HeartbeatACK:
|
94
|
-
this.emit("heartbeatACK", packet.d);
|
95
|
-
break;
|
96
|
-
case constants_1.VoiceOPCodes.Hello:
|
97
|
-
{
|
98
|
-
this.heartbeatInterval = setInterval(() => this.heartbeat(), packet.d.heartbeat_interval);
|
99
|
-
this.emit("hello");
|
100
|
-
}
|
101
|
-
break;
|
102
|
-
case constants_1.VoiceOPCodes.Resumed:
|
103
|
-
this.emit("resumed");
|
104
|
-
break;
|
105
|
-
case constants_1.VoiceOPCodes.ClientDisconnect:
|
106
|
-
this.emit("clientDisconnect");
|
107
|
-
break;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
onWebSocketError(err) {
|
111
|
-
throw err;
|
112
|
-
}
|
113
|
-
onWebSocketClose(code, reason) {
|
114
|
-
if (code === 1000)
|
115
|
-
return;
|
116
|
-
if (code === constants_1.VoiceCloseEventCodes.Disconnect)
|
117
|
-
return this.disconnect();
|
118
|
-
throw new utils_1.GatewayError(`[${code}] ${reason}`);
|
119
|
-
}
|
120
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
121
|
-
resume(options) {
|
122
|
-
this.ws.send(JSON.stringify({
|
123
|
-
op: constants_1.VoiceOPCodes.Resume,
|
124
|
-
d: {
|
125
|
-
server_id: options.serverID,
|
126
|
-
session_id: options.sessionID,
|
127
|
-
token: options.token,
|
128
|
-
},
|
129
|
-
}));
|
130
|
-
}
|
131
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
132
|
-
selectProtocol(options) {
|
133
|
-
this.ws.send(JSON.stringify({
|
134
|
-
op: constants_1.VoiceOPCodes.SelectProtocol,
|
135
|
-
d: options,
|
136
|
-
}));
|
137
|
-
}
|
138
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
139
|
-
speaking(speaking) {
|
140
|
-
this.ws.send(JSON.stringify({
|
141
|
-
op: constants_1.VoiceOPCodes.Speaking,
|
142
|
-
d: {
|
143
|
-
speaking,
|
144
|
-
delay: 0,
|
145
|
-
ssrc: this.ssrc,
|
146
|
-
},
|
147
|
-
}));
|
148
|
-
}
|
149
|
-
}
|
150
|
-
exports.VoiceConnection = VoiceConnection;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { snowflake } from "../types/common";
|
2
|
-
import type { ResumeConnectionPayload, SelectProtocolPayload, VoiceIdentifyPayload } from "../types/voice-connections";
|
3
|
-
import { VoiceConnection } from ".";
|
4
|
-
export declare class VoiceConnectionManager extends Map<snowflake, VoiceConnection> {
|
5
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
6
|
-
connect(endpoint: string, options: VoiceIdentifyPayload): VoiceConnection;
|
7
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
8
|
-
disconnect(guildID: snowflake): void;
|
9
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
10
|
-
heartbeat(guildID: snowflake): void;
|
11
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
12
|
-
identify(guildID: snowflake, options: VoiceIdentifyPayload): void;
|
13
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
14
|
-
resume(guildID: snowflake, options: ResumeConnectionPayload): void;
|
15
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
16
|
-
selectProtocol(guildID: snowflake, options: SelectProtocolPayload): void;
|
17
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
18
|
-
speaking(guildID: snowflake, speaking: number): void;
|
19
|
-
}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.VoiceConnectionManager = void 0;
|
4
|
-
const _1 = require(".");
|
5
|
-
class VoiceConnectionManager extends Map {
|
6
|
-
/** https://discord.com/developers/docs/topics/voice-connections#connecting-to-voice */
|
7
|
-
connect(endpoint, options) {
|
8
|
-
let voiceConnection = new _1.VoiceConnection(endpoint, options);
|
9
|
-
if (!this.has(options.serverID)) {
|
10
|
-
this.set(options.serverID, voiceConnection);
|
11
|
-
voiceConnection.connect();
|
12
|
-
}
|
13
|
-
else {
|
14
|
-
this.disconnect(options.serverID);
|
15
|
-
this.set(options.serverID, voiceConnection);
|
16
|
-
}
|
17
|
-
return voiceConnection;
|
18
|
-
}
|
19
|
-
/** https://discord.com/developers/docs/topics/gateway#connections */
|
20
|
-
disconnect(guildID) {
|
21
|
-
if (this.has(guildID)) {
|
22
|
-
this.get(guildID).disconnect();
|
23
|
-
this.delete(guildID);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
/** https://discord.com/developers/docs/topics/voice-connections#heartbeating */
|
27
|
-
heartbeat(guildID) {
|
28
|
-
if (this.has(guildID)) {
|
29
|
-
this.get(guildID).heartbeat();
|
30
|
-
}
|
31
|
-
}
|
32
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload */
|
33
|
-
identify(guildID, options) {
|
34
|
-
if (this.has(guildID)) {
|
35
|
-
this.get(guildID).identify({
|
36
|
-
serverID: options.serverID,
|
37
|
-
userID: options.userID,
|
38
|
-
sessionID: options.sessionID,
|
39
|
-
token: options.token,
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
/** https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection */
|
44
|
-
resume(guildID, options) {
|
45
|
-
if (this.has(guildID)) {
|
46
|
-
this.get(guildID).resume({
|
47
|
-
serverID: options.serverID,
|
48
|
-
sessionID: options.sessionID,
|
49
|
-
token: options.token,
|
50
|
-
});
|
51
|
-
}
|
52
|
-
}
|
53
|
-
/** https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection */
|
54
|
-
selectProtocol(guildID, options) {
|
55
|
-
if (this.has(guildID)) {
|
56
|
-
this.get(guildID).selectProtocol(options);
|
57
|
-
}
|
58
|
-
}
|
59
|
-
/** https://discord.com/developers/docs/topics/voice-connections#speaking */
|
60
|
-
speaking(guildID, speaking) {
|
61
|
-
if (this.has(guildID)) {
|
62
|
-
this.get(guildID).speaking(speaking);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
exports.VoiceConnectionManager = VoiceConnectionManager;
|
package/dist/lib/voice/index.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./VoiceConnection"), exports);
|
18
|
-
__exportStar(require("./VoiceConnectionManager"), exports);
|
File without changes
|
File without changes
|