@discordjs/voice 0.12.1-dev.1661947453-4bdb059.0 → 0.12.1-dev.1662077413-8a91d7c.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/dist/DataStore.cjs +3 -1
- package/dist/DataStore.cjs.map +1 -1
- package/dist/DataStore.d.ts +3 -7
- package/dist/DataStore.d.ts.map +1 -1
- package/dist/DataStore.mjs +3 -1
- package/dist/DataStore.mjs.map +1 -1
- package/dist/VoiceConnection.cjs +11 -13
- package/dist/VoiceConnection.cjs.map +1 -1
- package/dist/VoiceConnection.d.ts +26 -22
- package/dist/VoiceConnection.d.ts.map +1 -1
- package/dist/VoiceConnection.mjs +9 -11
- package/dist/VoiceConnection.mjs.map +1 -1
- package/dist/audio/AudioPlayer.cjs +17 -14
- package/dist/audio/AudioPlayer.cjs.map +1 -1
- package/dist/audio/AudioPlayer.d.ts +30 -32
- package/dist/audio/AudioPlayer.d.ts.map +1 -1
- package/dist/audio/AudioPlayer.mjs +15 -8
- package/dist/audio/AudioPlayer.mjs.map +1 -1
- package/dist/audio/AudioPlayerError.cjs.map +1 -1
- package/dist/audio/AudioPlayerError.d.ts.map +1 -1
- package/dist/audio/AudioPlayerError.mjs.map +1 -1
- package/dist/audio/AudioResource.cjs +1 -1
- package/dist/audio/AudioResource.cjs.map +1 -1
- package/dist/audio/AudioResource.d.ts +12 -16
- package/dist/audio/AudioResource.d.ts.map +1 -1
- package/dist/audio/AudioResource.mjs +1 -1
- package/dist/audio/AudioResource.mjs.map +1 -1
- package/dist/audio/PlayerSubscription.cjs.map +1 -1
- package/dist/audio/PlayerSubscription.d.ts +1 -1
- package/dist/audio/PlayerSubscription.d.ts.map +1 -1
- package/dist/audio/PlayerSubscription.mjs.map +1 -1
- package/dist/audio/TransformerGraph.cjs +9 -9
- package/dist/audio/TransformerGraph.cjs.map +1 -1
- package/dist/audio/TransformerGraph.d.ts +10 -10
- package/dist/audio/TransformerGraph.d.ts.map +1 -1
- package/dist/audio/TransformerGraph.mjs +9 -9
- package/dist/audio/TransformerGraph.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/joinVoiceChannel.cjs.map +1 -1
- package/dist/joinVoiceChannel.d.ts +6 -7
- package/dist/joinVoiceChannel.d.ts.map +1 -1
- package/dist/joinVoiceChannel.mjs.map +1 -1
- package/dist/networking/Networking.cjs +11 -10
- package/dist/networking/Networking.cjs.map +1 -1
- package/dist/networking/Networking.d.ts +23 -25
- package/dist/networking/Networking.d.ts.map +1 -1
- package/dist/networking/Networking.mjs +5 -4
- package/dist/networking/Networking.mjs.map +1 -1
- package/dist/networking/VoiceUDPSocket.cjs +9 -8
- package/dist/networking/VoiceUDPSocket.cjs.map +1 -1
- package/dist/networking/VoiceUDPSocket.d.ts +1 -0
- package/dist/networking/VoiceUDPSocket.d.ts.map +1 -1
- package/dist/networking/VoiceUDPSocket.mjs +4 -3
- package/dist/networking/VoiceUDPSocket.mjs.map +1 -1
- package/dist/networking/VoiceWebSocket.cjs +15 -14
- package/dist/networking/VoiceWebSocket.cjs.map +1 -1
- package/dist/networking/VoiceWebSocket.d.ts +1 -1
- package/dist/networking/VoiceWebSocket.d.ts.map +1 -1
- package/dist/networking/VoiceWebSocket.mjs +13 -12
- package/dist/networking/VoiceWebSocket.mjs.map +1 -1
- package/dist/receive/AudioReceiveStream.cjs +2 -4
- package/dist/receive/AudioReceiveStream.cjs.map +1 -1
- package/dist/receive/AudioReceiveStream.d.ts +5 -4
- package/dist/receive/AudioReceiveStream.d.ts.map +1 -1
- package/dist/receive/AudioReceiveStream.mjs +2 -4
- package/dist/receive/AudioReceiveStream.mjs.map +1 -1
- package/dist/receive/SSRCMap.cjs +2 -2
- package/dist/receive/SSRCMap.cjs.map +1 -1
- package/dist/receive/SSRCMap.d.ts +4 -5
- package/dist/receive/SSRCMap.d.ts.map +1 -1
- package/dist/receive/SSRCMap.mjs.map +1 -1
- package/dist/receive/SpeakingMap.cjs +2 -2
- package/dist/receive/SpeakingMap.cjs.map +1 -1
- package/dist/receive/SpeakingMap.d.ts +2 -0
- package/dist/receive/SpeakingMap.d.ts.map +1 -1
- package/dist/receive/SpeakingMap.mjs.map +1 -1
- package/dist/receive/VoiceReceiver.cjs +3 -2
- package/dist/receive/VoiceReceiver.cjs.map +1 -1
- package/dist/receive/VoiceReceiver.d.ts +4 -7
- package/dist/receive/VoiceReceiver.d.ts.map +1 -1
- package/dist/receive/VoiceReceiver.mjs +2 -1
- package/dist/receive/VoiceReceiver.mjs.map +1 -1
- package/dist/util/Secretbox.cjs +6 -4
- package/dist/util/Secretbox.cjs.map +1 -1
- package/dist/util/Secretbox.d.ts +4 -3
- package/dist/util/Secretbox.d.ts.map +1 -1
- package/dist/util/Secretbox.mjs +4 -2
- package/dist/util/Secretbox.mjs.map +1 -1
- package/dist/util/abortAfter.cjs.map +1 -1
- package/dist/util/abortAfter.d.ts.map +1 -1
- package/dist/util/abortAfter.mjs.map +1 -1
- package/dist/util/adapter.d.ts +12 -13
- package/dist/util/adapter.d.ts.map +1 -1
- package/dist/util/demuxProbe.cjs +18 -11
- package/dist/util/demuxProbe.cjs.map +1 -1
- package/dist/util/demuxProbe.d.ts +1 -2
- package/dist/util/demuxProbe.d.ts.map +1 -1
- package/dist/util/demuxProbe.mjs +14 -8
- package/dist/util/demuxProbe.mjs.map +1 -1
- package/dist/util/entersState.cjs +2 -2
- package/dist/util/entersState.cjs.map +1 -1
- package/dist/util/entersState.d.ts +2 -2
- package/dist/util/entersState.d.ts.map +1 -1
- package/dist/util/entersState.mjs.map +1 -1
- package/dist/util/generateDependencyReport.cjs +3 -3
- package/dist/util/generateDependencyReport.cjs.map +1 -1
- package/dist/util/generateDependencyReport.d.ts.map +1 -1
- package/dist/util/generateDependencyReport.mjs +3 -3
- package/dist/util/generateDependencyReport.mjs.map +1 -1
- package/dist/util/util.cjs.map +1 -1
- package/dist/util/util.d.ts.map +1 -1
- package/dist/util/util.mjs.map +1 -1
- package/package.json +2 -8
package/dist/DataStore.cjs
CHANGED
|
@@ -49,7 +49,9 @@ function audioCycleStep() {
|
|
|
49
49
|
return;
|
|
50
50
|
nextTime += FRAME_LENGTH;
|
|
51
51
|
const available = audioPlayers.filter((player) => player.checkPlayable());
|
|
52
|
-
|
|
52
|
+
for (const player of available) {
|
|
53
|
+
player["_stepDispatch"]();
|
|
54
|
+
}
|
|
53
55
|
prepareNextAudioFrame(available);
|
|
54
56
|
}
|
|
55
57
|
function prepareNextAudioFrame(players) {
|
package/dist/DataStore.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStore.cjs","sources":["../src/DataStore.ts"],"sourcesContent":["import { GatewayOpcodes } from 'discord-api-types/v10';\nimport type { VoiceConnection } from './VoiceConnection';\nimport type { AudioPlayer } from './audio';\n\nexport interface JoinConfig {\n\
|
|
1
|
+
{"version":3,"file":"DataStore.cjs","sources":["../src/DataStore.ts"],"sourcesContent":["import { GatewayOpcodes } from 'discord-api-types/v10';\nimport type { VoiceConnection } from './VoiceConnection';\nimport type { AudioPlayer } from './audio/index';\n\nexport interface JoinConfig {\n\tchannelId: string | null;\n\tgroup: string;\n\tguildId: string;\n\tselfDeaf: boolean;\n\tselfMute: boolean;\n}\n\n/**\n * Sends a voice state update to the main websocket shard of a guild, to indicate joining/leaving/moving across\n * voice channels.\n *\n * @param config - The configuration to use when joining the voice channel\n */\nexport function createJoinVoiceChannelPayload(config: JoinConfig) {\n\treturn {\n\t\top: GatewayOpcodes.VoiceStateUpdate,\n\t\t// eslint-disable-next-line id-length\n\t\td: {\n\t\t\tguild_id: config.guildId,\n\t\t\tchannel_id: config.channelId,\n\t\t\tself_deaf: config.selfDeaf,\n\t\t\tself_mute: config.selfMute,\n\t\t},\n\t};\n}\n\n// Voice Connections\nconst groups = new Map<string, Map<string, VoiceConnection>>();\ngroups.set('default', new Map());\n\nfunction getOrCreateGroup(group: string) {\n\tconst existing = groups.get(group);\n\tif (existing) return existing;\n\tconst map = new Map<string, VoiceConnection>();\n\tgroups.set(group, map);\n\treturn map;\n}\n\n/**\n * Retrieves the map of group names to maps of voice connections. By default, all voice connections\n * are created under the 'default' group.\n *\n * @returns The group map\n */\nexport function getGroups() {\n\treturn groups;\n}\n\n/**\n * Retrieves all the voice connections under the 'default' group.\n *\n * @param group - The group to look up\n * @returns The map of voice connections\n */\nexport function getVoiceConnections(group?: 'default'): Map<string, VoiceConnection>;\n\n/**\n * Retrieves all the voice connections under the given group name.\n *\n * @param group - The group to look up\n * @returns The map of voice connections\n */\nexport function getVoiceConnections(group: string): Map<string, VoiceConnection> | undefined;\n\n/**\n * Retrieves all the voice connections under the given group name. Defaults to the 'default' group.\n *\n * @param group - The group to look up\n * @returns The map of voice connections\n */\nexport function getVoiceConnections(group = 'default') {\n\treturn groups.get(group);\n}\n\n/**\n * Finds a voice connection with the given guild id and group. Defaults to the 'default' group.\n *\n * @param guildId - The guild id of the voice connection\n * @param group - the group that the voice connection was registered with\n * @returns The voice connection, if it exists\n */\nexport function getVoiceConnection(guildId: string, group = 'default') {\n\treturn getVoiceConnections(group)?.get(guildId);\n}\n\nexport function untrackVoiceConnection(voiceConnection: VoiceConnection) {\n\treturn getVoiceConnections(voiceConnection.joinConfig.group)?.delete(voiceConnection.joinConfig.guildId);\n}\n\nexport function trackVoiceConnection(voiceConnection: VoiceConnection) {\n\treturn getOrCreateGroup(voiceConnection.joinConfig.group).set(voiceConnection.joinConfig.guildId, voiceConnection);\n}\n\n// Audio Players\n\n// Each audio packet is 20ms long\nconst FRAME_LENGTH = 20;\n\nlet audioCycleInterval: NodeJS.Timeout | undefined;\nlet nextTime = -1;\n\n/**\n * A list of created audio players that are still active and haven't been destroyed.\n */\nconst audioPlayers: AudioPlayer[] = [];\n\n/**\n * Called roughly every 20 milliseconds. Dispatches audio from all players, and then gets the players to prepare\n * the next audio frame.\n */\nfunction audioCycleStep() {\n\tif (nextTime === -1) return;\n\n\tnextTime += FRAME_LENGTH;\n\tconst available = audioPlayers.filter((player) => player.checkPlayable());\n\n\tfor (const player of available) {\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tplayer['_stepDispatch']();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-use-before-define\n\tprepareNextAudioFrame(available);\n}\n\n/**\n * Recursively gets the players that have been passed as parameters to prepare audio frames that can be played\n * at the start of the next cycle.\n */\nfunction prepareNextAudioFrame(players: AudioPlayer[]) {\n\tconst nextPlayer = players.shift();\n\n\tif (!nextPlayer) {\n\t\tif (nextTime !== -1) {\n\t\t\taudioCycleInterval = setTimeout(() => audioCycleStep(), nextTime - Date.now());\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tnextPlayer['_stepPrepare']();\n\n\t// setImmediate to avoid long audio player chains blocking other scheduled tasks\n\tsetImmediate(() => prepareNextAudioFrame(players));\n}\n\n/**\n * Checks whether or not the given audio player is being driven by the data store clock.\n *\n * @param target - The target to test for\n * @returns `true` if it is being tracked, `false` otherwise\n */\nexport function hasAudioPlayer(target: AudioPlayer) {\n\treturn audioPlayers.includes(target);\n}\n\n/**\n * Adds an audio player to the data store tracking list, if it isn't already there.\n *\n * @param player - The player to track\n */\nexport function addAudioPlayer(player: AudioPlayer) {\n\tif (hasAudioPlayer(player)) return player;\n\taudioPlayers.push(player);\n\tif (audioPlayers.length === 1) {\n\t\tnextTime = Date.now();\n\t\tsetImmediate(() => audioCycleStep());\n\t}\n\n\treturn player;\n}\n\n/**\n * Removes an audio player from the data store tracking list, if it is present there.\n */\nexport function deleteAudioPlayer(player: AudioPlayer) {\n\tconst index = audioPlayers.indexOf(player);\n\tif (index === -1) return;\n\taudioPlayers.splice(index, 1);\n\tif (audioPlayers.length === 0) {\n\t\tnextTime = -1;\n\t\tif (typeof audioCycleInterval !== 'undefined') clearTimeout(audioCycleInterval);\n\t}\n}\n"],"names":["GatewayOpcodes"],"mappings":";;;;;;AACO,SAAS,6BAA6B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C,CAAC,CAAC;AACrD,CAAC;AACM,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,EAAE,OAAO,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AACM,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC;AAC5B,IAAI,OAAO,MAAM,CAAC;AAClB,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,EAAE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;AACjC,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAC1B,IAAI,YAAY,CAAC,MAAM,cAAc,EAAE,CAAC,CAAC;AACzC,GAAG;AACH,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC;AACM,SAAS,iBAAiB,CAAC,MAAM,EAAE;AAC1C,EAAE,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7C,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC;AAClB,IAAI,OAAO;AACX,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AAChC,EAAE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;AACjC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC;AAClB,IAAI,IAAI,OAAO,kBAAkB,KAAK,WAAW;AACjD,MAAM,YAAY,CAAC,kBAAkB,CAAC,CAAC;AACvC,GAAG;AACH;;;;;;;;;;;;"}
|
package/dist/DataStore.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { GatewayOpcodes } from 'discord-api-types/v10';
|
|
2
2
|
import type { VoiceConnection } from './VoiceConnection';
|
|
3
|
-
import type { AudioPlayer } from './audio';
|
|
3
|
+
import type { AudioPlayer } from './audio/index';
|
|
4
4
|
export interface JoinConfig {
|
|
5
|
-
guildId: string;
|
|
6
5
|
channelId: string | null;
|
|
6
|
+
group: string;
|
|
7
|
+
guildId: string;
|
|
7
8
|
selfDeaf: boolean;
|
|
8
9
|
selfMute: boolean;
|
|
9
|
-
group: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Sends a voice state update to the main websocket shard of a guild, to indicate joining/leaving/moving across
|
|
@@ -34,7 +34,6 @@ export declare function getGroups(): Map<string, Map<string, VoiceConnection>>;
|
|
|
34
34
|
* Retrieves all the voice connections under the 'default' group.
|
|
35
35
|
*
|
|
36
36
|
* @param group - The group to look up
|
|
37
|
-
*
|
|
38
37
|
* @returns The map of voice connections
|
|
39
38
|
*/
|
|
40
39
|
export declare function getVoiceConnections(group?: 'default'): Map<string, VoiceConnection>;
|
|
@@ -42,7 +41,6 @@ export declare function getVoiceConnections(group?: 'default'): Map<string, Voic
|
|
|
42
41
|
* Retrieves all the voice connections under the given group name.
|
|
43
42
|
*
|
|
44
43
|
* @param group - The group to look up
|
|
45
|
-
*
|
|
46
44
|
* @returns The map of voice connections
|
|
47
45
|
*/
|
|
48
46
|
export declare function getVoiceConnections(group: string): Map<string, VoiceConnection> | undefined;
|
|
@@ -51,7 +49,6 @@ export declare function getVoiceConnections(group: string): Map<string, VoiceCon
|
|
|
51
49
|
*
|
|
52
50
|
* @param guildId - The guild id of the voice connection
|
|
53
51
|
* @param group - the group that the voice connection was registered with
|
|
54
|
-
*
|
|
55
52
|
* @returns The voice connection, if it exists
|
|
56
53
|
*/
|
|
57
54
|
export declare function getVoiceConnection(guildId: string, group?: string): VoiceConnection | undefined;
|
|
@@ -61,7 +58,6 @@ export declare function trackVoiceConnection(voiceConnection: VoiceConnection):
|
|
|
61
58
|
* Checks whether or not the given audio player is being driven by the data store clock.
|
|
62
59
|
*
|
|
63
60
|
* @param target - The target to test for
|
|
64
|
-
*
|
|
65
61
|
* @returns `true` if it is being tracked, `false` otherwise
|
|
66
62
|
*/
|
|
67
63
|
export declare function hasAudioPlayer(target: AudioPlayer): boolean;
|
package/dist/DataStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../src/DataStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../src/DataStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,UAAU;;;;;;;;EAW/D;AAcD;;;;;GAKG;AACH,wBAAgB,SAAS,8CAExB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;AAY7F;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAY,+BAEpE;AAED,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,eAAe,uBAEtE;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,gCAEpE;AAwDD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,WAEjD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,eASjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,QAQpD"}
|
package/dist/DataStore.mjs
CHANGED
|
@@ -45,7 +45,9 @@ function audioCycleStep() {
|
|
|
45
45
|
return;
|
|
46
46
|
nextTime += FRAME_LENGTH;
|
|
47
47
|
const available = audioPlayers.filter((player) => player.checkPlayable());
|
|
48
|
-
|
|
48
|
+
for (const player of available) {
|
|
49
|
+
player["_stepDispatch"]();
|
|
50
|
+
}
|
|
49
51
|
prepareNextAudioFrame(available);
|
|
50
52
|
}
|
|
51
53
|
function prepareNextAudioFrame(players) {
|
package/dist/DataStore.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStore.mjs","sources":["../src/DataStore.ts"],"sourcesContent":["import { GatewayOpcodes } from 'discord-api-types/v10';\nimport type { VoiceConnection } from './VoiceConnection';\nimport type { AudioPlayer } from './audio';\n\nexport interface JoinConfig {\n\
|
|
1
|
+
{"version":3,"file":"DataStore.mjs","sources":["../src/DataStore.ts"],"sourcesContent":["import { GatewayOpcodes } from 'discord-api-types/v10';\nimport type { VoiceConnection } from './VoiceConnection';\nimport type { AudioPlayer } from './audio/index';\n\nexport interface JoinConfig {\n\tchannelId: string | null;\n\tgroup: string;\n\tguildId: string;\n\tselfDeaf: boolean;\n\tselfMute: boolean;\n}\n\n/**\n * Sends a voice state update to the main websocket shard of a guild, to indicate joining/leaving/moving across\n * voice channels.\n *\n * @param config - The configuration to use when joining the voice channel\n */\nexport function createJoinVoiceChannelPayload(config: JoinConfig) {\n\treturn {\n\t\top: GatewayOpcodes.VoiceStateUpdate,\n\t\t// eslint-disable-next-line id-length\n\t\td: {\n\t\t\tguild_id: config.guildId,\n\t\t\tchannel_id: config.channelId,\n\t\t\tself_deaf: config.selfDeaf,\n\t\t\tself_mute: config.selfMute,\n\t\t},\n\t};\n}\n\n// Voice Connections\nconst groups = new Map<string, Map<string, VoiceConnection>>();\ngroups.set('default', new Map());\n\nfunction getOrCreateGroup(group: string) {\n\tconst existing = groups.get(group);\n\tif (existing) return existing;\n\tconst map = new Map<string, VoiceConnection>();\n\tgroups.set(group, map);\n\treturn map;\n}\n\n/**\n * Retrieves the map of group names to maps of voice connections. By default, all voice connections\n * are created under the 'default' group.\n *\n * @returns The group map\n */\nexport function getGroups() {\n\treturn groups;\n}\n\n/**\n * Retrieves all the voice connections under the 'default' group.\n *\n * @param group - The group to look up\n * @returns The map of voice connections\n */\nexport function getVoiceConnections(group?: 'default'): Map<string, VoiceConnection>;\n\n/**\n * Retrieves all the voice connections under the given group name.\n *\n * @param group - The group to look up\n * @returns The map of voice connections\n */\nexport function getVoiceConnections(group: string): Map<string, VoiceConnection> | undefined;\n\n/**\n * Retrieves all the voice connections under the given group name. Defaults to the 'default' group.\n *\n * @param group - The group to look up\n * @returns The map of voice connections\n */\nexport function getVoiceConnections(group = 'default') {\n\treturn groups.get(group);\n}\n\n/**\n * Finds a voice connection with the given guild id and group. Defaults to the 'default' group.\n *\n * @param guildId - The guild id of the voice connection\n * @param group - the group that the voice connection was registered with\n * @returns The voice connection, if it exists\n */\nexport function getVoiceConnection(guildId: string, group = 'default') {\n\treturn getVoiceConnections(group)?.get(guildId);\n}\n\nexport function untrackVoiceConnection(voiceConnection: VoiceConnection) {\n\treturn getVoiceConnections(voiceConnection.joinConfig.group)?.delete(voiceConnection.joinConfig.guildId);\n}\n\nexport function trackVoiceConnection(voiceConnection: VoiceConnection) {\n\treturn getOrCreateGroup(voiceConnection.joinConfig.group).set(voiceConnection.joinConfig.guildId, voiceConnection);\n}\n\n// Audio Players\n\n// Each audio packet is 20ms long\nconst FRAME_LENGTH = 20;\n\nlet audioCycleInterval: NodeJS.Timeout | undefined;\nlet nextTime = -1;\n\n/**\n * A list of created audio players that are still active and haven't been destroyed.\n */\nconst audioPlayers: AudioPlayer[] = [];\n\n/**\n * Called roughly every 20 milliseconds. Dispatches audio from all players, and then gets the players to prepare\n * the next audio frame.\n */\nfunction audioCycleStep() {\n\tif (nextTime === -1) return;\n\n\tnextTime += FRAME_LENGTH;\n\tconst available = audioPlayers.filter((player) => player.checkPlayable());\n\n\tfor (const player of available) {\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tplayer['_stepDispatch']();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-use-before-define\n\tprepareNextAudioFrame(available);\n}\n\n/**\n * Recursively gets the players that have been passed as parameters to prepare audio frames that can be played\n * at the start of the next cycle.\n */\nfunction prepareNextAudioFrame(players: AudioPlayer[]) {\n\tconst nextPlayer = players.shift();\n\n\tif (!nextPlayer) {\n\t\tif (nextTime !== -1) {\n\t\t\taudioCycleInterval = setTimeout(() => audioCycleStep(), nextTime - Date.now());\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\tnextPlayer['_stepPrepare']();\n\n\t// setImmediate to avoid long audio player chains blocking other scheduled tasks\n\tsetImmediate(() => prepareNextAudioFrame(players));\n}\n\n/**\n * Checks whether or not the given audio player is being driven by the data store clock.\n *\n * @param target - The target to test for\n * @returns `true` if it is being tracked, `false` otherwise\n */\nexport function hasAudioPlayer(target: AudioPlayer) {\n\treturn audioPlayers.includes(target);\n}\n\n/**\n * Adds an audio player to the data store tracking list, if it isn't already there.\n *\n * @param player - The player to track\n */\nexport function addAudioPlayer(player: AudioPlayer) {\n\tif (hasAudioPlayer(player)) return player;\n\taudioPlayers.push(player);\n\tif (audioPlayers.length === 1) {\n\t\tnextTime = Date.now();\n\t\tsetImmediate(() => audioCycleStep());\n\t}\n\n\treturn player;\n}\n\n/**\n * Removes an audio player from the data store tracking list, if it is present there.\n */\nexport function deleteAudioPlayer(player: AudioPlayer) {\n\tconst index = audioPlayers.indexOf(player);\n\tif (index === -1) return;\n\taudioPlayers.splice(index, 1);\n\tif (audioPlayers.length === 0) {\n\t\tnextTime = -1;\n\t\tif (typeof audioCycleInterval !== 'undefined') clearTimeout(audioCycleInterval);\n\t}\n}\n"],"names":[],"mappings":";;AACO,SAAS,6BAA6B,CAAC,MAAM,EAAE;AACtD,EAAE,OAAO;AACT,IAAI,EAAE,EAAE,cAAc,CAAC,gBAAgB;AACvC,IAAI,CAAC,EAAE;AACP,MAAM,QAAQ,EAAE,MAAM,CAAC,OAAO;AAC9B,MAAM,UAAU,EAAE,MAAM,CAAC,SAAS;AAClC,MAAM,SAAS,EAAE,MAAM,CAAC,QAAQ;AAChC,MAAM,SAAS,EAAE,MAAM,CAAC,QAAQ;AAChC,KAAK;AACL,GAAG,CAAC;AACJ,CAAC;AACD,MAAM,MAAM,mBAAmB,IAAI,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,GAAG,CAAC,SAAS,kBAAkB,IAAI,GAAG,EAAE,CAAC,CAAC;AACjD,SAAS,gBAAgB,CAAC,KAAK,EAAE;AACjC,EAAE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrC,EAAE,IAAI,QAAQ;AACd,IAAI,OAAO,QAAQ,CAAC;AACpB,EAAE,MAAM,GAAG,mBAAmB,IAAI,GAAG,EAAE,CAAC;AACxC,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzB,EAAE,OAAO,GAAG,CAAC;AACb,CAAC;AACM,SAAS,SAAS,GAAG;AAC5B,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC;AACM,SAAS,mBAAmB,CAAC,KAAK,GAAG,SAAS,EAAE;AACvD,EAAE,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AACM,SAAS,kBAAkB,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,EAAE;AAC/D,E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
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const node_events = require('node:events');
|
|
6
6
|
const DataStore = require('./DataStore.cjs');
|
|
7
7
|
const Networking = require('./networking/Networking.cjs');
|
|
8
8
|
const VoiceReceiver = require('./receive/VoiceReceiver.cjs');
|
|
@@ -12,11 +12,11 @@ require('./receive/SpeakingMap.cjs');
|
|
|
12
12
|
const util = require('./util/util.cjs');
|
|
13
13
|
|
|
14
14
|
var VoiceConnectionStatus = /* @__PURE__ */ ((VoiceConnectionStatus2) => {
|
|
15
|
-
VoiceConnectionStatus2["Signalling"] = "signalling";
|
|
16
15
|
VoiceConnectionStatus2["Connecting"] = "connecting";
|
|
17
|
-
VoiceConnectionStatus2["Ready"] = "ready";
|
|
18
|
-
VoiceConnectionStatus2["Disconnected"] = "disconnected";
|
|
19
16
|
VoiceConnectionStatus2["Destroyed"] = "destroyed";
|
|
17
|
+
VoiceConnectionStatus2["Disconnected"] = "disconnected";
|
|
18
|
+
VoiceConnectionStatus2["Ready"] = "ready";
|
|
19
|
+
VoiceConnectionStatus2["Signalling"] = "signalling";
|
|
20
20
|
return VoiceConnectionStatus2;
|
|
21
21
|
})(VoiceConnectionStatus || {});
|
|
22
22
|
var VoiceConnectionDisconnectReason = /* @__PURE__ */ ((VoiceConnectionDisconnectReason2) => {
|
|
@@ -26,7 +26,7 @@ var VoiceConnectionDisconnectReason = /* @__PURE__ */ ((VoiceConnectionDisconnec
|
|
|
26
26
|
VoiceConnectionDisconnectReason2[VoiceConnectionDisconnectReason2["Manual"] = 3] = "Manual";
|
|
27
27
|
return VoiceConnectionDisconnectReason2;
|
|
28
28
|
})(VoiceConnectionDisconnectReason || {});
|
|
29
|
-
class VoiceConnection extends
|
|
29
|
+
class VoiceConnection extends node_events.EventEmitter {
|
|
30
30
|
constructor(joinConfig, { debug, adapterCreator }) {
|
|
31
31
|
super();
|
|
32
32
|
this.debug = debug ? (message) => this.emit("debug", message) : null;
|
|
@@ -334,14 +334,12 @@ function createVoiceConnection(joinConfig, options) {
|
|
|
334
334
|
}
|
|
335
335
|
const voiceConnection = new VoiceConnection(joinConfig, options);
|
|
336
336
|
DataStore.trackVoiceConnection(voiceConnection);
|
|
337
|
-
if (voiceConnection.state.status !== "destroyed" /* Destroyed */) {
|
|
338
|
-
|
|
339
|
-
voiceConnection.state
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
};
|
|
344
|
-
}
|
|
337
|
+
if (voiceConnection.state.status !== "destroyed" /* Destroyed */ && !voiceConnection.state.adapter.sendPayload(payload)) {
|
|
338
|
+
voiceConnection.state = {
|
|
339
|
+
...voiceConnection.state,
|
|
340
|
+
status: "disconnected" /* Disconnected */,
|
|
341
|
+
reason: 1 /* AdapterUnavailable */
|
|
342
|
+
};
|
|
345
343
|
}
|
|
346
344
|
return voiceConnection;
|
|
347
345
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceConnection.cjs","sources":["../src/VoiceConnection.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/method-signature-style */\nimport { EventEmitter } from 'node:events';\nimport type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';\nimport type { CreateVoiceConnectionOptions } from '.';\nimport {\n\tgetVoiceConnection,\n\tcreateJoinVoiceChannelPayload,\n\ttrackVoiceConnection,\n\tJoinConfig,\n\tuntrackVoiceConnection,\n} from './DataStore';\nimport type { AudioPlayer } from './audio/AudioPlayer';\nimport type { PlayerSubscription } from './audio/PlayerSubscription';\nimport type { VoiceWebSocket, VoiceUDPSocket } from './networking';\nimport { Networking, NetworkingState, NetworkingStatusCode } from './networking/Networking';\nimport { VoiceReceiver } from './receive';\nimport type { DiscordGatewayAdapterImplementerMethods } from './util/adapter';\nimport { noop } from './util/util';\n\n/**\n * The various status codes a voice connection can hold at any one time.\n */\nexport enum VoiceConnectionStatus {\n\t/**\n\t * Sending a packet to the main Discord gateway to indicate we want to change our voice state.\n\t */\n\tSignalling = 'signalling',\n\n\t/**\n\t * The `VOICE_SERVER_UPDATE` and `VOICE_STATE_UPDATE` packets have been received, now attempting to establish a voice connection.\n\t */\n\tConnecting = 'connecting',\n\n\t/**\n\t * A voice connection has been established, and is ready to be used.\n\t */\n\tReady = 'ready',\n\n\t/**\n\t * The voice connection has either been severed or not established.\n\t */\n\tDisconnected = 'disconnected',\n\n\t/**\n\t * The voice connection has been destroyed and untracked, it cannot be reused.\n\t */\n\tDestroyed = 'destroyed',\n}\n\n/**\n * The state that a VoiceConnection will be in when it is waiting to receive a VOICE_SERVER_UPDATE and\n * VOICE_STATE_UPDATE packet from Discord, provided by the adapter.\n */\nexport interface VoiceConnectionSignallingState {\n\tstatus: VoiceConnectionStatus.Signalling;\n\tsubscription?: PlayerSubscription | undefined;\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n}\n\n/**\n * The reasons a voice connection can be in the disconnected state.\n */\nexport enum VoiceConnectionDisconnectReason {\n\t/**\n\t * When the WebSocket connection has been closed.\n\t */\n\tWebSocketClose,\n\n\t/**\n\t * When the adapter was unable to send a message requested by the VoiceConnection.\n\t */\n\tAdapterUnavailable,\n\n\t/**\n\t * When a VOICE_SERVER_UPDATE packet is received with a null endpoint, causing the connection to be severed.\n\t */\n\tEndpointRemoved,\n\n\t/**\n\t * When a manual disconnect was requested.\n\t */\n\tManual,\n}\n\n/**\n * The state that a VoiceConnection will be in when it is not connected to a Discord voice server nor is\n * it attempting to connect. You can manually attempt to reconnect using VoiceConnection#reconnect.\n */\nexport interface VoiceConnectionDisconnectedBaseState {\n\tstatus: VoiceConnectionStatus.Disconnected;\n\tsubscription?: PlayerSubscription | undefined;\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n}\n\n/**\n * The state that a VoiceConnection will be in when it is not connected to a Discord voice server nor is\n * it attempting to connect. You can manually attempt to reconnect using VoiceConnection#reconnect.\n */\nexport interface VoiceConnectionDisconnectedOtherState extends VoiceConnectionDisconnectedBaseState {\n\treason: Exclude<VoiceConnectionDisconnectReason, VoiceConnectionDisconnectReason.WebSocketClose>;\n}\n\n/**\n * The state that a VoiceConnection will be in when its WebSocket connection was closed.\n * You can manually attempt to reconnect using VoiceConnection#reconnect.\n */\nexport interface VoiceConnectionDisconnectedWebSocketState extends VoiceConnectionDisconnectedBaseState {\n\treason: VoiceConnectionDisconnectReason.WebSocketClose;\n\n\t/**\n\t * The close code of the WebSocket connection to the Discord voice server.\n\t */\n\tcloseCode: number;\n}\n\n/**\n * The states that a VoiceConnection can be in when it is not connected to a Discord voice server nor is\n * it attempting to connect. You can manually attempt to connect using VoiceConnection#reconnect.\n */\nexport type VoiceConnectionDisconnectedState =\n\t| VoiceConnectionDisconnectedOtherState\n\t| VoiceConnectionDisconnectedWebSocketState;\n\n/**\n * The state that a VoiceConnection will be in when it is establishing a connection to a Discord\n * voice server.\n */\nexport interface VoiceConnectionConnectingState {\n\tstatus: VoiceConnectionStatus.Connecting;\n\tnetworking: Networking;\n\tsubscription?: PlayerSubscription | undefined;\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n}\n\n/**\n * The state that a VoiceConnection will be in when it has an active connection to a Discord\n * voice server.\n */\nexport interface VoiceConnectionReadyState {\n\tstatus: VoiceConnectionStatus.Ready;\n\tnetworking: Networking;\n\tsubscription?: PlayerSubscription | undefined;\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n}\n\n/**\n * The state that a VoiceConnection will be in when it has been permanently been destroyed by the\n * user and untracked by the library. It cannot be reconnected, instead, a new VoiceConnection\n * needs to be established.\n */\nexport interface VoiceConnectionDestroyedState {\n\tstatus: VoiceConnectionStatus.Destroyed;\n}\n\n/**\n * The various states that a voice connection can be in.\n */\nexport type VoiceConnectionState =\n\t| VoiceConnectionSignallingState\n\t| VoiceConnectionDisconnectedState\n\t| VoiceConnectionConnectingState\n\t| VoiceConnectionReadyState\n\t| VoiceConnectionDestroyedState;\n\nexport interface VoiceConnection extends EventEmitter {\n\t/**\n\t * Emitted when there is an error emitted from the voice connection\n\t * @eventProperty\n\t */\n\ton(event: 'error', listener: (error: Error) => void): this;\n\t/**\n\t * Emitted debugging information about the voice connection\n\t * @eventProperty\n\t */\n\ton(event: 'debug', listener: (message: string) => void): this;\n\t/**\n\t * Emitted when the state of the voice connection changes\n\t * @eventProperty\n\t */\n\ton(event: 'stateChange', listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState) => void): this;\n\t/**\n\t * Emitted when the state of the voice connection changes to a specific status\n\t * @eventProperty\n\t */\n\ton<T extends VoiceConnectionStatus>(\n\t\tevent: T,\n\t\tlistener: (oldState: VoiceConnectionState, newState: VoiceConnectionState & { status: T }) => void,\n\t): this;\n}\n\n/**\n * A connection to the voice server of a Guild, can be used to play audio in voice channels.\n */\nexport class VoiceConnection extends EventEmitter {\n\t/**\n\t * The number of consecutive rejoin attempts. Initially 0, and increments for each rejoin.\n\t * When a connection is successfully established, it resets to 0.\n\t */\n\tpublic rejoinAttempts: number;\n\n\t/**\n\t * The state of the voice connection.\n\t */\n\tprivate _state: VoiceConnectionState;\n\n\t/**\n\t * A configuration storing all the data needed to reconnect to a Guild's voice server.\n\t *\n\t * @internal\n\t */\n\tpublic readonly joinConfig: JoinConfig;\n\n\t/**\n\t * The two packets needed to successfully establish a voice connection. They are received\n\t * from the main Discord gateway after signalling to change the voice state.\n\t */\n\tprivate readonly packets: {\n\t\tserver: GatewayVoiceServerUpdateDispatchData | undefined;\n\t\tstate: GatewayVoiceStateUpdateDispatchData | undefined;\n\t};\n\n\t/**\n\t * The receiver of this voice connection. You should join the voice channel with `selfDeaf` set\n\t * to false for this feature to work properly.\n\t */\n\tpublic readonly receiver: VoiceReceiver;\n\n\t/**\n\t * The debug logger function, if debugging is enabled.\n\t */\n\tprivate readonly debug: null | ((message: string) => void);\n\n\t/**\n\t * Creates a new voice connection.\n\t *\n\t * @param joinConfig - The data required to establish the voice connection\n\t * @param options - The options used to create this voice connection\n\t */\n\tpublic constructor(joinConfig: JoinConfig, { debug, adapterCreator }: CreateVoiceConnectionOptions) {\n\t\tsuper();\n\n\t\tthis.debug = debug ? (message: string) => this.emit('debug', message) : null;\n\t\tthis.rejoinAttempts = 0;\n\n\t\tthis.receiver = new VoiceReceiver(this);\n\n\t\tthis.onNetworkingClose = this.onNetworkingClose.bind(this);\n\t\tthis.onNetworkingStateChange = this.onNetworkingStateChange.bind(this);\n\t\tthis.onNetworkingError = this.onNetworkingError.bind(this);\n\t\tthis.onNetworkingDebug = this.onNetworkingDebug.bind(this);\n\n\t\tconst adapter = adapterCreator({\n\t\t\tonVoiceServerUpdate: (data) => this.addServerPacket(data),\n\t\t\tonVoiceStateUpdate: (data) => this.addStatePacket(data),\n\t\t\tdestroy: () => this.destroy(false),\n\t\t});\n\n\t\tthis._state = { status: VoiceConnectionStatus.Signalling, adapter };\n\n\t\tthis.packets = {\n\t\t\tserver: undefined,\n\t\t\tstate: undefined,\n\t\t};\n\n\t\tthis.joinConfig = joinConfig;\n\t}\n\n\t/**\n\t * The current state of the voice connection.\n\t */\n\tpublic get state() {\n\t\treturn this._state;\n\t}\n\n\t/**\n\t * Updates the state of the voice connection, performing clean-up operations where necessary.\n\t */\n\tpublic set state(newState: VoiceConnectionState) {\n\t\tconst oldState = this._state;\n\t\tconst oldNetworking = Reflect.get(oldState, 'networking') as Networking | undefined;\n\t\tconst newNetworking = Reflect.get(newState, 'networking') as Networking | undefined;\n\n\t\tconst oldSubscription = Reflect.get(oldState, 'subscription') as PlayerSubscription | undefined;\n\t\tconst newSubscription = Reflect.get(newState, 'subscription') as PlayerSubscription | undefined;\n\n\t\tif (oldNetworking !== newNetworking) {\n\t\t\tif (oldNetworking) {\n\t\t\t\toldNetworking.on('error', noop);\n\t\t\t\toldNetworking.off('debug', this.onNetworkingDebug);\n\t\t\t\toldNetworking.off('error', this.onNetworkingError);\n\t\t\t\toldNetworking.off('close', this.onNetworkingClose);\n\t\t\t\toldNetworking.off('stateChange', this.onNetworkingStateChange);\n\t\t\t\toldNetworking.destroy();\n\t\t\t}\n\t\t\tif (newNetworking) this.updateReceiveBindings(newNetworking.state, oldNetworking?.state);\n\t\t}\n\n\t\tif (newState.status === VoiceConnectionStatus.Ready) {\n\t\t\tthis.rejoinAttempts = 0;\n\t\t} else if (newState.status === VoiceConnectionStatus.Destroyed) {\n\t\t\tfor (const stream of this.receiver.subscriptions.values()) {\n\t\t\t\tif (!stream.destroyed) stream.destroy();\n\t\t\t}\n\t\t}\n\n\t\t// If destroyed, the adapter can also be destroyed so it can be cleaned up by the user\n\t\tif (oldState.status !== VoiceConnectionStatus.Destroyed && newState.status === VoiceConnectionStatus.Destroyed) {\n\t\t\toldState.adapter.destroy();\n\t\t}\n\n\t\tthis._state = newState;\n\n\t\tif (oldSubscription && oldSubscription !== newSubscription) {\n\t\t\toldSubscription.unsubscribe();\n\t\t}\n\n\t\tthis.emit('stateChange', oldState, newState);\n\t\tif (oldState.status !== newState.status) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tthis.emit(newState.status, oldState, newState as any);\n\t\t}\n\t}\n\n\t/**\n\t * Registers a `VOICE_SERVER_UPDATE` packet to the voice connection. This will cause it to reconnect using the\n\t * new data provided in the packet.\n\t *\n\t * @param packet - The received `VOICE_SERVER_UPDATE` packet\n\t */\n\tprivate addServerPacket(packet: GatewayVoiceServerUpdateDispatchData) {\n\t\tthis.packets.server = packet;\n\t\tif (packet.endpoint) {\n\t\t\tthis.configureNetworking();\n\t\t} else if (this.state.status !== VoiceConnectionStatus.Destroyed) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.EndpointRemoved,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Registers a `VOICE_STATE_UPDATE` packet to the voice connection. Most importantly, it stores the id of the\n\t * channel that the client is connected to.\n\t *\n\t * @param packet - The received `VOICE_STATE_UPDATE` packet\n\t */\n\tprivate addStatePacket(packet: GatewayVoiceStateUpdateDispatchData) {\n\t\tthis.packets.state = packet;\n\n\t\tif (typeof packet.self_deaf !== 'undefined') this.joinConfig.selfDeaf = packet.self_deaf;\n\t\tif (typeof packet.self_mute !== 'undefined') this.joinConfig.selfMute = packet.self_mute;\n\t\tif (packet.channel_id) this.joinConfig.channelId = packet.channel_id;\n\t\t/*\n\t\t\tthe channel_id being null doesn't necessarily mean it was intended for the client to leave the voice channel\n\t\t\tas it may have disconnected due to network failure. This will be gracefully handled once the voice websocket\n\t\t\tdies, and then it is up to the user to decide how they wish to handle this.\n\t\t*/\n\t}\n\n\t/**\n\t * Called when the networking state changes, and the new ws/udp packet/message handlers need to be rebound\n\t * to the new instances.\n\t * @param newState - The new networking state\n\t * @param oldState - The old networking state, if there is one\n\t */\n\tprivate updateReceiveBindings(newState: NetworkingState, oldState?: NetworkingState) {\n\t\tconst oldWs = Reflect.get(oldState ?? {}, 'ws') as VoiceWebSocket | undefined;\n\t\tconst newWs = Reflect.get(newState, 'ws') as VoiceWebSocket | undefined;\n\t\tconst oldUdp = Reflect.get(oldState ?? {}, 'udp') as VoiceUDPSocket | undefined;\n\t\tconst newUdp = Reflect.get(newState, 'udp') as VoiceUDPSocket | undefined;\n\n\t\tif (oldWs !== newWs) {\n\t\t\toldWs?.off('packet', this.receiver.onWsPacket);\n\t\t\tnewWs?.on('packet', this.receiver.onWsPacket);\n\t\t}\n\n\t\tif (oldUdp !== newUdp) {\n\t\t\toldUdp?.off('message', this.receiver.onUdpMessage);\n\t\t\tnewUdp?.on('message', this.receiver.onUdpMessage);\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tthis.receiver.connectionData = Reflect.get(newState, 'connectionData') ?? {};\n\t}\n\n\t/**\n\t * Attempts to configure a networking instance for this voice connection using the received packets.\n\t * Both packets are required, and any existing networking instance will be destroyed.\n\t *\n\t * @remarks\n\t * This is called when the voice server of the connection changes, e.g. if the bot is moved into a\n\t * different channel in the same guild but has a different voice server. In this instance, the connection\n\t * needs to be re-established to the new voice server.\n\t *\n\t * The connection will transition to the Connecting state when this is called.\n\t */\n\tpublic configureNetworking() {\n\t\tconst { server, state } = this.packets;\n\t\tif (!server || !state || this.state.status === VoiceConnectionStatus.Destroyed || !server.endpoint) return;\n\n\t\tconst networking = new Networking(\n\t\t\t{\n\t\t\t\tendpoint: server.endpoint,\n\t\t\t\tserverId: server.guild_id,\n\t\t\t\ttoken: server.token,\n\t\t\t\tsessionId: state.session_id,\n\t\t\t\tuserId: state.user_id,\n\t\t\t},\n\t\t\tBoolean(this.debug),\n\t\t);\n\n\t\tnetworking.once('close', this.onNetworkingClose);\n\t\tnetworking.on('stateChange', this.onNetworkingStateChange);\n\t\tnetworking.on('error', this.onNetworkingError);\n\t\tnetworking.on('debug', this.onNetworkingDebug);\n\n\t\tthis.state = {\n\t\t\t...this.state,\n\t\t\tstatus: VoiceConnectionStatus.Connecting,\n\t\t\tnetworking,\n\t\t};\n\t}\n\n\t/**\n\t * Called when the networking instance for this connection closes. If the close code is 4014 (do not reconnect),\n\t * the voice connection will transition to the Disconnected state which will store the close code. You can\n\t * decide whether or not to reconnect when this occurs by listening for the state change and calling reconnect().\n\t *\n\t * @remarks\n\t * If the close code was anything other than 4014, it is likely that the closing was not intended, and so the\n\t * VoiceConnection will signal to Discord that it would like to rejoin the channel. This automatically attempts\n\t * to re-establish the connection. This would be seen as a transition from the Ready state to the Signalling state.\n\t *\n\t * @param code - The close code\n\t */\n\tprivate onNetworkingClose(code: number) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) return;\n\t\t// If networking closes, try to connect to the voice channel again.\n\t\tif (code === 4014) {\n\t\t\t// Disconnected - networking is already destroyed here\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.WebSocketClose,\n\t\t\t\tcloseCode: code,\n\t\t\t};\n\t\t} else {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Signalling,\n\t\t\t};\n\t\t\tthis.rejoinAttempts++;\n\t\t\tif (!this.state.adapter.sendPayload(createJoinVoiceChannelPayload(this.joinConfig))) {\n\t\t\t\tthis.state = {\n\t\t\t\t\t...this.state,\n\t\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Called when the state of the networking instance changes. This is used to derive the state of the voice connection.\n\t *\n\t * @param oldState - The previous state\n\t * @param newState - The new state\n\t */\n\tprivate onNetworkingStateChange(oldState: NetworkingState, newState: NetworkingState) {\n\t\tthis.updateReceiveBindings(newState, oldState);\n\t\tif (oldState.code === newState.code) return;\n\t\tif (this.state.status !== VoiceConnectionStatus.Connecting && this.state.status !== VoiceConnectionStatus.Ready)\n\t\t\treturn;\n\n\t\tif (newState.code === NetworkingStatusCode.Ready) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Ready,\n\t\t\t};\n\t\t} else if (newState.code !== NetworkingStatusCode.Closed) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Connecting,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Propagates errors from the underlying network instance.\n\t *\n\t * @param error - The error to propagate\n\t */\n\tprivate onNetworkingError(error: Error) {\n\t\tthis.emit('error', error);\n\t}\n\n\t/**\n\t * Propagates debug messages from the underlying network instance.\n\t *\n\t * @param message - The debug message to propagate\n\t */\n\tprivate onNetworkingDebug(message: string) {\n\t\tthis.debug?.(`[NW] ${message}`);\n\t}\n\n\t/**\n\t * Prepares an audio packet for dispatch.\n\t *\n\t * @param buffer - The Opus packet to prepare\n\t */\n\tpublic prepareAudioPacket(buffer: Buffer) {\n\t\tconst state = this.state;\n\t\tif (state.status !== VoiceConnectionStatus.Ready) return;\n\t\treturn state.networking.prepareAudioPacket(buffer);\n\t}\n\n\t/**\n\t * Dispatches the previously prepared audio packet (if any)\n\t */\n\tpublic dispatchAudio() {\n\t\tconst state = this.state;\n\t\tif (state.status !== VoiceConnectionStatus.Ready) return;\n\t\treturn state.networking.dispatchAudio();\n\t}\n\n\t/**\n\t * Prepares an audio packet and dispatches it immediately.\n\t *\n\t * @param buffer - The Opus packet to play\n\t */\n\tpublic playOpusPacket(buffer: Buffer) {\n\t\tconst state = this.state;\n\t\tif (state.status !== VoiceConnectionStatus.Ready) return;\n\t\tstate.networking.prepareAudioPacket(buffer);\n\t\treturn state.networking.dispatchAudio();\n\t}\n\n\t/**\n\t * Destroys the VoiceConnection, preventing it from connecting to voice again.\n\t * This method should be called when you no longer require the VoiceConnection to\n\t * prevent memory leaks.\n\t *\n\t * @param adapterAvailable - Whether the adapter can be used\n\t */\n\tpublic destroy(adapterAvailable = true) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) {\n\t\t\tthrow new Error('Cannot destroy VoiceConnection - it has already been destroyed');\n\t\t}\n\t\tif (getVoiceConnection(this.joinConfig.guildId, this.joinConfig.group) === this) {\n\t\t\tuntrackVoiceConnection(this);\n\t\t}\n\t\tif (adapterAvailable) {\n\t\t\tthis.state.adapter.sendPayload(createJoinVoiceChannelPayload({ ...this.joinConfig, channelId: null }));\n\t\t}\n\t\tthis.state = {\n\t\t\tstatus: VoiceConnectionStatus.Destroyed,\n\t\t};\n\t}\n\n\t/**\n\t * Disconnects the VoiceConnection, allowing the possibility of rejoining later on.\n\t *\n\t * @returns `true` if the connection was successfully disconnected\n\t */\n\tpublic disconnect() {\n\t\tif (\n\t\t\tthis.state.status === VoiceConnectionStatus.Destroyed ||\n\t\t\tthis.state.status === VoiceConnectionStatus.Signalling\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.joinConfig.channelId = null;\n\t\tif (!this.state.adapter.sendPayload(createJoinVoiceChannelPayload(this.joinConfig))) {\n\t\t\tthis.state = {\n\t\t\t\tadapter: this.state.adapter,\n\t\t\t\tsubscription: this.state.subscription,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t};\n\t\t\treturn false;\n\t\t}\n\t\tthis.state = {\n\t\t\tadapter: this.state.adapter,\n\t\t\treason: VoiceConnectionDisconnectReason.Manual,\n\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t};\n\t\treturn true;\n\t}\n\n\t/**\n\t * Attempts to rejoin (better explanation soon:tm:)\n\t *\n\t * @remarks\n\t * Calling this method successfully will automatically increment the `rejoinAttempts` counter,\n\t * which you can use to inform whether or not you'd like to keep attempting to reconnect your\n\t * voice connection.\n\t *\n\t * A state transition from Disconnected to Signalling will be observed when this is called.\n\t */\n\tpublic rejoin(joinConfig?: Omit<JoinConfig, 'guildId' | 'group'>) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst notReady = this.state.status !== VoiceConnectionStatus.Ready;\n\n\t\tif (notReady) this.rejoinAttempts++;\n\t\tObject.assign(this.joinConfig, joinConfig);\n\t\tif (this.state.adapter.sendPayload(createJoinVoiceChannelPayload(this.joinConfig))) {\n\t\t\tif (notReady) {\n\t\t\t\tthis.state = {\n\t\t\t\t\t...this.state,\n\t\t\t\t\tstatus: VoiceConnectionStatus.Signalling,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tthis.state = {\n\t\t\tadapter: this.state.adapter,\n\t\t\tsubscription: this.state.subscription,\n\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t};\n\t\treturn false;\n\t}\n\n\t/**\n\t * Updates the speaking status of the voice connection. This is used when audio players are done playing audio,\n\t * and need to signal that the connection is no longer playing audio.\n\t *\n\t * @param enabled - Whether or not to show as speaking\n\t */\n\tpublic setSpeaking(enabled: boolean) {\n\t\tif (this.state.status !== VoiceConnectionStatus.Ready) return false;\n\t\treturn this.state.networking.setSpeaking(enabled);\n\t}\n\n\t/**\n\t * Subscribes to an audio player, allowing the player to play audio on this voice connection.\n\t *\n\t * @param player - The audio player to subscribe to\n\t *\n\t * @returns The created subscription\n\t */\n\tpublic subscribe(player: AudioPlayer) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) return;\n\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tconst subscription = player['subscribe'](this);\n\n\t\tthis.state = {\n\t\t\t...this.state,\n\t\t\tsubscription,\n\t\t};\n\n\t\treturn subscription;\n\t}\n\n\t/**\n\t * The latest ping (in milliseconds) for the WebSocket connection and audio playback for this voice\n\t * connection, if this data is available.\n\t *\n\t * @remarks\n\t * For this data to be available, the VoiceConnection must be in the Ready state, and its underlying\n\t * WebSocket connection and UDP socket must have had at least one ping-pong exchange.\n\t */\n\tpublic get ping() {\n\t\tif (\n\t\t\tthis.state.status === VoiceConnectionStatus.Ready &&\n\t\t\tthis.state.networking.state.code === NetworkingStatusCode.Ready\n\t\t) {\n\t\t\treturn {\n\t\t\t\tws: this.state.networking.state.ws.ping,\n\t\t\t\tudp: this.state.networking.state.udp.ping,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tws: undefined,\n\t\t\tudp: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Called when a subscription of this voice connection to an audio player is removed.\n\t *\n\t * @param subscription - The removed subscription\n\t */\n\tprotected onSubscriptionRemoved(subscription: PlayerSubscription) {\n\t\tif (this.state.status !== VoiceConnectionStatus.Destroyed && this.state.subscription === subscription) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tsubscription: undefined,\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * Creates a new voice connection.\n *\n * @param joinConfig - The data required to establish the voice connection\n * @param options - The options to use when joining the voice channel\n */\nexport function createVoiceConnection(joinConfig: JoinConfig, options: CreateVoiceConnectionOptions) {\n\tconst payload = createJoinVoiceChannelPayload(joinConfig);\n\tconst existing = getVoiceConnection(joinConfig.guildId, joinConfig.group);\n\tif (existing && existing.state.status !== VoiceConnectionStatus.Destroyed) {\n\t\tif (existing.state.status === VoiceConnectionStatus.Disconnected) {\n\t\t\texisting.rejoin({\n\t\t\t\tchannelId: joinConfig.channelId,\n\t\t\t\tselfDeaf: joinConfig.selfDeaf,\n\t\t\t\tselfMute: joinConfig.selfMute,\n\t\t\t});\n\t\t} else if (!existing.state.adapter.sendPayload(payload)) {\n\t\t\texisting.state = {\n\t\t\t\t...existing.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t};\n\t\t}\n\t\treturn existing;\n\t}\n\n\tconst voiceConnection = new VoiceConnection(joinConfig, options);\n\ttrackVoiceConnection(voiceConnection);\n\tif (voiceConnection.state.status !== VoiceConnectionStatus.Destroyed) {\n\t\tif (!voiceConnection.state.adapter.sendPayload(payload)) {\n\t\t\tvoiceConnection.state = {\n\t\t\t\t...voiceConnection.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t};\n\t\t}\n\t}\n\treturn voiceConnection;\n}\n"],"names":["EventEmitter","VoiceReceiver","noop","Networking","createJoinVoiceChannelPayload","NetworkingStatusCode","getVoiceConnection","untrackVoiceConnection","trackVoiceConnection"],"mappings":";;;;;;;;;;;;;AAUU,IAAC,qBAAqB,mBAAmB,CAAC,CAAC,sBAAsB,KAAK;AAChF,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACtD,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACtD,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;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OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;AAC7D,MAAM,eAAe,CAAC,KAAK,GAAG;AAC9B,QAAQ,GAAG,eAAe,CAAC,KAAK;AAChC,QAAQ,MAAM,EAAE,cAAc;AAC9B,QAAQ,MAAM,EAAE,CAAC;AACjB,OAAO,CAAC;AACR,KAAK;AACL,GAAG;AACH,EAAE,OAAO,eAAe,CAAC;AACzB;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"VoiceConnection.cjs","sources":["../src/VoiceConnection.ts"],"sourcesContent":["/* eslint-disable consistent-return */\n/* eslint-disable @typescript-eslint/unbound-method */\n/* eslint-disable jsdoc/check-param-names */\n/* eslint-disable @typescript-eslint/method-signature-style */\nimport type { Buffer } from 'node:buffer';\nimport { EventEmitter } from 'node:events';\nimport type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';\nimport type { JoinConfig } from './DataStore';\nimport {\n\tgetVoiceConnection,\n\tcreateJoinVoiceChannelPayload,\n\ttrackVoiceConnection,\n\tuntrackVoiceConnection,\n} from './DataStore';\nimport type { AudioPlayer } from './audio/AudioPlayer';\nimport type { PlayerSubscription } from './audio/PlayerSubscription';\nimport type { VoiceWebSocket, VoiceUDPSocket } from './networking';\nimport { Networking, NetworkingStatusCode, type NetworkingState } from './networking/Networking';\nimport { VoiceReceiver } from './receive/index';\nimport type { DiscordGatewayAdapterImplementerMethods } from './util/adapter';\nimport { noop } from './util/util';\nimport type { CreateVoiceConnectionOptions } from './index';\n\n/**\n * The various status codes a voice connection can hold at any one time.\n */\nexport enum VoiceConnectionStatus {\n\t/**\n\t * The `VOICE_SERVER_UPDATE` and `VOICE_STATE_UPDATE` packets have been received, now attempting to establish a voice connection.\n\t */\n\tConnecting = 'connecting',\n\n\t/**\n\t * The voice connection has been destroyed and untracked, it cannot be reused.\n\t */\n\tDestroyed = 'destroyed',\n\n\t/**\n\t * The voice connection has either been severed or not established.\n\t */\n\tDisconnected = 'disconnected',\n\n\t/**\n\t * A voice connection has been established, and is ready to be used.\n\t */\n\tReady = 'ready',\n\n\t/**\n\t * Sending a packet to the main Discord gateway to indicate we want to change our voice state.\n\t */\n\tSignalling = 'signalling',\n}\n\n/**\n * The state that a VoiceConnection will be in when it is waiting to receive a VOICE_SERVER_UPDATE and\n * VOICE_STATE_UPDATE packet from Discord, provided by the adapter.\n */\nexport interface VoiceConnectionSignallingState {\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n\tstatus: VoiceConnectionStatus.Signalling;\n\tsubscription?: PlayerSubscription | undefined;\n}\n\n/**\n * The reasons a voice connection can be in the disconnected state.\n */\nexport enum VoiceConnectionDisconnectReason {\n\t/**\n\t * When the WebSocket connection has been closed.\n\t */\n\tWebSocketClose,\n\n\t/**\n\t * When the adapter was unable to send a message requested by the VoiceConnection.\n\t */\n\tAdapterUnavailable,\n\n\t/**\n\t * When a VOICE_SERVER_UPDATE packet is received with a null endpoint, causing the connection to be severed.\n\t */\n\tEndpointRemoved,\n\n\t/**\n\t * When a manual disconnect was requested.\n\t */\n\tManual,\n}\n\n/**\n * The state that a VoiceConnection will be in when it is not connected to a Discord voice server nor is\n * it attempting to connect. You can manually attempt to reconnect using VoiceConnection#reconnect.\n */\nexport interface VoiceConnectionDisconnectedBaseState {\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n\tstatus: VoiceConnectionStatus.Disconnected;\n\tsubscription?: PlayerSubscription | undefined;\n}\n\n/**\n * The state that a VoiceConnection will be in when it is not connected to a Discord voice server nor is\n * it attempting to connect. You can manually attempt to reconnect using VoiceConnection#reconnect.\n */\nexport interface VoiceConnectionDisconnectedOtherState extends VoiceConnectionDisconnectedBaseState {\n\treason: Exclude<VoiceConnectionDisconnectReason, VoiceConnectionDisconnectReason.WebSocketClose>;\n}\n\n/**\n * The state that a VoiceConnection will be in when its WebSocket connection was closed.\n * You can manually attempt to reconnect using VoiceConnection#reconnect.\n */\nexport interface VoiceConnectionDisconnectedWebSocketState extends VoiceConnectionDisconnectedBaseState {\n\t/**\n\t * The close code of the WebSocket connection to the Discord voice server.\n\t */\n\tcloseCode: number;\n\n\treason: VoiceConnectionDisconnectReason.WebSocketClose;\n}\n\n/**\n * The states that a VoiceConnection can be in when it is not connected to a Discord voice server nor is\n * it attempting to connect. You can manually attempt to connect using VoiceConnection#reconnect.\n */\nexport type VoiceConnectionDisconnectedState =\n\t| VoiceConnectionDisconnectedOtherState\n\t| VoiceConnectionDisconnectedWebSocketState;\n\n/**\n * The state that a VoiceConnection will be in when it is establishing a connection to a Discord\n * voice server.\n */\nexport interface VoiceConnectionConnectingState {\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n\tnetworking: Networking;\n\tstatus: VoiceConnectionStatus.Connecting;\n\tsubscription?: PlayerSubscription | undefined;\n}\n\n/**\n * The state that a VoiceConnection will be in when it has an active connection to a Discord\n * voice server.\n */\nexport interface VoiceConnectionReadyState {\n\tadapter: DiscordGatewayAdapterImplementerMethods;\n\tnetworking: Networking;\n\tstatus: VoiceConnectionStatus.Ready;\n\tsubscription?: PlayerSubscription | undefined;\n}\n\n/**\n * The state that a VoiceConnection will be in when it has been permanently been destroyed by the\n * user and untracked by the library. It cannot be reconnected, instead, a new VoiceConnection\n * needs to be established.\n */\nexport interface VoiceConnectionDestroyedState {\n\tstatus: VoiceConnectionStatus.Destroyed;\n}\n\n/**\n * The various states that a voice connection can be in.\n */\nexport type VoiceConnectionState =\n\t| VoiceConnectionConnectingState\n\t| VoiceConnectionDestroyedState\n\t| VoiceConnectionDisconnectedState\n\t| VoiceConnectionReadyState\n\t| VoiceConnectionSignallingState;\n\nexport interface VoiceConnection extends EventEmitter {\n\t/**\n\t * Emitted when there is an error emitted from the voice connection\n\t *\n\t * @eventProperty\n\t */\n\ton(event: 'error', listener: (error: Error) => void): this;\n\t/**\n\t * Emitted debugging information about the voice connection\n\t *\n\t * @eventProperty\n\t */\n\ton(event: 'debug', listener: (message: string) => void): this;\n\t/**\n\t * Emitted when the state of the voice connection changes\n\t *\n\t * @eventProperty\n\t */\n\ton(event: 'stateChange', listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState) => void): this;\n\t/**\n\t * Emitted when the state of the voice connection changes to a specific status\n\t *\n\t * @eventProperty\n\t */\n\ton<T extends VoiceConnectionStatus>(\n\t\tevent: T,\n\t\tlistener: (oldState: VoiceConnectionState, newState: VoiceConnectionState & { status: T }) => void,\n\t): this;\n}\n\n/**\n * A connection to the voice server of a Guild, can be used to play audio in voice channels.\n */\nexport class VoiceConnection extends EventEmitter {\n\t/**\n\t * The number of consecutive rejoin attempts. Initially 0, and increments for each rejoin.\n\t * When a connection is successfully established, it resets to 0.\n\t */\n\tpublic rejoinAttempts: number;\n\n\t/**\n\t * The state of the voice connection.\n\t */\n\tprivate _state: VoiceConnectionState;\n\n\t/**\n\t * A configuration storing all the data needed to reconnect to a Guild's voice server.\n\t *\n\t * @internal\n\t */\n\tpublic readonly joinConfig: JoinConfig;\n\n\t/**\n\t * The two packets needed to successfully establish a voice connection. They are received\n\t * from the main Discord gateway after signalling to change the voice state.\n\t */\n\tprivate readonly packets: {\n\t\tserver: GatewayVoiceServerUpdateDispatchData | undefined;\n\t\tstate: GatewayVoiceStateUpdateDispatchData | undefined;\n\t};\n\n\t/**\n\t * The receiver of this voice connection. You should join the voice channel with `selfDeaf` set\n\t * to false for this feature to work properly.\n\t */\n\tpublic readonly receiver: VoiceReceiver;\n\n\t/**\n\t * The debug logger function, if debugging is enabled.\n\t */\n\tprivate readonly debug: ((message: string) => void) | null;\n\n\t/**\n\t * Creates a new voice connection.\n\t *\n\t * @param joinConfig - The data required to establish the voice connection\n\t * @param options - The options used to create this voice connection\n\t */\n\tpublic constructor(joinConfig: JoinConfig, { debug, adapterCreator }: CreateVoiceConnectionOptions) {\n\t\tsuper();\n\n\t\tthis.debug = debug ? (message: string) => this.emit('debug', message) : null;\n\t\tthis.rejoinAttempts = 0;\n\n\t\tthis.receiver = new VoiceReceiver(this);\n\n\t\tthis.onNetworkingClose = this.onNetworkingClose.bind(this);\n\t\tthis.onNetworkingStateChange = this.onNetworkingStateChange.bind(this);\n\t\tthis.onNetworkingError = this.onNetworkingError.bind(this);\n\t\tthis.onNetworkingDebug = this.onNetworkingDebug.bind(this);\n\n\t\tconst adapter = adapterCreator({\n\t\t\tonVoiceServerUpdate: (data) => this.addServerPacket(data),\n\t\t\tonVoiceStateUpdate: (data) => this.addStatePacket(data),\n\t\t\tdestroy: () => this.destroy(false),\n\t\t});\n\n\t\tthis._state = { status: VoiceConnectionStatus.Signalling, adapter };\n\n\t\tthis.packets = {\n\t\t\tserver: undefined,\n\t\t\tstate: undefined,\n\t\t};\n\n\t\tthis.joinConfig = joinConfig;\n\t}\n\n\t/**\n\t * The current state of the voice connection.\n\t */\n\tpublic get state() {\n\t\treturn this._state;\n\t}\n\n\t/**\n\t * Updates the state of the voice connection, performing clean-up operations where necessary.\n\t */\n\tpublic set state(newState: VoiceConnectionState) {\n\t\tconst oldState = this._state;\n\t\tconst oldNetworking = Reflect.get(oldState, 'networking') as Networking | undefined;\n\t\tconst newNetworking = Reflect.get(newState, 'networking') as Networking | undefined;\n\n\t\tconst oldSubscription = Reflect.get(oldState, 'subscription') as PlayerSubscription | undefined;\n\t\tconst newSubscription = Reflect.get(newState, 'subscription') as PlayerSubscription | undefined;\n\n\t\tif (oldNetworking !== newNetworking) {\n\t\t\tif (oldNetworking) {\n\t\t\t\toldNetworking.on('error', noop);\n\t\t\t\toldNetworking.off('debug', this.onNetworkingDebug);\n\t\t\t\toldNetworking.off('error', this.onNetworkingError);\n\t\t\t\toldNetworking.off('close', this.onNetworkingClose);\n\t\t\t\toldNetworking.off('stateChange', this.onNetworkingStateChange);\n\t\t\t\toldNetworking.destroy();\n\t\t\t}\n\n\t\t\tif (newNetworking) this.updateReceiveBindings(newNetworking.state, oldNetworking?.state);\n\t\t}\n\n\t\tif (newState.status === VoiceConnectionStatus.Ready) {\n\t\t\tthis.rejoinAttempts = 0;\n\t\t} else if (newState.status === VoiceConnectionStatus.Destroyed) {\n\t\t\tfor (const stream of this.receiver.subscriptions.values()) {\n\t\t\t\tif (!stream.destroyed) stream.destroy();\n\t\t\t}\n\t\t}\n\n\t\t// If destroyed, the adapter can also be destroyed so it can be cleaned up by the user\n\t\tif (oldState.status !== VoiceConnectionStatus.Destroyed && newState.status === VoiceConnectionStatus.Destroyed) {\n\t\t\toldState.adapter.destroy();\n\t\t}\n\n\t\tthis._state = newState;\n\n\t\tif (oldSubscription && oldSubscription !== newSubscription) {\n\t\t\toldSubscription.unsubscribe();\n\t\t}\n\n\t\tthis.emit('stateChange', oldState, newState);\n\t\tif (oldState.status !== newState.status) {\n\t\t\tthis.emit(newState.status, oldState, newState as any);\n\t\t}\n\t}\n\n\t/**\n\t * Registers a `VOICE_SERVER_UPDATE` packet to the voice connection. This will cause it to reconnect using the\n\t * new data provided in the packet.\n\t *\n\t * @param packet - The received `VOICE_SERVER_UPDATE` packet\n\t */\n\tprivate addServerPacket(packet: GatewayVoiceServerUpdateDispatchData) {\n\t\tthis.packets.server = packet;\n\t\tif (packet.endpoint) {\n\t\t\tthis.configureNetworking();\n\t\t} else if (this.state.status !== VoiceConnectionStatus.Destroyed) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.EndpointRemoved,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Registers a `VOICE_STATE_UPDATE` packet to the voice connection. Most importantly, it stores the id of the\n\t * channel that the client is connected to.\n\t *\n\t * @param packet - The received `VOICE_STATE_UPDATE` packet\n\t */\n\tprivate addStatePacket(packet: GatewayVoiceStateUpdateDispatchData) {\n\t\tthis.packets.state = packet;\n\n\t\tif (typeof packet.self_deaf !== 'undefined') this.joinConfig.selfDeaf = packet.self_deaf;\n\t\tif (typeof packet.self_mute !== 'undefined') this.joinConfig.selfMute = packet.self_mute;\n\t\tif (packet.channel_id) this.joinConfig.channelId = packet.channel_id;\n\t\t/*\n\t\t\tthe channel_id being null doesn't necessarily mean it was intended for the client to leave the voice channel\n\t\t\tas it may have disconnected due to network failure. This will be gracefully handled once the voice websocket\n\t\t\tdies, and then it is up to the user to decide how they wish to handle this.\n\t\t*/\n\t}\n\n\t/**\n\t * Called when the networking state changes, and the new ws/udp packet/message handlers need to be rebound\n\t * to the new instances.\n\t *\n\t * @param newState - The new networking state\n\t * @param oldState - The old networking state, if there is one\n\t */\n\tprivate updateReceiveBindings(newState: NetworkingState, oldState?: NetworkingState) {\n\t\tconst oldWs = Reflect.get(oldState ?? {}, 'ws') as VoiceWebSocket | undefined;\n\t\tconst newWs = Reflect.get(newState, 'ws') as VoiceWebSocket | undefined;\n\t\tconst oldUdp = Reflect.get(oldState ?? {}, 'udp') as VoiceUDPSocket | undefined;\n\t\tconst newUdp = Reflect.get(newState, 'udp') as VoiceUDPSocket | undefined;\n\n\t\tif (oldWs !== newWs) {\n\t\t\toldWs?.off('packet', this.receiver.onWsPacket);\n\t\t\tnewWs?.on('packet', this.receiver.onWsPacket);\n\t\t}\n\n\t\tif (oldUdp !== newUdp) {\n\t\t\toldUdp?.off('message', this.receiver.onUdpMessage);\n\t\t\tnewUdp?.on('message', this.receiver.onUdpMessage);\n\t\t}\n\n\t\tthis.receiver.connectionData = Reflect.get(newState, 'connectionData') ?? {};\n\t}\n\n\t/**\n\t * Attempts to configure a networking instance for this voice connection using the received packets.\n\t * Both packets are required, and any existing networking instance will be destroyed.\n\t *\n\t * @remarks\n\t * This is called when the voice server of the connection changes, e.g. if the bot is moved into a\n\t * different channel in the same guild but has a different voice server. In this instance, the connection\n\t * needs to be re-established to the new voice server.\n\t *\n\t * The connection will transition to the Connecting state when this is called.\n\t */\n\tpublic configureNetworking() {\n\t\tconst { server, state } = this.packets;\n\t\tif (!server || !state || this.state.status === VoiceConnectionStatus.Destroyed || !server.endpoint) return;\n\n\t\tconst networking = new Networking(\n\t\t\t{\n\t\t\t\tendpoint: server.endpoint,\n\t\t\t\tserverId: server.guild_id,\n\t\t\t\ttoken: server.token,\n\t\t\t\tsessionId: state.session_id,\n\t\t\t\tuserId: state.user_id,\n\t\t\t},\n\t\t\tBoolean(this.debug),\n\t\t);\n\n\t\tnetworking.once('close', this.onNetworkingClose);\n\t\tnetworking.on('stateChange', this.onNetworkingStateChange);\n\t\tnetworking.on('error', this.onNetworkingError);\n\t\tnetworking.on('debug', this.onNetworkingDebug);\n\n\t\tthis.state = {\n\t\t\t...this.state,\n\t\t\tstatus: VoiceConnectionStatus.Connecting,\n\t\t\tnetworking,\n\t\t};\n\t}\n\n\t/**\n\t * Called when the networking instance for this connection closes. If the close code is 4014 (do not reconnect),\n\t * the voice connection will transition to the Disconnected state which will store the close code. You can\n\t * decide whether or not to reconnect when this occurs by listening for the state change and calling reconnect().\n\t *\n\t * @remarks\n\t * If the close code was anything other than 4014, it is likely that the closing was not intended, and so the\n\t * VoiceConnection will signal to Discord that it would like to rejoin the channel. This automatically attempts\n\t * to re-establish the connection. This would be seen as a transition from the Ready state to the Signalling state.\n\t * @param code - The close code\n\t */\n\tprivate onNetworkingClose(code: number) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) return;\n\t\t// If networking closes, try to connect to the voice channel again.\n\t\tif (code === 4_014) {\n\t\t\t// Disconnected - networking is already destroyed here\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.WebSocketClose,\n\t\t\t\tcloseCode: code,\n\t\t\t};\n\t\t} else {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Signalling,\n\t\t\t};\n\t\t\tthis.rejoinAttempts++;\n\t\t\tif (!this.state.adapter.sendPayload(createJoinVoiceChannelPayload(this.joinConfig))) {\n\t\t\t\tthis.state = {\n\t\t\t\t\t...this.state,\n\t\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Called when the state of the networking instance changes. This is used to derive the state of the voice connection.\n\t *\n\t * @param oldState - The previous state\n\t * @param newState - The new state\n\t */\n\tprivate onNetworkingStateChange(oldState: NetworkingState, newState: NetworkingState) {\n\t\tthis.updateReceiveBindings(newState, oldState);\n\t\tif (oldState.code === newState.code) return;\n\t\tif (this.state.status !== VoiceConnectionStatus.Connecting && this.state.status !== VoiceConnectionStatus.Ready)\n\t\t\treturn;\n\n\t\tif (newState.code === NetworkingStatusCode.Ready) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Ready,\n\t\t\t};\n\t\t} else if (newState.code !== NetworkingStatusCode.Closed) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Connecting,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Propagates errors from the underlying network instance.\n\t *\n\t * @param error - The error to propagate\n\t */\n\tprivate onNetworkingError(error: Error) {\n\t\tthis.emit('error', error);\n\t}\n\n\t/**\n\t * Propagates debug messages from the underlying network instance.\n\t *\n\t * @param message - The debug message to propagate\n\t */\n\tprivate onNetworkingDebug(message: string) {\n\t\tthis.debug?.(`[NW] ${message}`);\n\t}\n\n\t/**\n\t * Prepares an audio packet for dispatch.\n\t *\n\t * @param buffer - The Opus packet to prepare\n\t */\n\tpublic prepareAudioPacket(buffer: Buffer) {\n\t\tconst state = this.state;\n\t\tif (state.status !== VoiceConnectionStatus.Ready) return;\n\t\treturn state.networking.prepareAudioPacket(buffer);\n\t}\n\n\t/**\n\t * Dispatches the previously prepared audio packet (if any)\n\t */\n\tpublic dispatchAudio() {\n\t\tconst state = this.state;\n\t\tif (state.status !== VoiceConnectionStatus.Ready) return;\n\t\treturn state.networking.dispatchAudio();\n\t}\n\n\t/**\n\t * Prepares an audio packet and dispatches it immediately.\n\t *\n\t * @param buffer - The Opus packet to play\n\t */\n\tpublic playOpusPacket(buffer: Buffer) {\n\t\tconst state = this.state;\n\t\tif (state.status !== VoiceConnectionStatus.Ready) return;\n\t\tstate.networking.prepareAudioPacket(buffer);\n\t\treturn state.networking.dispatchAudio();\n\t}\n\n\t/**\n\t * Destroys the VoiceConnection, preventing it from connecting to voice again.\n\t * This method should be called when you no longer require the VoiceConnection to\n\t * prevent memory leaks.\n\t *\n\t * @param adapterAvailable - Whether the adapter can be used\n\t */\n\tpublic destroy(adapterAvailable = true) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) {\n\t\t\tthrow new Error('Cannot destroy VoiceConnection - it has already been destroyed');\n\t\t}\n\n\t\tif (getVoiceConnection(this.joinConfig.guildId, this.joinConfig.group) === this) {\n\t\t\tuntrackVoiceConnection(this);\n\t\t}\n\n\t\tif (adapterAvailable) {\n\t\t\tthis.state.adapter.sendPayload(createJoinVoiceChannelPayload({ ...this.joinConfig, channelId: null }));\n\t\t}\n\n\t\tthis.state = {\n\t\t\tstatus: VoiceConnectionStatus.Destroyed,\n\t\t};\n\t}\n\n\t/**\n\t * Disconnects the VoiceConnection, allowing the possibility of rejoining later on.\n\t *\n\t * @returns `true` if the connection was successfully disconnected\n\t */\n\tpublic disconnect() {\n\t\tif (\n\t\t\tthis.state.status === VoiceConnectionStatus.Destroyed ||\n\t\t\tthis.state.status === VoiceConnectionStatus.Signalling\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.joinConfig.channelId = null;\n\t\tif (!this.state.adapter.sendPayload(createJoinVoiceChannelPayload(this.joinConfig))) {\n\t\t\tthis.state = {\n\t\t\t\tadapter: this.state.adapter,\n\t\t\t\tsubscription: this.state.subscription,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t};\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.state = {\n\t\t\tadapter: this.state.adapter,\n\t\t\treason: VoiceConnectionDisconnectReason.Manual,\n\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t};\n\t\treturn true;\n\t}\n\n\t/**\n\t * Attempts to rejoin (better explanation soon:tm:)\n\t *\n\t * @remarks\n\t * Calling this method successfully will automatically increment the `rejoinAttempts` counter,\n\t * which you can use to inform whether or not you'd like to keep attempting to reconnect your\n\t * voice connection.\n\t *\n\t * A state transition from Disconnected to Signalling will be observed when this is called.\n\t */\n\tpublic rejoin(joinConfig?: Omit<JoinConfig, 'group' | 'guildId'>) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst notReady = this.state.status !== VoiceConnectionStatus.Ready;\n\n\t\tif (notReady) this.rejoinAttempts++;\n\t\tObject.assign(this.joinConfig, joinConfig);\n\t\tif (this.state.adapter.sendPayload(createJoinVoiceChannelPayload(this.joinConfig))) {\n\t\t\tif (notReady) {\n\t\t\t\tthis.state = {\n\t\t\t\t\t...this.state,\n\t\t\t\t\tstatus: VoiceConnectionStatus.Signalling,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\tthis.state = {\n\t\t\tadapter: this.state.adapter,\n\t\t\tsubscription: this.state.subscription,\n\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t};\n\t\treturn false;\n\t}\n\n\t/**\n\t * Updates the speaking status of the voice connection. This is used when audio players are done playing audio,\n\t * and need to signal that the connection is no longer playing audio.\n\t *\n\t * @param enabled - Whether or not to show as speaking\n\t */\n\tpublic setSpeaking(enabled: boolean) {\n\t\tif (this.state.status !== VoiceConnectionStatus.Ready) return false;\n\t\t// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n\t\treturn this.state.networking.setSpeaking(enabled);\n\t}\n\n\t/**\n\t * Subscribes to an audio player, allowing the player to play audio on this voice connection.\n\t *\n\t * @param player - The audio player to subscribe to\n\t * @returns The created subscription\n\t */\n\tpublic subscribe(player: AudioPlayer) {\n\t\tif (this.state.status === VoiceConnectionStatus.Destroyed) return;\n\n\t\t// eslint-disable-next-line @typescript-eslint/dot-notation\n\t\tconst subscription = player['subscribe'](this);\n\n\t\tthis.state = {\n\t\t\t...this.state,\n\t\t\tsubscription,\n\t\t};\n\n\t\treturn subscription;\n\t}\n\n\t/**\n\t * The latest ping (in milliseconds) for the WebSocket connection and audio playback for this voice\n\t * connection, if this data is available.\n\t *\n\t * @remarks\n\t * For this data to be available, the VoiceConnection must be in the Ready state, and its underlying\n\t * WebSocket connection and UDP socket must have had at least one ping-pong exchange.\n\t */\n\tpublic get ping() {\n\t\tif (\n\t\t\tthis.state.status === VoiceConnectionStatus.Ready &&\n\t\t\tthis.state.networking.state.code === NetworkingStatusCode.Ready\n\t\t) {\n\t\t\treturn {\n\t\t\t\tws: this.state.networking.state.ws.ping,\n\t\t\t\tudp: this.state.networking.state.udp.ping,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tws: undefined,\n\t\t\tudp: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Called when a subscription of this voice connection to an audio player is removed.\n\t *\n\t * @param subscription - The removed subscription\n\t */\n\tprotected onSubscriptionRemoved(subscription: PlayerSubscription) {\n\t\tif (this.state.status !== VoiceConnectionStatus.Destroyed && this.state.subscription === subscription) {\n\t\t\tthis.state = {\n\t\t\t\t...this.state,\n\t\t\t\tsubscription: undefined,\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * Creates a new voice connection.\n *\n * @param joinConfig - The data required to establish the voice connection\n * @param options - The options to use when joining the voice channel\n */\nexport function createVoiceConnection(joinConfig: JoinConfig, options: CreateVoiceConnectionOptions) {\n\tconst payload = createJoinVoiceChannelPayload(joinConfig);\n\tconst existing = getVoiceConnection(joinConfig.guildId, joinConfig.group);\n\tif (existing && existing.state.status !== VoiceConnectionStatus.Destroyed) {\n\t\tif (existing.state.status === VoiceConnectionStatus.Disconnected) {\n\t\t\texisting.rejoin({\n\t\t\t\tchannelId: joinConfig.channelId,\n\t\t\t\tselfDeaf: joinConfig.selfDeaf,\n\t\t\t\tselfMute: joinConfig.selfMute,\n\t\t\t});\n\t\t} else if (!existing.state.adapter.sendPayload(payload)) {\n\t\t\texisting.state = {\n\t\t\t\t...existing.state,\n\t\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t\t};\n\t\t}\n\n\t\treturn existing;\n\t}\n\n\tconst voiceConnection = new VoiceConnection(joinConfig, options);\n\ttrackVoiceConnection(voiceConnection);\n\tif (\n\t\tvoiceConnection.state.status !== VoiceConnectionStatus.Destroyed &&\n\t\t!voiceConnection.state.adapter.sendPayload(payload)\n\t) {\n\t\tvoiceConnection.state = {\n\t\t\t...voiceConnection.state,\n\t\t\tstatus: VoiceConnectionStatus.Disconnected,\n\t\t\treason: VoiceConnectionDisconnectReason.AdapterUnavailable,\n\t\t};\n\t}\n\n\treturn voiceConnection;\n}\n"],"names":["EventEmitter","VoiceReceiver","noop","Networking","createJoinVoiceChannelPayload","NetworkingStatusCode","getVoiceConnection","untrackVoiceConnection","trackVoiceConnection"],"mappings":";;;;;;;;;;;;;AAUU,IAAC,qBAAqB,mBAAmB,CAAC,CAAC,sBAAsB,KAAK;AAChF,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACtD,EAAE,sBAAsB,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AACpD,EAAE,sBAAsB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AAC1D,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAC5C,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACtD,EAAE,OAAO,sBAAsB,CAAC;AAChC,CAAC,EAAE,qBAAqB,IAAI,EAAE,EAAE;AACtB,IAAC,+BAA+B,mB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C;AACzB;;;;;;;"}
|
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
import type { Buffer } from 'node:buffer';
|
|
3
4
|
import { EventEmitter } from 'node:events';
|
|
4
|
-
import type {
|
|
5
|
-
import { JoinConfig } from './DataStore';
|
|
5
|
+
import type { JoinConfig } from './DataStore';
|
|
6
6
|
import type { AudioPlayer } from './audio/AudioPlayer';
|
|
7
7
|
import type { PlayerSubscription } from './audio/PlayerSubscription';
|
|
8
8
|
import { Networking } from './networking/Networking';
|
|
9
|
-
import { VoiceReceiver } from './receive';
|
|
9
|
+
import { VoiceReceiver } from './receive/index';
|
|
10
10
|
import type { DiscordGatewayAdapterImplementerMethods } from './util/adapter';
|
|
11
|
+
import type { CreateVoiceConnectionOptions } from './index';
|
|
11
12
|
/**
|
|
12
13
|
* The various status codes a voice connection can hold at any one time.
|
|
13
14
|
*/
|
|
14
15
|
export declare enum VoiceConnectionStatus {
|
|
15
|
-
/**
|
|
16
|
-
* Sending a packet to the main Discord gateway to indicate we want to change our voice state.
|
|
17
|
-
*/
|
|
18
|
-
Signalling = "signalling",
|
|
19
16
|
/**
|
|
20
17
|
* The `VOICE_SERVER_UPDATE` and `VOICE_STATE_UPDATE` packets have been received, now attempting to establish a voice connection.
|
|
21
18
|
*/
|
|
22
19
|
Connecting = "connecting",
|
|
23
20
|
/**
|
|
24
|
-
*
|
|
21
|
+
* The voice connection has been destroyed and untracked, it cannot be reused.
|
|
25
22
|
*/
|
|
26
|
-
|
|
23
|
+
Destroyed = "destroyed",
|
|
27
24
|
/**
|
|
28
25
|
* The voice connection has either been severed or not established.
|
|
29
26
|
*/
|
|
30
27
|
Disconnected = "disconnected",
|
|
31
28
|
/**
|
|
32
|
-
*
|
|
29
|
+
* A voice connection has been established, and is ready to be used.
|
|
33
30
|
*/
|
|
34
|
-
|
|
31
|
+
Ready = "ready",
|
|
32
|
+
/**
|
|
33
|
+
* Sending a packet to the main Discord gateway to indicate we want to change our voice state.
|
|
34
|
+
*/
|
|
35
|
+
Signalling = "signalling"
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* The state that a VoiceConnection will be in when it is waiting to receive a VOICE_SERVER_UPDATE and
|
|
38
39
|
* VOICE_STATE_UPDATE packet from Discord, provided by the adapter.
|
|
39
40
|
*/
|
|
40
41
|
export interface VoiceConnectionSignallingState {
|
|
42
|
+
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
41
43
|
status: VoiceConnectionStatus.Signalling;
|
|
42
44
|
subscription?: PlayerSubscription | undefined;
|
|
43
|
-
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* The reasons a voice connection can be in the disconnected state.
|
|
@@ -68,9 +69,9 @@ export declare enum VoiceConnectionDisconnectReason {
|
|
|
68
69
|
* it attempting to connect. You can manually attempt to reconnect using VoiceConnection#reconnect.
|
|
69
70
|
*/
|
|
70
71
|
export interface VoiceConnectionDisconnectedBaseState {
|
|
72
|
+
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
71
73
|
status: VoiceConnectionStatus.Disconnected;
|
|
72
74
|
subscription?: PlayerSubscription | undefined;
|
|
73
|
-
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
77
|
* The state that a VoiceConnection will be in when it is not connected to a Discord voice server nor is
|
|
@@ -84,11 +85,11 @@ export interface VoiceConnectionDisconnectedOtherState extends VoiceConnectionDi
|
|
|
84
85
|
* You can manually attempt to reconnect using VoiceConnection#reconnect.
|
|
85
86
|
*/
|
|
86
87
|
export interface VoiceConnectionDisconnectedWebSocketState extends VoiceConnectionDisconnectedBaseState {
|
|
87
|
-
reason: VoiceConnectionDisconnectReason.WebSocketClose;
|
|
88
88
|
/**
|
|
89
89
|
* The close code of the WebSocket connection to the Discord voice server.
|
|
90
90
|
*/
|
|
91
91
|
closeCode: number;
|
|
92
|
+
reason: VoiceConnectionDisconnectReason.WebSocketClose;
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* The states that a VoiceConnection can be in when it is not connected to a Discord voice server nor is
|
|
@@ -100,20 +101,20 @@ export declare type VoiceConnectionDisconnectedState = VoiceConnectionDisconnect
|
|
|
100
101
|
* voice server.
|
|
101
102
|
*/
|
|
102
103
|
export interface VoiceConnectionConnectingState {
|
|
103
|
-
|
|
104
|
+
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
104
105
|
networking: Networking;
|
|
106
|
+
status: VoiceConnectionStatus.Connecting;
|
|
105
107
|
subscription?: PlayerSubscription | undefined;
|
|
106
|
-
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
109
110
|
* The state that a VoiceConnection will be in when it has an active connection to a Discord
|
|
110
111
|
* voice server.
|
|
111
112
|
*/
|
|
112
113
|
export interface VoiceConnectionReadyState {
|
|
113
|
-
|
|
114
|
+
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
114
115
|
networking: Networking;
|
|
116
|
+
status: VoiceConnectionStatus.Ready;
|
|
115
117
|
subscription?: PlayerSubscription | undefined;
|
|
116
|
-
adapter: DiscordGatewayAdapterImplementerMethods;
|
|
117
118
|
}
|
|
118
119
|
/**
|
|
119
120
|
* The state that a VoiceConnection will be in when it has been permanently been destroyed by the
|
|
@@ -126,25 +127,29 @@ export interface VoiceConnectionDestroyedState {
|
|
|
126
127
|
/**
|
|
127
128
|
* The various states that a voice connection can be in.
|
|
128
129
|
*/
|
|
129
|
-
export declare type VoiceConnectionState =
|
|
130
|
+
export declare type VoiceConnectionState = VoiceConnectionConnectingState | VoiceConnectionDestroyedState | VoiceConnectionDisconnectedState | VoiceConnectionReadyState | VoiceConnectionSignallingState;
|
|
130
131
|
export interface VoiceConnection extends EventEmitter {
|
|
131
132
|
/**
|
|
132
133
|
* Emitted when there is an error emitted from the voice connection
|
|
134
|
+
*
|
|
133
135
|
* @eventProperty
|
|
134
136
|
*/
|
|
135
137
|
on(event: 'error', listener: (error: Error) => void): this;
|
|
136
138
|
/**
|
|
137
139
|
* Emitted debugging information about the voice connection
|
|
140
|
+
*
|
|
138
141
|
* @eventProperty
|
|
139
142
|
*/
|
|
140
143
|
on(event: 'debug', listener: (message: string) => void): this;
|
|
141
144
|
/**
|
|
142
145
|
* Emitted when the state of the voice connection changes
|
|
146
|
+
*
|
|
143
147
|
* @eventProperty
|
|
144
148
|
*/
|
|
145
149
|
on(event: 'stateChange', listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState) => void): this;
|
|
146
150
|
/**
|
|
147
151
|
* Emitted when the state of the voice connection changes to a specific status
|
|
152
|
+
*
|
|
148
153
|
* @eventProperty
|
|
149
154
|
*/
|
|
150
155
|
on<T extends VoiceConnectionStatus>(event: T, listener: (oldState: VoiceConnectionState, newState: VoiceConnectionState & {
|
|
@@ -216,6 +221,7 @@ export declare class VoiceConnection extends EventEmitter {
|
|
|
216
221
|
/**
|
|
217
222
|
* Called when the networking state changes, and the new ws/udp packet/message handlers need to be rebound
|
|
218
223
|
* to the new instances.
|
|
224
|
+
*
|
|
219
225
|
* @param newState - The new networking state
|
|
220
226
|
* @param oldState - The old networking state, if there is one
|
|
221
227
|
*/
|
|
@@ -241,7 +247,6 @@ export declare class VoiceConnection extends EventEmitter {
|
|
|
241
247
|
* If the close code was anything other than 4014, it is likely that the closing was not intended, and so the
|
|
242
248
|
* VoiceConnection will signal to Discord that it would like to rejoin the channel. This automatically attempts
|
|
243
249
|
* to re-establish the connection. This would be seen as a transition from the Ready state to the Signalling state.
|
|
244
|
-
*
|
|
245
250
|
* @param code - The close code
|
|
246
251
|
*/
|
|
247
252
|
private onNetworkingClose;
|
|
@@ -304,7 +309,7 @@ export declare class VoiceConnection extends EventEmitter {
|
|
|
304
309
|
*
|
|
305
310
|
* A state transition from Disconnected to Signalling will be observed when this is called.
|
|
306
311
|
*/
|
|
307
|
-
rejoin(joinConfig?: Omit<JoinConfig, '
|
|
312
|
+
rejoin(joinConfig?: Omit<JoinConfig, 'group' | 'guildId'>): boolean;
|
|
308
313
|
/**
|
|
309
314
|
* Updates the speaking status of the voice connection. This is used when audio players are done playing audio,
|
|
310
315
|
* and need to signal that the connection is no longer playing audio.
|
|
@@ -316,7 +321,6 @@ export declare class VoiceConnection extends EventEmitter {
|
|
|
316
321
|
* Subscribes to an audio player, allowing the player to play audio on this voice connection.
|
|
317
322
|
*
|
|
318
323
|
* @param player - The audio player to subscribe to
|
|
319
|
-
*
|
|
320
324
|
* @returns The created subscription
|
|
321
325
|
*/
|
|
322
326
|
subscribe(player: AudioPlayer): PlayerSubscription | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceConnection.d.ts","sourceRoot":"","sources":["../src/VoiceConnection.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"VoiceConnection.d.ts","sourceRoot":"","sources":["../src/VoiceConnection.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,UAAU,EAA8C,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE5D;;GAEG;AACH,oBAAY,qBAAqB;IAChC;;OAEG;IACH,UAAU,eAAe;IAEzB;;OAEG;IACH,SAAS,cAAc;IAEvB;;OAEG;IACH,YAAY,iBAAiB;IA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