lavalink-client 2.9.2 → 2.9.3
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/{index.mjs → index.cjs} +123 -23
- package/dist/{index.d.mts → index.d.cts} +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +58 -88
- package/package.json +7 -4
|
@@ -1,5 +1,69 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
DebugEvents: () => DebugEvents,
|
|
33
|
+
DefaultQueueStore: () => DefaultQueueStore,
|
|
34
|
+
DefaultSources: () => DefaultSources,
|
|
35
|
+
DestroyReasons: () => DestroyReasons,
|
|
36
|
+
DisconnectReasons: () => DisconnectReasons,
|
|
37
|
+
EQList: () => EQList,
|
|
38
|
+
FilterManager: () => FilterManager,
|
|
39
|
+
LavalinkManager: () => LavalinkManager,
|
|
40
|
+
LavalinkNode: () => LavalinkNode,
|
|
41
|
+
LavalinkPlugins: () => LavalinkPlugins,
|
|
42
|
+
ManagerUtils: () => ManagerUtils,
|
|
43
|
+
MiniMap: () => MiniMap,
|
|
44
|
+
NodeLinkExclusiveEvents: () => NodeLinkExclusiveEvents,
|
|
45
|
+
NodeLinkNode: () => NodeLinkNode,
|
|
46
|
+
NodeManager: () => NodeManager,
|
|
47
|
+
NodeSymbol: () => NodeSymbol,
|
|
48
|
+
Player: () => Player,
|
|
49
|
+
Queue: () => Queue,
|
|
50
|
+
QueueSaver: () => QueueSaver,
|
|
51
|
+
QueueSymbol: () => QueueSymbol,
|
|
52
|
+
RecommendationsStrings: () => RecommendationsStrings,
|
|
53
|
+
ReconnectionState: () => ReconnectionState,
|
|
54
|
+
SourceLinksRegexes: () => SourceLinksRegexes,
|
|
55
|
+
TrackSymbol: () => TrackSymbol,
|
|
56
|
+
UnresolvedTrackSymbol: () => UnresolvedTrackSymbol,
|
|
57
|
+
audioOutputsData: () => audioOutputsData,
|
|
58
|
+
parseLavalinkConnUrl: () => parseLavalinkConnUrl,
|
|
59
|
+
queueTrackEnd: () => queueTrackEnd,
|
|
60
|
+
safeStringify: () => safeStringify,
|
|
61
|
+
validSponsorBlocks: () => validSponsorBlocks
|
|
62
|
+
});
|
|
63
|
+
module.exports = __toCommonJS(index_exports);
|
|
64
|
+
|
|
1
65
|
// src/structures/LavalinkManager.ts
|
|
2
|
-
|
|
66
|
+
var import_node_events2 = require("events");
|
|
3
67
|
|
|
4
68
|
// src/structures/Constants.ts
|
|
5
69
|
var DebugEvents = /* @__PURE__ */ ((DebugEvents2) => {
|
|
@@ -340,11 +404,11 @@ var NodeLinkExclusiveEvents = [
|
|
|
340
404
|
];
|
|
341
405
|
|
|
342
406
|
// src/structures/NodeManager.ts
|
|
343
|
-
|
|
407
|
+
var import_node_events = require("events");
|
|
344
408
|
|
|
345
409
|
// src/structures/Node.ts
|
|
346
|
-
|
|
347
|
-
|
|
410
|
+
var import_node_path = require("path");
|
|
411
|
+
var import_ws = __toESM(require("ws"), 1);
|
|
348
412
|
|
|
349
413
|
// src/structures/Types/Node.ts
|
|
350
414
|
var ReconnectionState = /* @__PURE__ */ ((ReconnectionState2) => {
|
|
@@ -356,8 +420,8 @@ var ReconnectionState = /* @__PURE__ */ ((ReconnectionState2) => {
|
|
|
356
420
|
})(ReconnectionState || {});
|
|
357
421
|
|
|
358
422
|
// src/structures/Utils.ts
|
|
359
|
-
|
|
360
|
-
|
|
423
|
+
var import_node_url = require("url");
|
|
424
|
+
var import_types = require("util/types");
|
|
361
425
|
|
|
362
426
|
// src/structures/LavalinkManagerStatics.ts
|
|
363
427
|
var DefaultSources = {
|
|
@@ -527,7 +591,7 @@ var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
527
591
|
function parseLavalinkConnUrl(connectionUrl) {
|
|
528
592
|
if (!connectionUrl.startsWith("lavalink://"))
|
|
529
593
|
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://'`);
|
|
530
|
-
const parsed = new
|
|
594
|
+
const parsed = new import_node_url.URL(connectionUrl);
|
|
531
595
|
return {
|
|
532
596
|
authorization: parsed.password,
|
|
533
597
|
id: parsed.username,
|
|
@@ -792,7 +856,7 @@ var ManagerUtils = class {
|
|
|
792
856
|
});
|
|
793
857
|
}
|
|
794
858
|
if (this.LavalinkManager.options?.linksBlacklist.some(
|
|
795
|
-
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) || isRegExp(v) && v.test(queryString)
|
|
859
|
+
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) || (0, import_types.isRegExp)(v) && v.test(queryString)
|
|
796
860
|
)) {
|
|
797
861
|
throw new Error(`Query string contains a link / word which is blacklisted.`);
|
|
798
862
|
}
|
|
@@ -809,7 +873,7 @@ var ManagerUtils = class {
|
|
|
809
873
|
});
|
|
810
874
|
}
|
|
811
875
|
if (!this.LavalinkManager.options?.linksWhitelist.some(
|
|
812
|
-
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) || isRegExp(v) && v.test(queryString)
|
|
876
|
+
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) || (0, import_types.isRegExp)(v) && v.test(queryString)
|
|
813
877
|
)) {
|
|
814
878
|
throw new Error(`Query string contains a link / word which isn't whitelisted.`);
|
|
815
879
|
}
|
|
@@ -1285,7 +1349,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1285
1349
|
* ```
|
|
1286
1350
|
*/
|
|
1287
1351
|
get connected() {
|
|
1288
|
-
return this.socket && this.socket.readyState ===
|
|
1352
|
+
return this.socket && this.socket.readyState === import_ws.default.OPEN;
|
|
1289
1353
|
}
|
|
1290
1354
|
/**
|
|
1291
1355
|
* Returns the current ConnectionStatus
|
|
@@ -1605,7 +1669,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1605
1669
|
headers["Session-Id"] = this.options.sessionId || sessionId;
|
|
1606
1670
|
this.sessionId = this.options.sessionId || sessionId;
|
|
1607
1671
|
}
|
|
1608
|
-
this.socket = new
|
|
1672
|
+
this.socket = new import_ws.default(
|
|
1609
1673
|
`ws${this.options.secure ? "s" : ""}://${this.options.host}:${this.options.port}/v4/websocket`,
|
|
1610
1674
|
{ headers }
|
|
1611
1675
|
);
|
|
@@ -2559,7 +2623,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
2559
2623
|
player.connected = payload.state.connected;
|
|
2560
2624
|
player.ping.ws = payload.state.ping >= 0 ? payload.state.ping : player.ping.ws <= 0 && player.connected ? null : player.ping.ws || 0;
|
|
2561
2625
|
if (!player.createdTimeStamp && payload.state.time) player.createdTimeStamp = payload.state.time;
|
|
2562
|
-
if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri && isAbsolute(player.queue.current?.info?.uri))) {
|
|
2626
|
+
if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri && (0, import_node_path.isAbsolute)(player.queue.current?.info?.uri))) {
|
|
2563
2627
|
player.filterManager.filterUpdatedState = false;
|
|
2564
2628
|
this._emitDebugEvent("PlayerUpdateFilterFixApply" /* PlayerUpdateFilterFixApply */, {
|
|
2565
2629
|
state: "log",
|
|
@@ -3364,7 +3428,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3364
3428
|
LavalinkNode._NodeLinkClass = NodeLinkNode;
|
|
3365
3429
|
|
|
3366
3430
|
// src/structures/NodeManager.ts
|
|
3367
|
-
var NodeManager = class extends EventEmitter {
|
|
3431
|
+
var NodeManager = class extends import_node_events.EventEmitter {
|
|
3368
3432
|
/**
|
|
3369
3433
|
* Emit an event
|
|
3370
3434
|
* @param event The event to emit
|
|
@@ -5238,7 +5302,8 @@ var Player = class {
|
|
|
5238
5302
|
voice = {
|
|
5239
5303
|
endpoint: null,
|
|
5240
5304
|
sessionId: null,
|
|
5241
|
-
token: null
|
|
5305
|
+
token: null,
|
|
5306
|
+
channelId: void 0
|
|
5242
5307
|
};
|
|
5243
5308
|
voiceState = {
|
|
5244
5309
|
selfDeaf: false,
|
|
@@ -5966,7 +6031,8 @@ var Player = class {
|
|
|
5966
6031
|
voice: {
|
|
5967
6032
|
token: this.voice.token,
|
|
5968
6033
|
endpoint: this.voice.endpoint,
|
|
5969
|
-
sessionId: this.voice.sessionId
|
|
6034
|
+
sessionId: this.voice.sessionId,
|
|
6035
|
+
channelId: this.voice.channelId
|
|
5970
6036
|
}
|
|
5971
6037
|
}
|
|
5972
6038
|
});
|
|
@@ -6044,7 +6110,7 @@ var Player = class {
|
|
|
6044
6110
|
};
|
|
6045
6111
|
|
|
6046
6112
|
// src/structures/LavalinkManager.ts
|
|
6047
|
-
var LavalinkManager = class extends
|
|
6113
|
+
var LavalinkManager = class extends import_node_events2.EventEmitter {
|
|
6048
6114
|
/**
|
|
6049
6115
|
* Emit an event
|
|
6050
6116
|
* @param event The event to emit
|
|
@@ -6532,17 +6598,43 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6532
6598
|
if ("token" in update) {
|
|
6533
6599
|
if (!player.node?.sessionId) throw new Error("Lavalink Node is either not ready or not up to date");
|
|
6534
6600
|
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : void 0);
|
|
6601
|
+
const channelId2Use = player.voice?.channelId || ("channel_id" in update ? update.channel_id : void 0);
|
|
6535
6602
|
if (!sessionId2Use) {
|
|
6536
6603
|
this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
|
|
6537
6604
|
state: "error",
|
|
6538
|
-
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6605
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, channelId: channelId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6539
6606
|
functionLayer: "LavalinkManager > sendRawData()"
|
|
6540
6607
|
});
|
|
6541
6608
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6542
6609
|
console.debug(
|
|
6543
6610
|
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Can't send updatePlayer for voice token session - Missing sessionId",
|
|
6544
6611
|
{
|
|
6545
|
-
voice: {
|
|
6612
|
+
voice: {
|
|
6613
|
+
token: update.token,
|
|
6614
|
+
endpoint: update.endpoint,
|
|
6615
|
+
sessionId: sessionId2Use,
|
|
6616
|
+
channelId: channelId2Use
|
|
6617
|
+
},
|
|
6618
|
+
update,
|
|
6619
|
+
playerVoice: player.voice
|
|
6620
|
+
}
|
|
6621
|
+
);
|
|
6622
|
+
} else if (!channelId2Use) {
|
|
6623
|
+
this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
|
|
6624
|
+
state: "error",
|
|
6625
|
+
message: `Can't send updatePlayer for voice token session - Missing channelId :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, channelId: channelId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6626
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
6627
|
+
});
|
|
6628
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6629
|
+
console.debug(
|
|
6630
|
+
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Can't send updatePlayer for voice token session - Missing channelId",
|
|
6631
|
+
{
|
|
6632
|
+
voice: {
|
|
6633
|
+
token: update.token,
|
|
6634
|
+
endpoint: update.endpoint,
|
|
6635
|
+
sessionId: sessionId2Use,
|
|
6636
|
+
channelId: channelId2Use
|
|
6637
|
+
},
|
|
6546
6638
|
update,
|
|
6547
6639
|
playerVoice: player.voice
|
|
6548
6640
|
}
|
|
@@ -6554,20 +6646,26 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6554
6646
|
voice: {
|
|
6555
6647
|
token: update.token,
|
|
6556
6648
|
endpoint: update.endpoint,
|
|
6557
|
-
sessionId: sessionId2Use
|
|
6649
|
+
sessionId: sessionId2Use,
|
|
6650
|
+
channelId: channelId2Use
|
|
6558
6651
|
}
|
|
6559
6652
|
}
|
|
6560
6653
|
});
|
|
6561
6654
|
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
6562
6655
|
state: "log",
|
|
6563
|
-
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6656
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, channelId: channelId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6564
6657
|
functionLayer: "LavalinkManager > sendRawData()"
|
|
6565
6658
|
});
|
|
6566
6659
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6567
6660
|
console.debug(
|
|
6568
6661
|
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Sent updatePlayer for voice token session",
|
|
6569
6662
|
{
|
|
6570
|
-
voice: {
|
|
6663
|
+
voice: {
|
|
6664
|
+
token: update.token,
|
|
6665
|
+
endpoint: update.endpoint,
|
|
6666
|
+
sessionId: sessionId2Use,
|
|
6667
|
+
channelId: channelId2Use
|
|
6668
|
+
},
|
|
6571
6669
|
playerVoice: player.voice,
|
|
6572
6670
|
update
|
|
6573
6671
|
}
|
|
@@ -6602,6 +6700,7 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6602
6700
|
if (player.voiceChannelId !== update.channel_id)
|
|
6603
6701
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
6604
6702
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
6703
|
+
player.voice.channelId = update.channel_id;
|
|
6605
6704
|
if (!player.voice.sessionId) {
|
|
6606
6705
|
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
6607
6706
|
state: "warn",
|
|
@@ -6677,7 +6776,8 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6677
6776
|
}
|
|
6678
6777
|
}
|
|
6679
6778
|
};
|
|
6680
|
-
export
|
|
6779
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
6780
|
+
0 && (module.exports = {
|
|
6681
6781
|
DebugEvents,
|
|
6682
6782
|
DefaultQueueStore,
|
|
6683
6783
|
DefaultSources,
|
|
@@ -6708,4 +6808,4 @@ export {
|
|
|
6708
6808
|
queueTrackEnd,
|
|
6709
6809
|
safeStringify,
|
|
6710
6810
|
validSponsorBlocks
|
|
6711
|
-
};
|
|
6811
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { ReadableStream } from 'stream/web';
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { ReadableStream } from 'node:stream/web';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Debug events for more detailed logging
|
|
@@ -803,6 +803,8 @@ interface LavalinkPlayerVoice {
|
|
|
803
803
|
endpoint: string;
|
|
804
804
|
/** The Voice SessionId */
|
|
805
805
|
sessionId: string;
|
|
806
|
+
/** The Voice Channel Id */
|
|
807
|
+
channelId?: string;
|
|
806
808
|
/** Whether or not the player is connected */
|
|
807
809
|
connected?: boolean;
|
|
808
810
|
/** The Ping to the voice server */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { ReadableStream } from 'stream/web';
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { ReadableStream } from 'node:stream/web';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Debug events for more detailed logging
|
|
@@ -803,6 +803,8 @@ interface LavalinkPlayerVoice {
|
|
|
803
803
|
endpoint: string;
|
|
804
804
|
/** The Voice SessionId */
|
|
805
805
|
sessionId: string;
|
|
806
|
+
/** The Voice Channel Id */
|
|
807
|
+
channelId?: string;
|
|
806
808
|
/** Whether or not the player is connected */
|
|
807
809
|
connected?: boolean;
|
|
808
810
|
/** The Ping to the voice server */
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,5 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/index.ts
|
|
30
|
-
var index_exports = {};
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
DebugEvents: () => DebugEvents,
|
|
33
|
-
DefaultQueueStore: () => DefaultQueueStore,
|
|
34
|
-
DefaultSources: () => DefaultSources,
|
|
35
|
-
DestroyReasons: () => DestroyReasons,
|
|
36
|
-
DisconnectReasons: () => DisconnectReasons,
|
|
37
|
-
EQList: () => EQList,
|
|
38
|
-
FilterManager: () => FilterManager,
|
|
39
|
-
LavalinkManager: () => LavalinkManager,
|
|
40
|
-
LavalinkNode: () => LavalinkNode,
|
|
41
|
-
LavalinkPlugins: () => LavalinkPlugins,
|
|
42
|
-
ManagerUtils: () => ManagerUtils,
|
|
43
|
-
MiniMap: () => MiniMap,
|
|
44
|
-
NodeLinkExclusiveEvents: () => NodeLinkExclusiveEvents,
|
|
45
|
-
NodeLinkNode: () => NodeLinkNode,
|
|
46
|
-
NodeManager: () => NodeManager,
|
|
47
|
-
NodeSymbol: () => NodeSymbol,
|
|
48
|
-
Player: () => Player,
|
|
49
|
-
Queue: () => Queue,
|
|
50
|
-
QueueSaver: () => QueueSaver,
|
|
51
|
-
QueueSymbol: () => QueueSymbol,
|
|
52
|
-
RecommendationsStrings: () => RecommendationsStrings,
|
|
53
|
-
ReconnectionState: () => ReconnectionState,
|
|
54
|
-
SourceLinksRegexes: () => SourceLinksRegexes,
|
|
55
|
-
TrackSymbol: () => TrackSymbol,
|
|
56
|
-
UnresolvedTrackSymbol: () => UnresolvedTrackSymbol,
|
|
57
|
-
audioOutputsData: () => audioOutputsData,
|
|
58
|
-
parseLavalinkConnUrl: () => parseLavalinkConnUrl,
|
|
59
|
-
queueTrackEnd: () => queueTrackEnd,
|
|
60
|
-
safeStringify: () => safeStringify,
|
|
61
|
-
validSponsorBlocks: () => validSponsorBlocks
|
|
62
|
-
});
|
|
63
|
-
module.exports = __toCommonJS(index_exports);
|
|
64
|
-
|
|
65
1
|
// src/structures/LavalinkManager.ts
|
|
66
|
-
|
|
2
|
+
import { EventEmitter as EventEmitter2 } from "events";
|
|
67
3
|
|
|
68
4
|
// src/structures/Constants.ts
|
|
69
5
|
var DebugEvents = /* @__PURE__ */ ((DebugEvents2) => {
|
|
@@ -404,11 +340,11 @@ var NodeLinkExclusiveEvents = [
|
|
|
404
340
|
];
|
|
405
341
|
|
|
406
342
|
// src/structures/NodeManager.ts
|
|
407
|
-
|
|
343
|
+
import { EventEmitter } from "events";
|
|
408
344
|
|
|
409
345
|
// src/structures/Node.ts
|
|
410
|
-
|
|
411
|
-
|
|
346
|
+
import { isAbsolute } from "path";
|
|
347
|
+
import WebSocket from "ws";
|
|
412
348
|
|
|
413
349
|
// src/structures/Types/Node.ts
|
|
414
350
|
var ReconnectionState = /* @__PURE__ */ ((ReconnectionState2) => {
|
|
@@ -420,8 +356,8 @@ var ReconnectionState = /* @__PURE__ */ ((ReconnectionState2) => {
|
|
|
420
356
|
})(ReconnectionState || {});
|
|
421
357
|
|
|
422
358
|
// src/structures/Utils.ts
|
|
423
|
-
|
|
424
|
-
|
|
359
|
+
import { URL as URL2 } from "url";
|
|
360
|
+
import { isRegExp } from "util/types";
|
|
425
361
|
|
|
426
362
|
// src/structures/LavalinkManagerStatics.ts
|
|
427
363
|
var DefaultSources = {
|
|
@@ -591,7 +527,7 @@ var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
591
527
|
function parseLavalinkConnUrl(connectionUrl) {
|
|
592
528
|
if (!connectionUrl.startsWith("lavalink://"))
|
|
593
529
|
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://'`);
|
|
594
|
-
const parsed = new
|
|
530
|
+
const parsed = new URL2(connectionUrl);
|
|
595
531
|
return {
|
|
596
532
|
authorization: parsed.password,
|
|
597
533
|
id: parsed.username,
|
|
@@ -856,7 +792,7 @@ var ManagerUtils = class {
|
|
|
856
792
|
});
|
|
857
793
|
}
|
|
858
794
|
if (this.LavalinkManager.options?.linksBlacklist.some(
|
|
859
|
-
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) ||
|
|
795
|
+
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) || isRegExp(v) && v.test(queryString)
|
|
860
796
|
)) {
|
|
861
797
|
throw new Error(`Query string contains a link / word which is blacklisted.`);
|
|
862
798
|
}
|
|
@@ -873,7 +809,7 @@ var ManagerUtils = class {
|
|
|
873
809
|
});
|
|
874
810
|
}
|
|
875
811
|
if (!this.LavalinkManager.options?.linksWhitelist.some(
|
|
876
|
-
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) ||
|
|
812
|
+
(v) => typeof v === "string" && queryString.toLowerCase().includes(v.toLowerCase()) || isRegExp(v) && v.test(queryString)
|
|
877
813
|
)) {
|
|
878
814
|
throw new Error(`Query string contains a link / word which isn't whitelisted.`);
|
|
879
815
|
}
|
|
@@ -1349,7 +1285,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1349
1285
|
* ```
|
|
1350
1286
|
*/
|
|
1351
1287
|
get connected() {
|
|
1352
|
-
return this.socket && this.socket.readyState ===
|
|
1288
|
+
return this.socket && this.socket.readyState === WebSocket.OPEN;
|
|
1353
1289
|
}
|
|
1354
1290
|
/**
|
|
1355
1291
|
* Returns the current ConnectionStatus
|
|
@@ -1669,7 +1605,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1669
1605
|
headers["Session-Id"] = this.options.sessionId || sessionId;
|
|
1670
1606
|
this.sessionId = this.options.sessionId || sessionId;
|
|
1671
1607
|
}
|
|
1672
|
-
this.socket = new
|
|
1608
|
+
this.socket = new WebSocket(
|
|
1673
1609
|
`ws${this.options.secure ? "s" : ""}://${this.options.host}:${this.options.port}/v4/websocket`,
|
|
1674
1610
|
{ headers }
|
|
1675
1611
|
);
|
|
@@ -2623,7 +2559,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
2623
2559
|
player.connected = payload.state.connected;
|
|
2624
2560
|
player.ping.ws = payload.state.ping >= 0 ? payload.state.ping : player.ping.ws <= 0 && player.connected ? null : player.ping.ws || 0;
|
|
2625
2561
|
if (!player.createdTimeStamp && payload.state.time) player.createdTimeStamp = payload.state.time;
|
|
2626
|
-
if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri &&
|
|
2562
|
+
if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri && isAbsolute(player.queue.current?.info?.uri))) {
|
|
2627
2563
|
player.filterManager.filterUpdatedState = false;
|
|
2628
2564
|
this._emitDebugEvent("PlayerUpdateFilterFixApply" /* PlayerUpdateFilterFixApply */, {
|
|
2629
2565
|
state: "log",
|
|
@@ -3428,7 +3364,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3428
3364
|
LavalinkNode._NodeLinkClass = NodeLinkNode;
|
|
3429
3365
|
|
|
3430
3366
|
// src/structures/NodeManager.ts
|
|
3431
|
-
var NodeManager = class extends
|
|
3367
|
+
var NodeManager = class extends EventEmitter {
|
|
3432
3368
|
/**
|
|
3433
3369
|
* Emit an event
|
|
3434
3370
|
* @param event The event to emit
|
|
@@ -5302,7 +5238,8 @@ var Player = class {
|
|
|
5302
5238
|
voice = {
|
|
5303
5239
|
endpoint: null,
|
|
5304
5240
|
sessionId: null,
|
|
5305
|
-
token: null
|
|
5241
|
+
token: null,
|
|
5242
|
+
channelId: void 0
|
|
5306
5243
|
};
|
|
5307
5244
|
voiceState = {
|
|
5308
5245
|
selfDeaf: false,
|
|
@@ -6030,7 +5967,8 @@ var Player = class {
|
|
|
6030
5967
|
voice: {
|
|
6031
5968
|
token: this.voice.token,
|
|
6032
5969
|
endpoint: this.voice.endpoint,
|
|
6033
|
-
sessionId: this.voice.sessionId
|
|
5970
|
+
sessionId: this.voice.sessionId,
|
|
5971
|
+
channelId: this.voice.channelId
|
|
6034
5972
|
}
|
|
6035
5973
|
}
|
|
6036
5974
|
});
|
|
@@ -6108,7 +6046,7 @@ var Player = class {
|
|
|
6108
6046
|
};
|
|
6109
6047
|
|
|
6110
6048
|
// src/structures/LavalinkManager.ts
|
|
6111
|
-
var LavalinkManager = class extends
|
|
6049
|
+
var LavalinkManager = class extends EventEmitter2 {
|
|
6112
6050
|
/**
|
|
6113
6051
|
* Emit an event
|
|
6114
6052
|
* @param event The event to emit
|
|
@@ -6596,17 +6534,43 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
6596
6534
|
if ("token" in update) {
|
|
6597
6535
|
if (!player.node?.sessionId) throw new Error("Lavalink Node is either not ready or not up to date");
|
|
6598
6536
|
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : void 0);
|
|
6537
|
+
const channelId2Use = player.voice?.channelId || ("channel_id" in update ? update.channel_id : void 0);
|
|
6599
6538
|
if (!sessionId2Use) {
|
|
6600
6539
|
this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
|
|
6601
6540
|
state: "error",
|
|
6602
|
-
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6541
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, channelId: channelId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6603
6542
|
functionLayer: "LavalinkManager > sendRawData()"
|
|
6604
6543
|
});
|
|
6605
6544
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6606
6545
|
console.debug(
|
|
6607
6546
|
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Can't send updatePlayer for voice token session - Missing sessionId",
|
|
6608
6547
|
{
|
|
6609
|
-
voice: {
|
|
6548
|
+
voice: {
|
|
6549
|
+
token: update.token,
|
|
6550
|
+
endpoint: update.endpoint,
|
|
6551
|
+
sessionId: sessionId2Use,
|
|
6552
|
+
channelId: channelId2Use
|
|
6553
|
+
},
|
|
6554
|
+
update,
|
|
6555
|
+
playerVoice: player.voice
|
|
6556
|
+
}
|
|
6557
|
+
);
|
|
6558
|
+
} else if (!channelId2Use) {
|
|
6559
|
+
this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
|
|
6560
|
+
state: "error",
|
|
6561
|
+
message: `Can't send updatePlayer for voice token session - Missing channelId :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, channelId: channelId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6562
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
6563
|
+
});
|
|
6564
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6565
|
+
console.debug(
|
|
6566
|
+
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Can't send updatePlayer for voice token session - Missing channelId",
|
|
6567
|
+
{
|
|
6568
|
+
voice: {
|
|
6569
|
+
token: update.token,
|
|
6570
|
+
endpoint: update.endpoint,
|
|
6571
|
+
sessionId: sessionId2Use,
|
|
6572
|
+
channelId: channelId2Use
|
|
6573
|
+
},
|
|
6610
6574
|
update,
|
|
6611
6575
|
playerVoice: player.voice
|
|
6612
6576
|
}
|
|
@@ -6618,20 +6582,26 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
6618
6582
|
voice: {
|
|
6619
6583
|
token: update.token,
|
|
6620
6584
|
endpoint: update.endpoint,
|
|
6621
|
-
sessionId: sessionId2Use
|
|
6585
|
+
sessionId: sessionId2Use,
|
|
6586
|
+
channelId: channelId2Use
|
|
6622
6587
|
}
|
|
6623
6588
|
}
|
|
6624
6589
|
});
|
|
6625
6590
|
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
6626
6591
|
state: "log",
|
|
6627
|
-
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6592
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, channelId: channelId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
6628
6593
|
functionLayer: "LavalinkManager > sendRawData()"
|
|
6629
6594
|
});
|
|
6630
6595
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6631
6596
|
console.debug(
|
|
6632
6597
|
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Sent updatePlayer for voice token session",
|
|
6633
6598
|
{
|
|
6634
|
-
voice: {
|
|
6599
|
+
voice: {
|
|
6600
|
+
token: update.token,
|
|
6601
|
+
endpoint: update.endpoint,
|
|
6602
|
+
sessionId: sessionId2Use,
|
|
6603
|
+
channelId: channelId2Use
|
|
6604
|
+
},
|
|
6635
6605
|
playerVoice: player.voice,
|
|
6636
6606
|
update
|
|
6637
6607
|
}
|
|
@@ -6666,6 +6636,7 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
6666
6636
|
if (player.voiceChannelId !== update.channel_id)
|
|
6667
6637
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
6668
6638
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
6639
|
+
player.voice.channelId = update.channel_id;
|
|
6669
6640
|
if (!player.voice.sessionId) {
|
|
6670
6641
|
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
6671
6642
|
state: "warn",
|
|
@@ -6741,8 +6712,7 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
6741
6712
|
}
|
|
6742
6713
|
}
|
|
6743
6714
|
};
|
|
6744
|
-
|
|
6745
|
-
0 && (module.exports = {
|
|
6715
|
+
export {
|
|
6746
6716
|
DebugEvents,
|
|
6747
6717
|
DefaultQueueStore,
|
|
6748
6718
|
DefaultSources,
|
|
@@ -6773,4 +6743,4 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
6773
6743
|
queueTrackEnd,
|
|
6774
6744
|
safeStringify,
|
|
6775
6745
|
validSponsorBlocks
|
|
6776
|
-
}
|
|
6746
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lavalink-client",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients. - Supports NodeLink@v3 too.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advanced",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
|
+
"type": "module",
|
|
35
36
|
"main": "./dist/index.js",
|
|
36
37
|
"module": "./dist/index.mjs",
|
|
37
38
|
"types": "./dist/index.d.ts",
|
|
@@ -57,13 +58,14 @@
|
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"tslib": "^2.8.1",
|
|
60
|
-
"ws": "^8.
|
|
61
|
+
"ws": "^8.19.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@types/
|
|
64
|
+
"@types/bun": "latest",
|
|
65
|
+
"@types/node": "^24.10.15",
|
|
64
66
|
"@types/ws": "^8.18.1",
|
|
65
67
|
"oxfmt": "^0.28.0",
|
|
66
|
-
"oxlint": "^1.
|
|
68
|
+
"oxlint": "^1.50.0",
|
|
67
69
|
"tsup": "^8.5.1",
|
|
68
70
|
"typescript": "^5.9.3"
|
|
69
71
|
},
|
|
@@ -71,6 +73,7 @@
|
|
|
71
73
|
"bun": ">=1.1.27",
|
|
72
74
|
"node": ">=18.0.0"
|
|
73
75
|
},
|
|
76
|
+
"packageManager": "bun@1.3.9",
|
|
74
77
|
"pnpm": {
|
|
75
78
|
"onlyBuiltDependencies": [
|
|
76
79
|
"esbuild"
|