lavalink-client 2.9.11 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/dist/index.cjs +139 -74
- package/dist/index.d.cts +60 -48
- package/dist/index.d.ts +60 -48
- package/dist/index.js +138 -74
- package/dist/index.mjs +138 -74
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,8 +111,16 @@ pnpm add tomato6966/lavalink-client
|
|
|
111
111
|
|
|
112
112
|
This client can be used with nodelink too, but because nodelink's websocket is different than the one from lavalink, you need to disable a few things on the NODE OPTIONS / NODE PROPERTIES:
|
|
113
113
|
|
|
114
|
+
Import the NodeType Enum:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
import { NodeType } from "lavalink-client"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
// You must assign NodeLink enum to nodeType of the node options, before creating the node.
|
|
121
|
+
|
|
114
122
|
```ts
|
|
115
|
-
nodeOptions.nodeType =
|
|
123
|
+
nodeOptions.nodeType = NodeType.NodeLink;
|
|
116
124
|
```
|
|
117
125
|
|
|
118
126
|
this can be done directly when creating the node in the lavalinkmanager.
|
|
@@ -122,7 +130,7 @@ client.lavalink = new LavalinkManager({
|
|
|
122
130
|
nodes: [
|
|
123
131
|
{
|
|
124
132
|
host: "localhost",
|
|
125
|
-
nodeType:
|
|
133
|
+
nodeType: NodeType.NodeLink, // provide nodeType "nodelink" to it.
|
|
126
134
|
},
|
|
127
135
|
],
|
|
128
136
|
});
|
|
@@ -135,8 +143,10 @@ client.lavalink = new LavalinkManager({
|
|
|
135
143
|
port: 2333,
|
|
136
144
|
id: "Main Node",
|
|
137
145
|
// set to nodeLink
|
|
138
|
-
nodeType:
|
|
146
|
+
nodeType: NodeType.NodeLink, // provide it here
|
|
139
147
|
},
|
|
148
|
+
// you can also use the util like this, and it will return a valid node option object. must start with: lavalink:// | nodelink://
|
|
149
|
+
// parseLavalinkConnUrl("nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
140
150
|
],
|
|
141
151
|
// A function to send voice server updates to the Lavalink client
|
|
142
152
|
sendToShard: (guildId, payload) => {
|
|
@@ -171,6 +181,8 @@ const node = client.lavalink.lavalinkManager.getNode("id") as NodeLinkNode;
|
|
|
171
181
|
node.addMixerLayer()
|
|
172
182
|
```
|
|
173
183
|
|
|
184
|
+
⚠️ NODELINK does not really require you to run "instaUpdateFiltersFix" on player creation.
|
|
185
|
+
|
|
174
186
|
### NodeLink Specific Methods
|
|
175
187
|
|
|
176
188
|
- **`node.getYoutubeOAUTH(refreshToken)`**: Exchange a Refresh Token for an Access Token. [Docs](https://nodelink.js.org/docs/api/nodelink-features#oauth)
|
|
@@ -392,6 +404,8 @@ client.lavalink = new LavalinkManager({
|
|
|
392
404
|
port: 2333,
|
|
393
405
|
id: "Main Node",
|
|
394
406
|
},
|
|
407
|
+
// you can also use the util like this, and it will return a valid node option object.
|
|
408
|
+
// parseLavalinkConnUrl("nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
395
409
|
],
|
|
396
410
|
// A function to send voice server updates to the Lavalink client
|
|
397
411
|
sendToShard: (guildId, payload) => {
|
|
@@ -448,6 +462,8 @@ client.lavalink = new LavalinkManager({
|
|
|
448
462
|
retryAmount: 5,
|
|
449
463
|
retryDelay: 10_000, // 10 seconds
|
|
450
464
|
},
|
|
465
|
+
// you can also use the util like this, and it will return a valid node option object. must start with: lavalink:// | nodelink://
|
|
466
|
+
// parseLavalinkConnUrl("lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
451
467
|
],
|
|
452
468
|
sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
|
|
453
469
|
autoSkip: true, // automatically play the next song of the queue, on: trackend, trackerror, trackexception
|
package/dist/index.cjs
CHANGED
|
@@ -45,6 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
NodeLinkNode: () => NodeLinkNode,
|
|
46
46
|
NodeManager: () => NodeManager,
|
|
47
47
|
NodeSymbol: () => NodeSymbol,
|
|
48
|
+
NodeType: () => NodeType,
|
|
48
49
|
Player: () => Player,
|
|
49
50
|
Queue: () => Queue,
|
|
50
51
|
QueueSaver: () => QueueSaver,
|
|
@@ -403,9 +404,6 @@ var NodeLinkExclusiveEvents = [
|
|
|
403
404
|
"LyricsNotFoundEvent"
|
|
404
405
|
];
|
|
405
406
|
|
|
406
|
-
// src/structures/NodeManager.ts
|
|
407
|
-
var import_node_events = require("events");
|
|
408
|
-
|
|
409
407
|
// src/structures/Node.ts
|
|
410
408
|
var import_node_path = require("path");
|
|
411
409
|
var import_ws = __toESM(require("ws"), 1);
|
|
@@ -418,6 +416,11 @@ var ReconnectionState = /* @__PURE__ */ ((ReconnectionState2) => {
|
|
|
418
416
|
ReconnectionState2["DESTROYING"] = "DESTROYING";
|
|
419
417
|
return ReconnectionState2;
|
|
420
418
|
})(ReconnectionState || {});
|
|
419
|
+
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
420
|
+
NodeType2["Lavalink"] = "Lavalink";
|
|
421
|
+
NodeType2["NodeLink"] = "NodeLink";
|
|
422
|
+
return NodeType2;
|
|
423
|
+
})(NodeType || {});
|
|
421
424
|
|
|
422
425
|
// src/structures/Utils.ts
|
|
423
426
|
var import_node_url = require("url");
|
|
@@ -589,12 +592,14 @@ var QueueSymbol = /* @__PURE__ */ Symbol("LC-Queue");
|
|
|
589
592
|
var NodeSymbol = /* @__PURE__ */ Symbol("LC-Node");
|
|
590
593
|
var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
591
594
|
function parseLavalinkConnUrl(connectionUrl) {
|
|
592
|
-
if (!connectionUrl
|
|
595
|
+
if (!connectionUrl) throw new Error("ConnectionUrl is required");
|
|
596
|
+
const lowered = connectionUrl.toLowerCase();
|
|
597
|
+
if (!lowered.startsWith("lavalink://") && !lowered.startsWith("nodelink://"))
|
|
593
598
|
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://' or 'nodelink://'`);
|
|
594
599
|
const parsed = new import_node_url.URL(connectionUrl);
|
|
595
600
|
return {
|
|
596
601
|
authorization: parsed.password,
|
|
597
|
-
nodeType:
|
|
602
|
+
nodeType: lowered.startsWith("lavalink://") ? "Lavalink" /* Lavalink */ : "NodeLink" /* NodeLink */,
|
|
598
603
|
id: parsed.username,
|
|
599
604
|
host: parsed.hostname,
|
|
600
605
|
port: Number(parsed.port)
|
|
@@ -1248,7 +1253,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1248
1253
|
heartBeatPongTimestamp = 0;
|
|
1249
1254
|
heartBeatInterval;
|
|
1250
1255
|
pingTimeout;
|
|
1251
|
-
nodeType = "Lavalink"
|
|
1256
|
+
nodeType = "Lavalink" /* Lavalink */;
|
|
1252
1257
|
isAlive = false;
|
|
1253
1258
|
static _NodeLinkClass = null;
|
|
1254
1259
|
/** The provided Options of the Node */
|
|
@@ -1322,7 +1327,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1322
1327
|
* Returns wether the plugin validations are enabled or not
|
|
1323
1328
|
*/
|
|
1324
1329
|
get _checkForPlugins() {
|
|
1325
|
-
if (this.nodeType === "NodeLink") return false;
|
|
1330
|
+
if (this.nodeType === "NodeLink" /* NodeLink */) return false;
|
|
1326
1331
|
return !!this.options?.autoChecks?.pluginValidations;
|
|
1327
1332
|
}
|
|
1328
1333
|
/**
|
|
@@ -1392,16 +1397,17 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1392
1397
|
heartBeatInterval: 3e4,
|
|
1393
1398
|
enablePingOnStatsCheck: true,
|
|
1394
1399
|
closeOnError: true,
|
|
1400
|
+
nodeType: "Lavalink" /* Lavalink */,
|
|
1395
1401
|
...options,
|
|
1396
1402
|
autoChecks: {
|
|
1397
1403
|
sourcesValidations: options?.autoChecks?.sourcesValidations ?? true,
|
|
1398
1404
|
pluginValidations: options?.autoChecks?.pluginValidations ?? true
|
|
1399
1405
|
}
|
|
1400
1406
|
};
|
|
1401
|
-
if (this.options.nodeType === "NodeLink" && this.constructor.name === "LavalinkNode" && _LavalinkNode._NodeLinkClass) {
|
|
1407
|
+
if (this.options.nodeType === "NodeLink" /* NodeLink */ && this.constructor.name === "LavalinkNode" && _LavalinkNode._NodeLinkClass) {
|
|
1402
1408
|
return new _LavalinkNode._NodeLinkClass(options, manager);
|
|
1403
1409
|
}
|
|
1404
|
-
this.nodeType = this.options.nodeType
|
|
1410
|
+
this.nodeType = this.options.nodeType;
|
|
1405
1411
|
this.NodeManager = manager;
|
|
1406
1412
|
this.validate();
|
|
1407
1413
|
if (this.options.secure && this.options.port !== 443)
|
|
@@ -1540,10 +1546,8 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1540
1546
|
if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
|
|
1541
1547
|
if (/^https?:\/\//.test(Query.query))
|
|
1542
1548
|
return this.search({ query: Query.query, source: Query.source }, requestUser);
|
|
1543
|
-
if (!
|
|
1544
|
-
throw new SyntaxError(
|
|
1545
|
-
`Query.source must be a source from LavaSrc: "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ytmsearch" | "ytsearch"`
|
|
1546
|
-
);
|
|
1549
|
+
if (!this.isLavaSrcSource(Query.source))
|
|
1550
|
+
throw new SyntaxError(`Query.source must be an available source from LavaSrc`);
|
|
1547
1551
|
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasearch-plugin"))
|
|
1548
1552
|
throw new RangeError(`there is no lavasearch-plugin available in the lavalink node: ${this.id}`);
|
|
1549
1553
|
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin"))
|
|
@@ -1969,7 +1973,10 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1969
1973
|
throw new RangeError(
|
|
1970
1974
|
`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
|
|
1971
1975
|
);
|
|
1972
|
-
|
|
1976
|
+
let url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
|
|
1977
|
+
if (this.nodeType === "NodeLink" /* NodeLink */) {
|
|
1978
|
+
url = `/loadlyrics?encodedTrack=${track.encoded}`;
|
|
1979
|
+
}
|
|
1973
1980
|
return await this.request(url);
|
|
1974
1981
|
},
|
|
1975
1982
|
/**
|
|
@@ -1995,7 +2002,10 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1995
2002
|
throw new RangeError(
|
|
1996
2003
|
`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
|
|
1997
2004
|
);
|
|
1998
|
-
|
|
2005
|
+
let url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
|
|
2006
|
+
if (this.nodeType === "NodeLink" /* NodeLink */) {
|
|
2007
|
+
url = `/loadlyrics?encodedTrack=${this._LManager.getPlayer(guildId)?.queue.current?.encoded}`;
|
|
2008
|
+
}
|
|
1999
2009
|
return await this.request(url);
|
|
2000
2010
|
},
|
|
2001
2011
|
/**
|
|
@@ -2344,20 +2354,22 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
2344
2354
|
throw new SyntaxError("LavalinkNode.autoChecks.pluginValidations must be either false | true aka boolean");
|
|
2345
2355
|
if (this.options.regions !== void 0 && (!Array.isArray(this.options.regions) || !this.options.regions.every((r) => typeof r === "string")))
|
|
2346
2356
|
throw new SyntaxError("LavalinkNode.regions must be an Array of strings");
|
|
2357
|
+
if (this.options.nodeType && !NodeType[this.options.nodeType])
|
|
2358
|
+
throw new SyntaxError("LavalinkNode.nodeType must be a valid NodeType enum value");
|
|
2347
2359
|
}
|
|
2348
2360
|
/**
|
|
2349
2361
|
* Checks if the node is a NodeLink node
|
|
2350
2362
|
* @returns true if the node is a NodeLink node
|
|
2351
2363
|
*/
|
|
2352
2364
|
isNodeLink() {
|
|
2353
|
-
return this.nodeType === "NodeLink"
|
|
2365
|
+
return this.nodeType === "NodeLink" /* NodeLink */;
|
|
2354
2366
|
}
|
|
2355
2367
|
/**
|
|
2356
2368
|
* Checks if the node is a Lavalink node
|
|
2357
2369
|
* @returns true if the node is a Lavalink node
|
|
2358
2370
|
*/
|
|
2359
2371
|
isLavalinkNode() {
|
|
2360
|
-
return this.nodeType === "Lavalink"
|
|
2372
|
+
return this.nodeType === "Lavalink" /* Lavalink */;
|
|
2361
2373
|
}
|
|
2362
2374
|
/**
|
|
2363
2375
|
* Sync the data of the player you make an action to lavalink to
|
|
@@ -3126,17 +3138,36 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
3126
3138
|
this._LManager.emit("LyricsNotFound", player, track, payload);
|
|
3127
3139
|
return;
|
|
3128
3140
|
}
|
|
3141
|
+
/**
|
|
3142
|
+
* @private
|
|
3143
|
+
* util function to check if a provided source is valid with current node.
|
|
3144
|
+
* @param {LavalinkSearchPlatform} src
|
|
3145
|
+
* @returns {boolean} True if provided source is valid.
|
|
3146
|
+
*/
|
|
3147
|
+
isLavaSrcSource(src) {
|
|
3148
|
+
const source = /* @__PURE__ */ new Set([]);
|
|
3149
|
+
if (this.info?.sourceManagers.includes("spotify")) source.add("spsearch").add("sprec");
|
|
3150
|
+
if (this.info?.sourceManagers.includes("applemusic")) source.add("amsearch");
|
|
3151
|
+
if (this.info?.sourceManagers.includes("deezer")) source.add("dzsearch").add("dzrec").add("dzisrc");
|
|
3152
|
+
if (this.info?.sourceManagers.includes("yandexmusic")) source.add("ymsearch").add("ymrec");
|
|
3153
|
+
if (this.info?.sourceManagers.includes("vkmusic")) source.add("vksearch").add("vkrec");
|
|
3154
|
+
if (this.info?.sourceManagers.includes("tidal")) source.add("tdsearch").add("tdrec");
|
|
3155
|
+
if (this.info?.sourceManagers.includes("qobuz")) source.add("qbsearch").add("qbisrc").add("qbrec");
|
|
3156
|
+
if (this.info?.sourceManagers.includes("pandora")) source.add("pdsearch").add("pdisrc").add("pdrec");
|
|
3157
|
+
if (this.info?.sourceManagers.includes("youtube")) source.add("ytsearch").add("ytmsearch");
|
|
3158
|
+
return typeof src === "string" && source.has(src);
|
|
3159
|
+
}
|
|
3129
3160
|
};
|
|
3130
3161
|
|
|
3131
3162
|
// src/structures/NodeLink.ts
|
|
3132
3163
|
var NodeLinkNode = class extends LavalinkNode {
|
|
3133
|
-
nodeType = "NodeLink"
|
|
3164
|
+
nodeType = "NodeLink" /* NodeLink */;
|
|
3134
3165
|
constructor(options, manager) {
|
|
3135
3166
|
super(options, manager);
|
|
3136
|
-
if (this.options.nodeType === "Lavalink" && this.constructor.name === "NodeLink") {
|
|
3167
|
+
if (this.options.nodeType === "Lavalink" /* Lavalink */ && (this.constructor.name === "NodeLinkNode" || this.constructor.name === "NodeLink")) {
|
|
3137
3168
|
return new LavalinkNode(options, manager);
|
|
3138
3169
|
}
|
|
3139
|
-
this.nodeType = "NodeLink"
|
|
3170
|
+
this.nodeType = "NodeLink" /* NodeLink */;
|
|
3140
3171
|
}
|
|
3141
3172
|
/**
|
|
3142
3173
|
* Uses the gapless feature to set the next track to be played.
|
|
@@ -3477,6 +3508,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3477
3508
|
LavalinkNode._NodeLinkClass = NodeLinkNode;
|
|
3478
3509
|
|
|
3479
3510
|
// src/structures/NodeManager.ts
|
|
3511
|
+
var import_node_events = require("events");
|
|
3480
3512
|
var NodeManager = class extends import_node_events.EventEmitter {
|
|
3481
3513
|
/**
|
|
3482
3514
|
* Emit an event
|
|
@@ -3538,9 +3570,7 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3538
3570
|
super();
|
|
3539
3571
|
this.LavalinkManager = LavalinkManager2;
|
|
3540
3572
|
if (this.LavalinkManager.options.nodes)
|
|
3541
|
-
this.LavalinkManager.options.nodes.forEach((node) =>
|
|
3542
|
-
this.createNode(node);
|
|
3543
|
-
});
|
|
3573
|
+
this.LavalinkManager.options.nodes.forEach((node) => this.createNode(node));
|
|
3544
3574
|
}
|
|
3545
3575
|
/**
|
|
3546
3576
|
* Disconnects all Nodes from lavalink ws sockets
|
|
@@ -3601,9 +3631,21 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3601
3631
|
* @returns The node that was created
|
|
3602
3632
|
*/
|
|
3603
3633
|
createNode(options) {
|
|
3634
|
+
if (options instanceof NodeLinkNode) {
|
|
3635
|
+
const preExistingNode = this.nodes.get(options.id);
|
|
3636
|
+
if (preExistingNode) return preExistingNode;
|
|
3637
|
+
this.nodes.set(options.id, options);
|
|
3638
|
+
return options;
|
|
3639
|
+
}
|
|
3640
|
+
if (options instanceof LavalinkNode) {
|
|
3641
|
+
const preExistingNode = this.nodes.get(options.id);
|
|
3642
|
+
if (preExistingNode) return preExistingNode;
|
|
3643
|
+
this.nodes.set(options.id, options);
|
|
3644
|
+
return options;
|
|
3645
|
+
}
|
|
3604
3646
|
if (this.nodes.has(options.id || `${options.host}:${options.port}`))
|
|
3605
3647
|
return this.nodes.get(options.id || `${options.host}:${options.port}`);
|
|
3606
|
-
const newNode = options.nodeType === "NodeLink" ? new NodeLinkNode(options, this) : new LavalinkNode(options, this);
|
|
3648
|
+
const newNode = options.nodeType === "NodeLink" /* NodeLink */ ? new NodeLinkNode(options, this) : new LavalinkNode(options, this);
|
|
3607
3649
|
this.nodes.set(newNode.id, newNode);
|
|
3608
3650
|
return newNode;
|
|
3609
3651
|
}
|
|
@@ -3612,48 +3654,57 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3612
3654
|
* @param sortType The type of sorting to use
|
|
3613
3655
|
* @returns
|
|
3614
3656
|
*/
|
|
3615
|
-
leastUsedNodes(sortType = "players") {
|
|
3657
|
+
leastUsedNodes(sortType = "players", filterForNodeTypes) {
|
|
3658
|
+
const normalizedFilterForNodeTypes = filterForNodeTypes?.length ? filterForNodeTypes : ["Lavalink" /* Lavalink */, "NodeLink" /* NodeLink */];
|
|
3616
3659
|
const connectedNodes = Array.from(this.nodes.values()).filter((node) => node.connected);
|
|
3660
|
+
const normalizedNodeTypes = new Set(
|
|
3661
|
+
normalizedFilterForNodeTypes.map(
|
|
3662
|
+
(nodeTypeFilter) => Object.values(NodeType).includes(nodeTypeFilter) ? nodeTypeFilter : nodeTypeFilter.nodeType
|
|
3663
|
+
)
|
|
3664
|
+
);
|
|
3665
|
+
const filteredConnectedNodes = connectedNodes.filter((node) => normalizedNodeTypes.has(node.nodeType));
|
|
3617
3666
|
switch (sortType) {
|
|
3618
3667
|
case "memory":
|
|
3619
3668
|
{
|
|
3620
|
-
return
|
|
3669
|
+
return filteredConnectedNodes.sort(
|
|
3670
|
+
(a, b) => (a.stats?.memory?.used || 0) - (b.stats?.memory?.used || 0)
|
|
3671
|
+
);
|
|
3621
3672
|
}
|
|
3622
3673
|
break;
|
|
3623
3674
|
case "cpuLavalink":
|
|
3624
3675
|
{
|
|
3625
|
-
return
|
|
3676
|
+
return filteredConnectedNodes.sort(
|
|
3626
3677
|
(a, b) => (a.stats?.cpu?.lavalinkLoad || 0) - (b.stats?.cpu?.lavalinkLoad || 0)
|
|
3627
3678
|
);
|
|
3628
3679
|
}
|
|
3629
3680
|
break;
|
|
3630
3681
|
case "cpuSystem":
|
|
3631
3682
|
{
|
|
3632
|
-
return
|
|
3683
|
+
return filteredConnectedNodes.sort(
|
|
3633
3684
|
(a, b) => (a.stats?.cpu?.systemLoad || 0) - (b.stats?.cpu?.systemLoad || 0)
|
|
3634
3685
|
);
|
|
3635
3686
|
}
|
|
3636
3687
|
break;
|
|
3637
3688
|
case "calls":
|
|
3638
3689
|
{
|
|
3639
|
-
return
|
|
3690
|
+
return filteredConnectedNodes.sort((a, b) => a.calls - b.calls);
|
|
3640
3691
|
}
|
|
3641
3692
|
break;
|
|
3642
3693
|
case "playingPlayers":
|
|
3643
3694
|
{
|
|
3644
|
-
return
|
|
3695
|
+
return filteredConnectedNodes.sort(
|
|
3645
3696
|
(a, b) => (a.stats?.playingPlayers || 0) - (b.stats?.playingPlayers || 0)
|
|
3646
3697
|
);
|
|
3647
3698
|
}
|
|
3648
3699
|
break;
|
|
3649
3700
|
case "players":
|
|
3650
3701
|
{
|
|
3651
|
-
return
|
|
3702
|
+
return filteredConnectedNodes.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
3652
3703
|
}
|
|
3653
3704
|
break;
|
|
3654
3705
|
default:
|
|
3655
3706
|
{
|
|
3656
|
-
return
|
|
3707
|
+
return filteredConnectedNodes.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
3657
3708
|
}
|
|
3658
3709
|
break;
|
|
3659
3710
|
}
|
|
@@ -3686,13 +3737,22 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3686
3737
|
}
|
|
3687
3738
|
/**
|
|
3688
3739
|
* Get a node from the nodeManager
|
|
3689
|
-
* @param node The node to get
|
|
3740
|
+
* @param node The node to get either by idetnifier, by class or by enum
|
|
3690
3741
|
* @returns The node that was retrieved
|
|
3691
3742
|
*/
|
|
3692
3743
|
getNode(node) {
|
|
3744
|
+
if (!!node && Object.values(NodeType).includes(node)) {
|
|
3745
|
+
return this.leastUsedNodes().filter((node2) => node2.nodeType === node2)[0];
|
|
3746
|
+
}
|
|
3747
|
+
if (!!node && node instanceof NodeLinkNode) {
|
|
3748
|
+
return this.leastUsedNodes().filter((node2) => node2 instanceof NodeLinkNode)[0];
|
|
3749
|
+
}
|
|
3750
|
+
if (!!node && node instanceof LavalinkNode) {
|
|
3751
|
+
return this.leastUsedNodes().filter((node2) => node2 instanceof LavalinkNode)[0];
|
|
3752
|
+
}
|
|
3693
3753
|
const decodeNode = typeof node === "string" ? this.nodes.get(node) : node;
|
|
3694
3754
|
if (!decodeNode) return void 0;
|
|
3695
|
-
if (decodeNode.nodeType === "NodeLink") return decodeNode;
|
|
3755
|
+
if (decodeNode.nodeType === "NodeLink" /* NodeLink */) return decodeNode;
|
|
3696
3756
|
return decodeNode;
|
|
3697
3757
|
}
|
|
3698
3758
|
};
|
|
@@ -6055,7 +6115,7 @@ var Player = class {
|
|
|
6055
6115
|
);
|
|
6056
6116
|
if (this.queue.current || this.queue.tracks.length) {
|
|
6057
6117
|
const trackSources = new Set(
|
|
6058
|
-
[this.queue.current, ...this.queue.tracks].map((track) => track
|
|
6118
|
+
[this.queue.current, ...this.queue.tracks].map((track) => track?.info?.sourceName).filter(Boolean)
|
|
6059
6119
|
);
|
|
6060
6120
|
const missingSources = [...trackSources].filter(
|
|
6061
6121
|
(source) => !updateNode.info?.sourceManagers.includes(source)
|
|
@@ -6331,9 +6391,11 @@ var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEm
|
|
|
6331
6391
|
throw new SyntaxError("ManagerOption.autoSkipOnResolveError must be either false | true aka boolean");
|
|
6332
6392
|
if (options?.emitNewSongsOnly && typeof options?.emitNewSongsOnly !== "boolean")
|
|
6333
6393
|
throw new SyntaxError("ManagerOption.emitNewSongsOnly must be either false | true aka boolean");
|
|
6334
|
-
if (!options?.nodes || !Array.isArray(options?.nodes) || !options?.nodes.every(
|
|
6394
|
+
if (!options?.nodes || !Array.isArray(options?.nodes) || !options?.nodes.every(
|
|
6395
|
+
(node) => node instanceof NodeLinkNode || node instanceof LavalinkNode || this.utils.isNodeOptions(node)
|
|
6396
|
+
))
|
|
6335
6397
|
throw new SyntaxError(
|
|
6336
|
-
"ManagerOption.nodes must be an Array of NodeOptions and is required of at least 1 Node"
|
|
6398
|
+
"ManagerOption.nodes must be an Array of NodeOptions or the Node-Classes 'NodeLinkNode' or 'LavalinkNode' and is required of at least 1 Node"
|
|
6337
6399
|
);
|
|
6338
6400
|
if (options?.queueOptions?.queueStore) {
|
|
6339
6401
|
const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(options?.queueOptions?.queueStore));
|
|
@@ -6389,48 +6451,50 @@ var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEm
|
|
|
6389
6451
|
* port: 2333,
|
|
6390
6452
|
* id: "testnode"
|
|
6391
6453
|
* },
|
|
6454
|
+
* // you can also use the util like this, and it will return a valid node option object. must start with: lavalink:// | nodelink://
|
|
6455
|
+
* // parseLavalinkConnUrl("nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
6392
6456
|
* sendToShard(guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
|
|
6393
|
-
*
|
|
6394
|
-
*
|
|
6395
|
-
*
|
|
6396
|
-
*
|
|
6397
|
-
*
|
|
6398
|
-
*
|
|
6399
|
-
*
|
|
6400
|
-
*
|
|
6401
|
-
*
|
|
6402
|
-
*
|
|
6403
|
-
*
|
|
6404
|
-
*
|
|
6405
|
-
*
|
|
6406
|
-
*
|
|
6407
|
-
*
|
|
6408
|
-
*
|
|
6409
|
-
*
|
|
6410
|
-
* onEmptyQueue: {
|
|
6411
|
-
* destroyAfterMs: 30_000,
|
|
6412
|
-
* //autoPlayFunction: YourAutoplayFunction,
|
|
6413
|
-
* },
|
|
6414
|
-
* useUnresolvedData: true
|
|
6457
|
+
* ],
|
|
6458
|
+
* client: {
|
|
6459
|
+
* id: process.env.CLIENT_ID,
|
|
6460
|
+
* username: "TESTBOT"
|
|
6461
|
+
* },
|
|
6462
|
+
* // optional Options:
|
|
6463
|
+
* autoSkip: true,
|
|
6464
|
+
* playerOptions: {
|
|
6465
|
+
* applyVolumeAsFilter: false,
|
|
6466
|
+
* clientBasedPositionUpdateInterval: 150,
|
|
6467
|
+
* defaultSearchPlatform: "ytmsearch",
|
|
6468
|
+
* allowCustomSources: false,
|
|
6469
|
+
* volumeDecrementer: 0.75,
|
|
6470
|
+
* //requesterTransformer: YourRequesterTransformerFunction,
|
|
6471
|
+
* onDisconnect: {
|
|
6472
|
+
* autoReconnect: true,
|
|
6473
|
+
* destroyPlayer: false
|
|
6415
6474
|
* },
|
|
6416
|
-
*
|
|
6417
|
-
*
|
|
6418
|
-
* //
|
|
6419
|
-
* //queueChangesWatcher: yourCustomQueueChangesWatcherClass
|
|
6475
|
+
* onEmptyQueue: {
|
|
6476
|
+
* destroyAfterMs: 30_000,
|
|
6477
|
+
* //autoPlayFunction: YourAutoplayFunction,
|
|
6420
6478
|
* },
|
|
6421
|
-
*
|
|
6422
|
-
*
|
|
6423
|
-
*
|
|
6424
|
-
*
|
|
6425
|
-
*
|
|
6426
|
-
*
|
|
6427
|
-
*
|
|
6428
|
-
*
|
|
6429
|
-
*
|
|
6430
|
-
*
|
|
6479
|
+
* useUnresolvedData: true
|
|
6480
|
+
* },
|
|
6481
|
+
* queueOptions: {
|
|
6482
|
+
* maxPreviousTracks: 25,
|
|
6483
|
+
* //queueStore: yourCustomQueueStoreManagerClass,
|
|
6484
|
+
* //queueChangesWatcher: yourCustomQueueChangesWatcherClass
|
|
6485
|
+
* },
|
|
6486
|
+
* linksBlacklist: [],
|
|
6487
|
+
* linksWhitelist: [],
|
|
6488
|
+
* advancedOptions: {
|
|
6489
|
+
* maxFilterFixDuration: 600_000,
|
|
6490
|
+
* debugOptions: {
|
|
6491
|
+
* noAudio: false,
|
|
6492
|
+
* playerDestroy: {
|
|
6493
|
+
* dontThrowError: false,
|
|
6494
|
+
* debugLogs: false
|
|
6431
6495
|
* }
|
|
6432
6496
|
* }
|
|
6433
|
-
*
|
|
6497
|
+
* }
|
|
6434
6498
|
* })
|
|
6435
6499
|
* ```
|
|
6436
6500
|
*/
|
|
@@ -6839,6 +6903,7 @@ var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEm
|
|
|
6839
6903
|
NodeLinkNode,
|
|
6840
6904
|
NodeManager,
|
|
6841
6905
|
NodeSymbol,
|
|
6906
|
+
NodeType,
|
|
6842
6907
|
Player,
|
|
6843
6908
|
Queue,
|
|
6844
6909
|
QueueSaver,
|