@discordjs/voice 0.9.0-dev.1649505804-3c0bbac → 0.9.0
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 +1 -0
- package/dist/index.d.ts +83 -83
- package/dist/index.js +97 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +87 -88
- package/CHANGELOG.md +0 -51
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
1
2
|
import { Readable, ReadableOptions } from 'node:stream';
|
|
2
3
|
import prism from 'prism-media';
|
|
3
|
-
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
4
|
-
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
|
|
5
4
|
import WebSocket, { MessageEvent } from 'ws';
|
|
6
|
-
|
|
7
|
-
declare type Awaited<T> = T | Promise<T>;
|
|
5
|
+
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* The different types of stream that can exist within the pipeline.
|
|
@@ -232,6 +230,8 @@ declare class PlayerSubscription {
|
|
|
232
230
|
unsubscribe(): void;
|
|
233
231
|
}
|
|
234
232
|
|
|
233
|
+
declare type Awaited<T> = T | Promise<T>;
|
|
234
|
+
|
|
235
235
|
/**
|
|
236
236
|
* Describes the behavior of the player when an audio packet is played but there are no available
|
|
237
237
|
* voice connections to play to.
|
|
@@ -542,54 +542,6 @@ declare function getVoiceConnections(group: string): Map<string, VoiceConnection
|
|
|
542
542
|
*/
|
|
543
543
|
declare function getVoiceConnection(guildId: string, group?: string): VoiceConnection | undefined;
|
|
544
544
|
|
|
545
|
-
/**
|
|
546
|
-
* Methods that are provided by the @discordjs/voice library to implementations of
|
|
547
|
-
* Discord gateway DiscordGatewayAdapters.
|
|
548
|
-
*/
|
|
549
|
-
interface DiscordGatewayAdapterLibraryMethods {
|
|
550
|
-
/**
|
|
551
|
-
* Call this when you receive a VOICE_SERVER_UPDATE payload that is relevant to the adapter.
|
|
552
|
-
*
|
|
553
|
-
* @param data - The inner data of the VOICE_SERVER_UPDATE payload
|
|
554
|
-
*/
|
|
555
|
-
onVoiceServerUpdate: (data: GatewayVoiceServerUpdateDispatchData) => void;
|
|
556
|
-
/**
|
|
557
|
-
* Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter.
|
|
558
|
-
*
|
|
559
|
-
* @param data - The inner data of the VOICE_STATE_UPDATE payload
|
|
560
|
-
*/
|
|
561
|
-
onVoiceStateUpdate: (data: GatewayVoiceStateUpdateDispatchData) => void;
|
|
562
|
-
/**
|
|
563
|
-
* Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway)
|
|
564
|
-
*/
|
|
565
|
-
destroy: () => void;
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Methods that are provided by the implementer of a Discord gateway DiscordGatewayAdapter.
|
|
569
|
-
*/
|
|
570
|
-
interface DiscordGatewayAdapterImplementerMethods {
|
|
571
|
-
/**
|
|
572
|
-
* Implement this method such that the given payload is sent to the main Discord gateway connection.
|
|
573
|
-
*
|
|
574
|
-
* @param payload - The payload to send to the main Discord gateway connection
|
|
575
|
-
*
|
|
576
|
-
* @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects
|
|
577
|
-
*/
|
|
578
|
-
sendPayload: (payload: any) => boolean;
|
|
579
|
-
/**
|
|
580
|
-
* This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no
|
|
581
|
-
* longer be used.
|
|
582
|
-
*/
|
|
583
|
-
destroy: () => void;
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* A function used to build adapters. It accepts a methods parameter that contains functions that
|
|
587
|
-
* can be called by the implementer when new data is received on its gateway connection. In return,
|
|
588
|
-
* the implementer will return some methods that the library can call - e.g. to send messages on
|
|
589
|
-
* the gateway, or to signal that the adapter can be removed.
|
|
590
|
-
*/
|
|
591
|
-
declare type DiscordGatewayAdapterCreator = (methods: DiscordGatewayAdapterLibraryMethods) => DiscordGatewayAdapterImplementerMethods;
|
|
592
|
-
|
|
593
545
|
/**
|
|
594
546
|
* Stores an IP address and port. Used to store socket details for the local client as well as
|
|
595
547
|
* for Discord.
|
|
@@ -1041,37 +993,6 @@ declare class AudioReceiveStream extends Readable {
|
|
|
1041
993
|
_read(): void;
|
|
1042
994
|
}
|
|
1043
995
|
|
|
1044
|
-
/**
|
|
1045
|
-
* The events that a SpeakingMap can emit.
|
|
1046
|
-
*/
|
|
1047
|
-
interface SpeakingMapEvents {
|
|
1048
|
-
/**
|
|
1049
|
-
* Emitted when a user starts speaking.
|
|
1050
|
-
*/
|
|
1051
|
-
start: (userId: string) => Awaited<void>;
|
|
1052
|
-
/**
|
|
1053
|
-
* Emitted when a user stops speaking.
|
|
1054
|
-
*/
|
|
1055
|
-
end: (userId: string) => Awaited<void>;
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Tracks the speaking states of users in a voice channel.
|
|
1059
|
-
*/
|
|
1060
|
-
declare class SpeakingMap extends TypedEmitter<SpeakingMapEvents> {
|
|
1061
|
-
/**
|
|
1062
|
-
* The delay after a packet is received from a user until they're marked as not speaking anymore.
|
|
1063
|
-
*/
|
|
1064
|
-
static readonly DELAY = 100;
|
|
1065
|
-
/**
|
|
1066
|
-
* The currently speaking users, mapped to the milliseconds since UNIX epoch at which they started speaking.
|
|
1067
|
-
*/
|
|
1068
|
-
readonly users: Map<string, number>;
|
|
1069
|
-
private readonly speakingTimeouts;
|
|
1070
|
-
constructor();
|
|
1071
|
-
onPacket(userId: string): void;
|
|
1072
|
-
private startTimeout;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
996
|
/**
|
|
1076
997
|
* The known data for a user in a Discord voice connection.
|
|
1077
998
|
*/
|
|
@@ -1129,6 +1050,37 @@ declare class SSRCMap extends TypedEmitter<SSRCMapEvents> {
|
|
|
1129
1050
|
delete(target: number | string): VoiceUserData | undefined;
|
|
1130
1051
|
}
|
|
1131
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* The events that a SpeakingMap can emit.
|
|
1055
|
+
*/
|
|
1056
|
+
interface SpeakingMapEvents {
|
|
1057
|
+
/**
|
|
1058
|
+
* Emitted when a user starts speaking.
|
|
1059
|
+
*/
|
|
1060
|
+
start: (userId: string) => Awaited<void>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Emitted when a user stops speaking.
|
|
1063
|
+
*/
|
|
1064
|
+
end: (userId: string) => Awaited<void>;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Tracks the speaking states of users in a voice channel.
|
|
1068
|
+
*/
|
|
1069
|
+
declare class SpeakingMap extends TypedEmitter<SpeakingMapEvents> {
|
|
1070
|
+
/**
|
|
1071
|
+
* The delay after a packet is received from a user until they're marked as not speaking anymore.
|
|
1072
|
+
*/
|
|
1073
|
+
static readonly DELAY = 100;
|
|
1074
|
+
/**
|
|
1075
|
+
* The currently speaking users, mapped to the milliseconds since UNIX epoch at which they started speaking.
|
|
1076
|
+
*/
|
|
1077
|
+
readonly users: Map<string, number>;
|
|
1078
|
+
private readonly speakingTimeouts;
|
|
1079
|
+
constructor();
|
|
1080
|
+
onPacket(userId: string): void;
|
|
1081
|
+
private startTimeout;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1132
1084
|
/**
|
|
1133
1085
|
* Attaches to a VoiceConnection, allowing you to receive audio packets from other
|
|
1134
1086
|
* users that are speaking.
|
|
@@ -1197,6 +1149,54 @@ declare class VoiceReceiver {
|
|
|
1197
1149
|
subscribe(userId: string, options?: Partial<AudioReceiveStreamOptions>): AudioReceiveStream;
|
|
1198
1150
|
}
|
|
1199
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* Methods that are provided by the @discordjs/voice library to implementations of
|
|
1154
|
+
* Discord gateway DiscordGatewayAdapters.
|
|
1155
|
+
*/
|
|
1156
|
+
interface DiscordGatewayAdapterLibraryMethods {
|
|
1157
|
+
/**
|
|
1158
|
+
* Call this when you receive a VOICE_SERVER_UPDATE payload that is relevant to the adapter.
|
|
1159
|
+
*
|
|
1160
|
+
* @param data - The inner data of the VOICE_SERVER_UPDATE payload
|
|
1161
|
+
*/
|
|
1162
|
+
onVoiceServerUpdate: (data: GatewayVoiceServerUpdateDispatchData) => void;
|
|
1163
|
+
/**
|
|
1164
|
+
* Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter.
|
|
1165
|
+
*
|
|
1166
|
+
* @param data - The inner data of the VOICE_STATE_UPDATE payload
|
|
1167
|
+
*/
|
|
1168
|
+
onVoiceStateUpdate: (data: GatewayVoiceStateUpdateDispatchData) => void;
|
|
1169
|
+
/**
|
|
1170
|
+
* Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway)
|
|
1171
|
+
*/
|
|
1172
|
+
destroy: () => void;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Methods that are provided by the implementer of a Discord gateway DiscordGatewayAdapter.
|
|
1176
|
+
*/
|
|
1177
|
+
interface DiscordGatewayAdapterImplementerMethods {
|
|
1178
|
+
/**
|
|
1179
|
+
* Implement this method such that the given payload is sent to the main Discord gateway connection.
|
|
1180
|
+
*
|
|
1181
|
+
* @param payload - The payload to send to the main Discord gateway connection
|
|
1182
|
+
*
|
|
1183
|
+
* @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects
|
|
1184
|
+
*/
|
|
1185
|
+
sendPayload: (payload: any) => boolean;
|
|
1186
|
+
/**
|
|
1187
|
+
* This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no
|
|
1188
|
+
* longer be used.
|
|
1189
|
+
*/
|
|
1190
|
+
destroy: () => void;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* A function used to build adapters. It accepts a methods parameter that contains functions that
|
|
1194
|
+
* can be called by the implementer when new data is received on its gateway connection. In return,
|
|
1195
|
+
* the implementer will return some methods that the library can call - e.g. to send messages on
|
|
1196
|
+
* the gateway, or to signal that the adapter can be removed.
|
|
1197
|
+
*/
|
|
1198
|
+
declare type DiscordGatewayAdapterCreator = (methods: DiscordGatewayAdapterLibraryMethods) => DiscordGatewayAdapterImplementerMethods;
|
|
1199
|
+
|
|
1200
1200
|
/**
|
|
1201
1201
|
* The various status codes a voice connection can hold at any one time.
|
|
1202
1202
|
*/
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
10
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
10
|
var __commonJS = (cb, mod) => function __require() {
|
|
12
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -15,22 +14,16 @@ var __export = (target, all) => {
|
|
|
15
14
|
for (var name in all)
|
|
16
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
16
|
};
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
for (let key of __getOwnPropNames(
|
|
21
|
-
if (!__hasOwnProp.call(
|
|
22
|
-
__defProp(
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
22
|
}
|
|
24
|
-
return
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (module2, isNodeMode) => {
|
|
27
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
return to;
|
|
28
24
|
};
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
32
|
-
};
|
|
33
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var __publicField = (obj, key, value) => {
|
|
35
28
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
29
|
return value;
|
|
@@ -41,7 +34,7 @@ var require_package = __commonJS({
|
|
|
41
34
|
"package.json"(exports, module2) {
|
|
42
35
|
module2.exports = {
|
|
43
36
|
name: "@discordjs/voice",
|
|
44
|
-
version: "0.9.0
|
|
37
|
+
version: "0.9.0",
|
|
45
38
|
description: "Implementation of the Discord Voice API for node.js",
|
|
46
39
|
scripts: {
|
|
47
40
|
build: "tsup && node scripts/postbuild.mjs",
|
|
@@ -91,7 +84,7 @@ var require_package = __commonJS({
|
|
|
91
84
|
},
|
|
92
85
|
homepage: "https://discord.js.org",
|
|
93
86
|
dependencies: {
|
|
94
|
-
"@types/ws": "^8.
|
|
87
|
+
"@types/ws": "^8.5.3",
|
|
95
88
|
"discord-api-types": "^0.29.0",
|
|
96
89
|
"prism-media": "^1.3.2",
|
|
97
90
|
"tiny-typed-emitter": "^2.1.0",
|
|
@@ -99,26 +92,26 @@ var require_package = __commonJS({
|
|
|
99
92
|
ws: "^8.5.0"
|
|
100
93
|
},
|
|
101
94
|
devDependencies: {
|
|
102
|
-
"@babel/core": "^7.17.
|
|
95
|
+
"@babel/core": "^7.17.9",
|
|
103
96
|
"@babel/preset-env": "^7.16.11",
|
|
104
97
|
"@babel/preset-typescript": "^7.16.7",
|
|
105
|
-
"@discordjs/ts-docgen": "^0.
|
|
106
|
-
"@types/jest": "^27.4.
|
|
107
|
-
"@types/node": "^16.11.
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
109
|
-
"@typescript-eslint/parser": "^5.
|
|
110
|
-
eslint: "^8.
|
|
111
|
-
"eslint-config-marine": "^9.
|
|
112
|
-
"eslint-config-prettier": "^8.
|
|
113
|
-
"eslint-plugin-
|
|
98
|
+
"@discordjs/ts-docgen": "^0.4.1",
|
|
99
|
+
"@types/jest": "^27.4.1",
|
|
100
|
+
"@types/node": "^16.11.27",
|
|
101
|
+
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
|
102
|
+
"@typescript-eslint/parser": "^5.19.0",
|
|
103
|
+
eslint: "^8.13.0",
|
|
104
|
+
"eslint-config-marine": "^9.4.1",
|
|
105
|
+
"eslint-config-prettier": "^8.5.0",
|
|
106
|
+
"eslint-plugin-import": "^2.26.0",
|
|
114
107
|
jest: "^27.5.1",
|
|
115
108
|
"jest-websocket-mock": "^2.3.0",
|
|
116
109
|
"mock-socket": "^9.1.2",
|
|
117
|
-
prettier: "^2.
|
|
118
|
-
tsup: "^5.
|
|
110
|
+
prettier: "^2.6.2",
|
|
111
|
+
tsup: "^5.12.5",
|
|
119
112
|
tweetnacl: "^1.0.3",
|
|
120
|
-
typedoc: "^0.22.
|
|
121
|
-
typescript: "^4.
|
|
113
|
+
typedoc: "^0.22.15",
|
|
114
|
+
typescript: "^4.6.3"
|
|
122
115
|
},
|
|
123
116
|
engines: {
|
|
124
117
|
node: ">=16.9.0"
|
|
@@ -160,6 +153,10 @@ __export(src_exports, {
|
|
|
160
153
|
joinVoiceChannel: () => joinVoiceChannel,
|
|
161
154
|
validateDiscordOpusHead: () => validateDiscordOpusHead
|
|
162
155
|
});
|
|
156
|
+
module.exports = __toCommonJS(src_exports);
|
|
157
|
+
|
|
158
|
+
// src/VoiceConnection.ts
|
|
159
|
+
var import_tiny_typed_emitter7 = require("tiny-typed-emitter");
|
|
163
160
|
|
|
164
161
|
// src/DataStore.ts
|
|
165
162
|
var import_v10 = require("discord-api-types/v10");
|
|
@@ -261,6 +258,7 @@ __name(deleteAudioPlayer, "deleteAudioPlayer");
|
|
|
261
258
|
|
|
262
259
|
// src/networking/Networking.ts
|
|
263
260
|
var import_v42 = require("discord-api-types/voice/v4");
|
|
261
|
+
var import_tiny_typed_emitter3 = require("tiny-typed-emitter");
|
|
264
262
|
|
|
265
263
|
// src/networking/VoiceUDPSocket.ts
|
|
266
264
|
var import_node_dgram = require("dgram");
|
|
@@ -365,8 +363,8 @@ __name(VoiceUDPSocket, "VoiceUDPSocket");
|
|
|
365
363
|
|
|
366
364
|
// src/networking/VoiceWebSocket.ts
|
|
367
365
|
var import_v4 = require("discord-api-types/voice/v4");
|
|
368
|
-
var import_ws = __toESM(require("ws"));
|
|
369
366
|
var import_tiny_typed_emitter2 = require("tiny-typed-emitter");
|
|
367
|
+
var import_ws = __toESM(require("ws"));
|
|
370
368
|
var VoiceWebSocket = class extends import_tiny_typed_emitter2.TypedEmitter {
|
|
371
369
|
constructor(address, debug) {
|
|
372
370
|
super();
|
|
@@ -452,12 +450,29 @@ __name(VoiceWebSocket, "VoiceWebSocket");
|
|
|
452
450
|
|
|
453
451
|
// src/util/Secretbox.ts
|
|
454
452
|
var libs = {
|
|
453
|
+
"sodium-native": (sodium) => ({
|
|
454
|
+
open: (buffer, nonce2, secretKey) => {
|
|
455
|
+
if (buffer) {
|
|
456
|
+
const output = Buffer.allocUnsafe(buffer.length - sodium.crypto_box_MACBYTES);
|
|
457
|
+
if (sodium.crypto_secretbox_open_easy(output, buffer, nonce2, secretKey))
|
|
458
|
+
return output;
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
},
|
|
462
|
+
close: (opusPacket, nonce2, secretKey) => {
|
|
463
|
+
const output = Buffer.allocUnsafe(opusPacket.length + sodium.crypto_box_MACBYTES);
|
|
464
|
+
sodium.crypto_secretbox_easy(output, opusPacket, nonce2, secretKey);
|
|
465
|
+
return output;
|
|
466
|
+
},
|
|
467
|
+
random: (n, buffer = Buffer.allocUnsafe(n)) => {
|
|
468
|
+
sodium.randombytes_buf(buffer);
|
|
469
|
+
return buffer;
|
|
470
|
+
}
|
|
471
|
+
}),
|
|
455
472
|
sodium: (sodium) => ({
|
|
456
473
|
open: sodium.api.crypto_secretbox_open_easy,
|
|
457
474
|
close: sodium.api.crypto_secretbox_easy,
|
|
458
|
-
random: (n, buffer) => {
|
|
459
|
-
if (!buffer)
|
|
460
|
-
buffer = Buffer.allocUnsafe(n);
|
|
475
|
+
random: (n, buffer = Buffer.allocUnsafe(n)) => {
|
|
461
476
|
sodium.api.randombytes_buf(buffer);
|
|
462
477
|
return buffer;
|
|
463
478
|
}
|
|
@@ -465,12 +480,12 @@ var libs = {
|
|
|
465
480
|
"libsodium-wrappers": (sodium) => ({
|
|
466
481
|
open: sodium.crypto_secretbox_open_easy,
|
|
467
482
|
close: sodium.crypto_secretbox_easy,
|
|
468
|
-
random:
|
|
483
|
+
random: sodium.randombytes_buf
|
|
469
484
|
}),
|
|
470
485
|
tweetnacl: (tweetnacl) => ({
|
|
471
486
|
open: tweetnacl.secretbox.open,
|
|
472
487
|
close: tweetnacl.secretbox,
|
|
473
|
-
random:
|
|
488
|
+
random: tweetnacl.randomBytes
|
|
474
489
|
})
|
|
475
490
|
};
|
|
476
491
|
var fallbackError = /* @__PURE__ */ __name(() => {
|
|
@@ -502,7 +517,6 @@ var noop = /* @__PURE__ */ __name(() => {
|
|
|
502
517
|
}, "noop");
|
|
503
518
|
|
|
504
519
|
// src/networking/Networking.ts
|
|
505
|
-
var import_tiny_typed_emitter3 = require("tiny-typed-emitter");
|
|
506
520
|
var CHANNELS = 2;
|
|
507
521
|
var TIMESTAMP_INC = 48e3 / 100 * CHANNELS;
|
|
508
522
|
var MAX_NONCE_SIZE = 2 ** 32 - 1;
|
|
@@ -792,15 +806,15 @@ to ${stringifyState(newState)}`);
|
|
|
792
806
|
};
|
|
793
807
|
__name(Networking, "Networking");
|
|
794
808
|
|
|
795
|
-
// src/VoiceConnection.ts
|
|
796
|
-
var import_tiny_typed_emitter7 = require("tiny-typed-emitter");
|
|
797
|
-
|
|
798
809
|
// src/receive/VoiceReceiver.ts
|
|
799
810
|
var import_v43 = require("discord-api-types/voice/v4");
|
|
800
811
|
|
|
801
812
|
// src/receive/AudioReceiveStream.ts
|
|
802
813
|
var import_node_stream = require("stream");
|
|
803
814
|
|
|
815
|
+
// src/audio/AudioPlayer.ts
|
|
816
|
+
var import_tiny_typed_emitter4 = require("tiny-typed-emitter");
|
|
817
|
+
|
|
804
818
|
// src/audio/AudioPlayerError.ts
|
|
805
819
|
var AudioPlayerError = class extends Error {
|
|
806
820
|
constructor(error, resource) {
|
|
@@ -829,7 +843,6 @@ var PlayerSubscription = class {
|
|
|
829
843
|
__name(PlayerSubscription, "PlayerSubscription");
|
|
830
844
|
|
|
831
845
|
// src/audio/AudioPlayer.ts
|
|
832
|
-
var import_tiny_typed_emitter4 = require("tiny-typed-emitter");
|
|
833
846
|
var SILENCE_FRAME = Buffer.from([248, 255, 254]);
|
|
834
847
|
var NoSubscriberBehavior = /* @__PURE__ */ ((NoSubscriberBehavior2) => {
|
|
835
848
|
NoSubscriberBehavior2["Pause"] = "pause";
|
|
@@ -1145,41 +1158,9 @@ var AudioReceiveStream = class extends import_node_stream.Readable {
|
|
|
1145
1158
|
};
|
|
1146
1159
|
__name(AudioReceiveStream, "AudioReceiveStream");
|
|
1147
1160
|
|
|
1148
|
-
// src/receive/SpeakingMap.ts
|
|
1149
|
-
var import_tiny_typed_emitter5 = require("tiny-typed-emitter");
|
|
1150
|
-
var _SpeakingMap = class extends import_tiny_typed_emitter5.TypedEmitter {
|
|
1151
|
-
constructor() {
|
|
1152
|
-
super();
|
|
1153
|
-
__publicField(this, "users");
|
|
1154
|
-
__publicField(this, "speakingTimeouts");
|
|
1155
|
-
this.users = /* @__PURE__ */ new Map();
|
|
1156
|
-
this.speakingTimeouts = /* @__PURE__ */ new Map();
|
|
1157
|
-
}
|
|
1158
|
-
onPacket(userId) {
|
|
1159
|
-
const timeout = this.speakingTimeouts.get(userId);
|
|
1160
|
-
if (timeout) {
|
|
1161
|
-
clearTimeout(timeout);
|
|
1162
|
-
} else {
|
|
1163
|
-
this.users.set(userId, Date.now());
|
|
1164
|
-
this.emit("start", userId);
|
|
1165
|
-
}
|
|
1166
|
-
this.startTimeout(userId);
|
|
1167
|
-
}
|
|
1168
|
-
startTimeout(userId) {
|
|
1169
|
-
this.speakingTimeouts.set(userId, setTimeout(() => {
|
|
1170
|
-
this.emit("end", userId);
|
|
1171
|
-
this.speakingTimeouts.delete(userId);
|
|
1172
|
-
this.users.delete(userId);
|
|
1173
|
-
}, _SpeakingMap.DELAY));
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
var SpeakingMap = _SpeakingMap;
|
|
1177
|
-
__name(SpeakingMap, "SpeakingMap");
|
|
1178
|
-
__publicField(SpeakingMap, "DELAY", 100);
|
|
1179
|
-
|
|
1180
1161
|
// src/receive/SSRCMap.ts
|
|
1181
|
-
var
|
|
1182
|
-
var SSRCMap = class extends
|
|
1162
|
+
var import_tiny_typed_emitter5 = require("tiny-typed-emitter");
|
|
1163
|
+
var SSRCMap = class extends import_tiny_typed_emitter5.TypedEmitter {
|
|
1183
1164
|
constructor() {
|
|
1184
1165
|
super();
|
|
1185
1166
|
__publicField(this, "map");
|
|
@@ -1228,6 +1209,38 @@ var SSRCMap = class extends import_tiny_typed_emitter6.TypedEmitter {
|
|
|
1228
1209
|
};
|
|
1229
1210
|
__name(SSRCMap, "SSRCMap");
|
|
1230
1211
|
|
|
1212
|
+
// src/receive/SpeakingMap.ts
|
|
1213
|
+
var import_tiny_typed_emitter6 = require("tiny-typed-emitter");
|
|
1214
|
+
var _SpeakingMap = class extends import_tiny_typed_emitter6.TypedEmitter {
|
|
1215
|
+
constructor() {
|
|
1216
|
+
super();
|
|
1217
|
+
__publicField(this, "users");
|
|
1218
|
+
__publicField(this, "speakingTimeouts");
|
|
1219
|
+
this.users = /* @__PURE__ */ new Map();
|
|
1220
|
+
this.speakingTimeouts = /* @__PURE__ */ new Map();
|
|
1221
|
+
}
|
|
1222
|
+
onPacket(userId) {
|
|
1223
|
+
const timeout = this.speakingTimeouts.get(userId);
|
|
1224
|
+
if (timeout) {
|
|
1225
|
+
clearTimeout(timeout);
|
|
1226
|
+
} else {
|
|
1227
|
+
this.users.set(userId, Date.now());
|
|
1228
|
+
this.emit("start", userId);
|
|
1229
|
+
}
|
|
1230
|
+
this.startTimeout(userId);
|
|
1231
|
+
}
|
|
1232
|
+
startTimeout(userId) {
|
|
1233
|
+
this.speakingTimeouts.set(userId, setTimeout(() => {
|
|
1234
|
+
this.emit("end", userId);
|
|
1235
|
+
this.speakingTimeouts.delete(userId);
|
|
1236
|
+
this.users.delete(userId);
|
|
1237
|
+
}, _SpeakingMap.DELAY));
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
var SpeakingMap = _SpeakingMap;
|
|
1241
|
+
__name(SpeakingMap, "SpeakingMap");
|
|
1242
|
+
__publicField(SpeakingMap, "DELAY", 100);
|
|
1243
|
+
|
|
1231
1244
|
// src/receive/VoiceReceiver.ts
|
|
1232
1245
|
var VoiceReceiver = class {
|
|
1233
1246
|
constructor(voiceConnection) {
|
|
@@ -1685,6 +1698,10 @@ function joinVoiceChannel(options) {
|
|
|
1685
1698
|
}
|
|
1686
1699
|
__name(joinVoiceChannel, "joinVoiceChannel");
|
|
1687
1700
|
|
|
1701
|
+
// src/audio/AudioResource.ts
|
|
1702
|
+
var import_node_stream2 = require("stream");
|
|
1703
|
+
var import_prism_media2 = __toESM(require("prism-media"));
|
|
1704
|
+
|
|
1688
1705
|
// src/audio/TransformerGraph.ts
|
|
1689
1706
|
var import_prism_media = __toESM(require("prism-media"));
|
|
1690
1707
|
var FFMPEG_PCM_ARGUMENTS = ["-analyzeduration", "0", "-loglevel", "0", "-f", "s16le", "-ar", "48000", "-ac", "2"];
|
|
@@ -1829,8 +1846,6 @@ function findPipeline(from, constraint) {
|
|
|
1829
1846
|
__name(findPipeline, "findPipeline");
|
|
1830
1847
|
|
|
1831
1848
|
// src/audio/AudioResource.ts
|
|
1832
|
-
var import_node_stream2 = require("stream");
|
|
1833
|
-
var import_prism_media2 = __toESM(require("prism-media"));
|
|
1834
1849
|
var AudioResource = class {
|
|
1835
1850
|
constructor(edges, streams, metadata, silencePaddingFrames) {
|
|
1836
1851
|
__publicField(this, "playStream");
|
|
@@ -1963,6 +1978,7 @@ function generateDependencyReport() {
|
|
|
1963
1978
|
addVersion("opusscript");
|
|
1964
1979
|
report.push("");
|
|
1965
1980
|
report.push("Encryption Libraries");
|
|
1981
|
+
addVersion("sodium-native");
|
|
1966
1982
|
addVersion("sodium");
|
|
1967
1983
|
addVersion("libsodium-wrappers");
|
|
1968
1984
|
addVersion("tweetnacl");
|
|
@@ -1979,6 +1995,9 @@ function generateDependencyReport() {
|
|
|
1979
1995
|
}
|
|
1980
1996
|
__name(generateDependencyReport, "generateDependencyReport");
|
|
1981
1997
|
|
|
1998
|
+
// src/util/entersState.ts
|
|
1999
|
+
var import_node_events = require("events");
|
|
2000
|
+
|
|
1982
2001
|
// src/util/abortAfter.ts
|
|
1983
2002
|
function abortAfter(delay) {
|
|
1984
2003
|
const ac = new AbortController();
|
|
@@ -1989,7 +2008,6 @@ function abortAfter(delay) {
|
|
|
1989
2008
|
__name(abortAfter, "abortAfter");
|
|
1990
2009
|
|
|
1991
2010
|
// src/util/entersState.ts
|
|
1992
|
-
var import_node_events = require("events");
|
|
1993
2011
|
async function entersState(target, status, timeoutOrSignal) {
|
|
1994
2012
|
if (target.state.status !== status) {
|
|
1995
2013
|
const [ac, signal] = typeof timeoutOrSignal === "number" ? abortAfter(timeoutOrSignal) : [void 0, timeoutOrSignal];
|
|
@@ -2074,7 +2092,6 @@ function demuxProbe(stream, probeSize = 1024, validator = validateDiscordOpusHea
|
|
|
2074
2092
|
});
|
|
2075
2093
|
}
|
|
2076
2094
|
__name(demuxProbe, "demuxProbe");
|
|
2077
|
-
module.exports = __toCommonJS(src_exports);
|
|
2078
2095
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2079
2096
|
0 && (module.exports = {
|
|
2080
2097
|
AudioPlayer,
|