lavalink-client 2.9.11 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/dist/index.cjs +109 -67
- package/dist/index.d.cts +53 -48
- package/dist/index.d.ts +53 -48
- package/dist/index.js +108 -67
- package/dist/index.mjs +108 -67
- 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) => {
|
|
@@ -392,6 +402,8 @@ client.lavalink = new LavalinkManager({
|
|
|
392
402
|
port: 2333,
|
|
393
403
|
id: "Main Node",
|
|
394
404
|
},
|
|
405
|
+
// you can also use the util like this, and it will return a valid node option object.
|
|
406
|
+
// parseLavalinkConnUrl("nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
395
407
|
],
|
|
396
408
|
// A function to send voice server updates to the Lavalink client
|
|
397
409
|
sendToShard: (guildId, payload) => {
|
|
@@ -448,6 +460,8 @@ client.lavalink = new LavalinkManager({
|
|
|
448
460
|
retryAmount: 5,
|
|
449
461
|
retryDelay: 10_000, // 10 seconds
|
|
450
462
|
},
|
|
463
|
+
// you can also use the util like this, and it will return a valid node option object. must start with: lavalink:// | nodelink://
|
|
464
|
+
// parseLavalinkConnUrl("lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
451
465
|
],
|
|
452
466
|
sendToShard: (guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
|
|
453
467
|
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)
|
|
@@ -2344,20 +2350,22 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
2344
2350
|
throw new SyntaxError("LavalinkNode.autoChecks.pluginValidations must be either false | true aka boolean");
|
|
2345
2351
|
if (this.options.regions !== void 0 && (!Array.isArray(this.options.regions) || !this.options.regions.every((r) => typeof r === "string")))
|
|
2346
2352
|
throw new SyntaxError("LavalinkNode.regions must be an Array of strings");
|
|
2353
|
+
if (this.options.nodeType && !NodeType[this.options.nodeType])
|
|
2354
|
+
throw new SyntaxError("LavalinkNode.nodeType must be a valid NodeType enum value");
|
|
2347
2355
|
}
|
|
2348
2356
|
/**
|
|
2349
2357
|
* Checks if the node is a NodeLink node
|
|
2350
2358
|
* @returns true if the node is a NodeLink node
|
|
2351
2359
|
*/
|
|
2352
2360
|
isNodeLink() {
|
|
2353
|
-
return this.nodeType === "NodeLink"
|
|
2361
|
+
return this.nodeType === "NodeLink" /* NodeLink */;
|
|
2354
2362
|
}
|
|
2355
2363
|
/**
|
|
2356
2364
|
* Checks if the node is a Lavalink node
|
|
2357
2365
|
* @returns true if the node is a Lavalink node
|
|
2358
2366
|
*/
|
|
2359
2367
|
isLavalinkNode() {
|
|
2360
|
-
return this.nodeType === "Lavalink"
|
|
2368
|
+
return this.nodeType === "Lavalink" /* Lavalink */;
|
|
2361
2369
|
}
|
|
2362
2370
|
/**
|
|
2363
2371
|
* Sync the data of the player you make an action to lavalink to
|
|
@@ -3130,13 +3138,13 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
3130
3138
|
|
|
3131
3139
|
// src/structures/NodeLink.ts
|
|
3132
3140
|
var NodeLinkNode = class extends LavalinkNode {
|
|
3133
|
-
nodeType = "NodeLink"
|
|
3141
|
+
nodeType = "NodeLink" /* NodeLink */;
|
|
3134
3142
|
constructor(options, manager) {
|
|
3135
3143
|
super(options, manager);
|
|
3136
|
-
if (this.options.nodeType === "Lavalink" && this.constructor.name === "NodeLink") {
|
|
3144
|
+
if (this.options.nodeType === "Lavalink" /* Lavalink */ && (this.constructor.name === "NodeLinkNode" || this.constructor.name === "NodeLink")) {
|
|
3137
3145
|
return new LavalinkNode(options, manager);
|
|
3138
3146
|
}
|
|
3139
|
-
this.nodeType = "NodeLink"
|
|
3147
|
+
this.nodeType = "NodeLink" /* NodeLink */;
|
|
3140
3148
|
}
|
|
3141
3149
|
/**
|
|
3142
3150
|
* Uses the gapless feature to set the next track to be played.
|
|
@@ -3477,6 +3485,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3477
3485
|
LavalinkNode._NodeLinkClass = NodeLinkNode;
|
|
3478
3486
|
|
|
3479
3487
|
// src/structures/NodeManager.ts
|
|
3488
|
+
var import_node_events = require("events");
|
|
3480
3489
|
var NodeManager = class extends import_node_events.EventEmitter {
|
|
3481
3490
|
/**
|
|
3482
3491
|
* Emit an event
|
|
@@ -3538,9 +3547,7 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3538
3547
|
super();
|
|
3539
3548
|
this.LavalinkManager = LavalinkManager2;
|
|
3540
3549
|
if (this.LavalinkManager.options.nodes)
|
|
3541
|
-
this.LavalinkManager.options.nodes.forEach((node) =>
|
|
3542
|
-
this.createNode(node);
|
|
3543
|
-
});
|
|
3550
|
+
this.LavalinkManager.options.nodes.forEach((node) => this.createNode(node));
|
|
3544
3551
|
}
|
|
3545
3552
|
/**
|
|
3546
3553
|
* Disconnects all Nodes from lavalink ws sockets
|
|
@@ -3601,9 +3608,21 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3601
3608
|
* @returns The node that was created
|
|
3602
3609
|
*/
|
|
3603
3610
|
createNode(options) {
|
|
3611
|
+
if (options instanceof NodeLinkNode) {
|
|
3612
|
+
const preExistingNode = this.nodes.get(options.id);
|
|
3613
|
+
if (preExistingNode) return preExistingNode;
|
|
3614
|
+
this.nodes.set(options.id, options);
|
|
3615
|
+
return options;
|
|
3616
|
+
}
|
|
3617
|
+
if (options instanceof LavalinkNode) {
|
|
3618
|
+
const preExistingNode = this.nodes.get(options.id);
|
|
3619
|
+
if (preExistingNode) return preExistingNode;
|
|
3620
|
+
this.nodes.set(options.id, options);
|
|
3621
|
+
return options;
|
|
3622
|
+
}
|
|
3604
3623
|
if (this.nodes.has(options.id || `${options.host}:${options.port}`))
|
|
3605
3624
|
return this.nodes.get(options.id || `${options.host}:${options.port}`);
|
|
3606
|
-
const newNode = options.nodeType === "NodeLink" ? new NodeLinkNode(options, this) : new LavalinkNode(options, this);
|
|
3625
|
+
const newNode = options.nodeType === "NodeLink" /* NodeLink */ ? new NodeLinkNode(options, this) : new LavalinkNode(options, this);
|
|
3607
3626
|
this.nodes.set(newNode.id, newNode);
|
|
3608
3627
|
return newNode;
|
|
3609
3628
|
}
|
|
@@ -3612,48 +3631,57 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3612
3631
|
* @param sortType The type of sorting to use
|
|
3613
3632
|
* @returns
|
|
3614
3633
|
*/
|
|
3615
|
-
leastUsedNodes(sortType = "players") {
|
|
3634
|
+
leastUsedNodes(sortType = "players", filterForNodeTypes) {
|
|
3635
|
+
const normalizedFilterForNodeTypes = filterForNodeTypes?.length ? filterForNodeTypes : ["Lavalink" /* Lavalink */, "NodeLink" /* NodeLink */];
|
|
3616
3636
|
const connectedNodes = Array.from(this.nodes.values()).filter((node) => node.connected);
|
|
3637
|
+
const normalizedNodeTypes = new Set(
|
|
3638
|
+
normalizedFilterForNodeTypes.map(
|
|
3639
|
+
(nodeTypeFilter) => Object.values(NodeType).includes(nodeTypeFilter) ? nodeTypeFilter : nodeTypeFilter.nodeType
|
|
3640
|
+
)
|
|
3641
|
+
);
|
|
3642
|
+
const filteredConnectedNodes = connectedNodes.filter((node) => normalizedNodeTypes.has(node.nodeType));
|
|
3617
3643
|
switch (sortType) {
|
|
3618
3644
|
case "memory":
|
|
3619
3645
|
{
|
|
3620
|
-
return
|
|
3646
|
+
return filteredConnectedNodes.sort(
|
|
3647
|
+
(a, b) => (a.stats?.memory?.used || 0) - (b.stats?.memory?.used || 0)
|
|
3648
|
+
);
|
|
3621
3649
|
}
|
|
3622
3650
|
break;
|
|
3623
3651
|
case "cpuLavalink":
|
|
3624
3652
|
{
|
|
3625
|
-
return
|
|
3653
|
+
return filteredConnectedNodes.sort(
|
|
3626
3654
|
(a, b) => (a.stats?.cpu?.lavalinkLoad || 0) - (b.stats?.cpu?.lavalinkLoad || 0)
|
|
3627
3655
|
);
|
|
3628
3656
|
}
|
|
3629
3657
|
break;
|
|
3630
3658
|
case "cpuSystem":
|
|
3631
3659
|
{
|
|
3632
|
-
return
|
|
3660
|
+
return filteredConnectedNodes.sort(
|
|
3633
3661
|
(a, b) => (a.stats?.cpu?.systemLoad || 0) - (b.stats?.cpu?.systemLoad || 0)
|
|
3634
3662
|
);
|
|
3635
3663
|
}
|
|
3636
3664
|
break;
|
|
3637
3665
|
case "calls":
|
|
3638
3666
|
{
|
|
3639
|
-
return
|
|
3667
|
+
return filteredConnectedNodes.sort((a, b) => a.calls - b.calls);
|
|
3640
3668
|
}
|
|
3641
3669
|
break;
|
|
3642
3670
|
case "playingPlayers":
|
|
3643
3671
|
{
|
|
3644
|
-
return
|
|
3672
|
+
return filteredConnectedNodes.sort(
|
|
3645
3673
|
(a, b) => (a.stats?.playingPlayers || 0) - (b.stats?.playingPlayers || 0)
|
|
3646
3674
|
);
|
|
3647
3675
|
}
|
|
3648
3676
|
break;
|
|
3649
3677
|
case "players":
|
|
3650
3678
|
{
|
|
3651
|
-
return
|
|
3679
|
+
return filteredConnectedNodes.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
3652
3680
|
}
|
|
3653
3681
|
break;
|
|
3654
3682
|
default:
|
|
3655
3683
|
{
|
|
3656
|
-
return
|
|
3684
|
+
return filteredConnectedNodes.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
3657
3685
|
}
|
|
3658
3686
|
break;
|
|
3659
3687
|
}
|
|
@@ -3686,13 +3714,22 @@ var NodeManager = class extends import_node_events.EventEmitter {
|
|
|
3686
3714
|
}
|
|
3687
3715
|
/**
|
|
3688
3716
|
* Get a node from the nodeManager
|
|
3689
|
-
* @param node The node to get
|
|
3717
|
+
* @param node The node to get either by idetnifier, by class or by enum
|
|
3690
3718
|
* @returns The node that was retrieved
|
|
3691
3719
|
*/
|
|
3692
3720
|
getNode(node) {
|
|
3721
|
+
if (!!node && Object.values(NodeType).includes(node)) {
|
|
3722
|
+
return this.leastUsedNodes().filter((node2) => node2.nodeType === node2)[0];
|
|
3723
|
+
}
|
|
3724
|
+
if (!!node && node instanceof NodeLinkNode) {
|
|
3725
|
+
return this.leastUsedNodes().filter((node2) => node2 instanceof NodeLinkNode)[0];
|
|
3726
|
+
}
|
|
3727
|
+
if (!!node && node instanceof LavalinkNode) {
|
|
3728
|
+
return this.leastUsedNodes().filter((node2) => node2 instanceof LavalinkNode)[0];
|
|
3729
|
+
}
|
|
3693
3730
|
const decodeNode = typeof node === "string" ? this.nodes.get(node) : node;
|
|
3694
3731
|
if (!decodeNode) return void 0;
|
|
3695
|
-
if (decodeNode.nodeType === "NodeLink") return decodeNode;
|
|
3732
|
+
if (decodeNode.nodeType === "NodeLink" /* NodeLink */) return decodeNode;
|
|
3696
3733
|
return decodeNode;
|
|
3697
3734
|
}
|
|
3698
3735
|
};
|
|
@@ -6331,9 +6368,11 @@ var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEm
|
|
|
6331
6368
|
throw new SyntaxError("ManagerOption.autoSkipOnResolveError must be either false | true aka boolean");
|
|
6332
6369
|
if (options?.emitNewSongsOnly && typeof options?.emitNewSongsOnly !== "boolean")
|
|
6333
6370
|
throw new SyntaxError("ManagerOption.emitNewSongsOnly must be either false | true aka boolean");
|
|
6334
|
-
if (!options?.nodes || !Array.isArray(options?.nodes) || !options?.nodes.every(
|
|
6371
|
+
if (!options?.nodes || !Array.isArray(options?.nodes) || !options?.nodes.every(
|
|
6372
|
+
(node) => node instanceof NodeLinkNode || node instanceof LavalinkNode || this.utils.isNodeOptions(node)
|
|
6373
|
+
))
|
|
6335
6374
|
throw new SyntaxError(
|
|
6336
|
-
"ManagerOption.nodes must be an Array of NodeOptions and is required of at least 1 Node"
|
|
6375
|
+
"ManagerOption.nodes must be an Array of NodeOptions or the Node-Classes 'NodeLinkNode' or 'LavalinkNode' and is required of at least 1 Node"
|
|
6337
6376
|
);
|
|
6338
6377
|
if (options?.queueOptions?.queueStore) {
|
|
6339
6378
|
const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(options?.queueOptions?.queueStore));
|
|
@@ -6389,48 +6428,50 @@ var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEm
|
|
|
6389
6428
|
* port: 2333,
|
|
6390
6429
|
* id: "testnode"
|
|
6391
6430
|
* },
|
|
6431
|
+
* // you can also use the util like this, and it will return a valid node option object. must start with: lavalink:// | nodelink://
|
|
6432
|
+
* // parseLavalinkConnUrl("nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
6392
6433
|
* 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
|
|
6434
|
+
* ],
|
|
6435
|
+
* client: {
|
|
6436
|
+
* id: process.env.CLIENT_ID,
|
|
6437
|
+
* username: "TESTBOT"
|
|
6438
|
+
* },
|
|
6439
|
+
* // optional Options:
|
|
6440
|
+
* autoSkip: true,
|
|
6441
|
+
* playerOptions: {
|
|
6442
|
+
* applyVolumeAsFilter: false,
|
|
6443
|
+
* clientBasedPositionUpdateInterval: 150,
|
|
6444
|
+
* defaultSearchPlatform: "ytmsearch",
|
|
6445
|
+
* allowCustomSources: false,
|
|
6446
|
+
* volumeDecrementer: 0.75,
|
|
6447
|
+
* //requesterTransformer: YourRequesterTransformerFunction,
|
|
6448
|
+
* onDisconnect: {
|
|
6449
|
+
* autoReconnect: true,
|
|
6450
|
+
* destroyPlayer: false
|
|
6415
6451
|
* },
|
|
6416
|
-
*
|
|
6417
|
-
*
|
|
6418
|
-
* //
|
|
6419
|
-
* //queueChangesWatcher: yourCustomQueueChangesWatcherClass
|
|
6452
|
+
* onEmptyQueue: {
|
|
6453
|
+
* destroyAfterMs: 30_000,
|
|
6454
|
+
* //autoPlayFunction: YourAutoplayFunction,
|
|
6420
6455
|
* },
|
|
6421
|
-
*
|
|
6422
|
-
*
|
|
6423
|
-
*
|
|
6424
|
-
*
|
|
6425
|
-
*
|
|
6426
|
-
*
|
|
6427
|
-
*
|
|
6428
|
-
*
|
|
6429
|
-
*
|
|
6430
|
-
*
|
|
6456
|
+
* useUnresolvedData: true
|
|
6457
|
+
* },
|
|
6458
|
+
* queueOptions: {
|
|
6459
|
+
* maxPreviousTracks: 25,
|
|
6460
|
+
* //queueStore: yourCustomQueueStoreManagerClass,
|
|
6461
|
+
* //queueChangesWatcher: yourCustomQueueChangesWatcherClass
|
|
6462
|
+
* },
|
|
6463
|
+
* linksBlacklist: [],
|
|
6464
|
+
* linksWhitelist: [],
|
|
6465
|
+
* advancedOptions: {
|
|
6466
|
+
* maxFilterFixDuration: 600_000,
|
|
6467
|
+
* debugOptions: {
|
|
6468
|
+
* noAudio: false,
|
|
6469
|
+
* playerDestroy: {
|
|
6470
|
+
* dontThrowError: false,
|
|
6471
|
+
* debugLogs: false
|
|
6431
6472
|
* }
|
|
6432
6473
|
* }
|
|
6433
|
-
*
|
|
6474
|
+
* }
|
|
6434
6475
|
* })
|
|
6435
6476
|
* ```
|
|
6436
6477
|
*/
|
|
@@ -6839,6 +6880,7 @@ var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEm
|
|
|
6839
6880
|
NodeLinkNode,
|
|
6840
6881
|
NodeManager,
|
|
6841
6882
|
NodeSymbol,
|
|
6883
|
+
NodeType,
|
|
6842
6884
|
Player,
|
|
6843
6885
|
Queue,
|
|
6844
6886
|
QueueSaver,
|
package/dist/index.d.cts
CHANGED
|
@@ -410,7 +410,7 @@ declare const NodeSymbol: unique symbol;
|
|
|
410
410
|
*/
|
|
411
411
|
declare function parseLavalinkConnUrl(connectionUrl: string): {
|
|
412
412
|
authorization: string;
|
|
413
|
-
nodeType:
|
|
413
|
+
nodeType: NodeType;
|
|
414
414
|
id: string;
|
|
415
415
|
host: string;
|
|
416
416
|
port: number;
|
|
@@ -1537,7 +1537,7 @@ type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "
|
|
|
1537
1537
|
*/
|
|
1538
1538
|
interface LavalinkNodeOptions {
|
|
1539
1539
|
/** Specify the Node-Type of this node. Default: Lavalink */
|
|
1540
|
-
nodeType?:
|
|
1540
|
+
nodeType?: NodeType;
|
|
1541
1541
|
/** The Lavalink Server-Ip / Domain-URL */
|
|
1542
1542
|
host: string;
|
|
1543
1543
|
/** The Lavalink Connection Port */
|
|
@@ -1832,7 +1832,10 @@ declare enum ReconnectionState {
|
|
|
1832
1832
|
PENDING = "PENDING",
|
|
1833
1833
|
DESTROYING = "DESTROYING"
|
|
1834
1834
|
}
|
|
1835
|
-
|
|
1835
|
+
declare enum NodeType {
|
|
1836
|
+
Lavalink = "Lavalink",
|
|
1837
|
+
NodeLink = "NodeLink"
|
|
1838
|
+
}
|
|
1836
1839
|
|
|
1837
1840
|
declare class FilterManager {
|
|
1838
1841
|
static EQList: {
|
|
@@ -2891,7 +2894,7 @@ declare class Player {
|
|
|
2891
2894
|
}
|
|
2892
2895
|
|
|
2893
2896
|
declare class NodeLinkNode extends LavalinkNode {
|
|
2894
|
-
nodeType:
|
|
2897
|
+
nodeType: NodeType;
|
|
2895
2898
|
constructor(options: LavalinkNodeOptions, manager: NodeManager);
|
|
2896
2899
|
/**
|
|
2897
2900
|
* Uses the gapless feature to set the next track to be played.
|
|
@@ -3064,7 +3067,7 @@ declare class LavalinkNode {
|
|
|
3064
3067
|
private heartBeatPongTimestamp;
|
|
3065
3068
|
private heartBeatInterval?;
|
|
3066
3069
|
private pingTimeout?;
|
|
3067
|
-
nodeType:
|
|
3070
|
+
nodeType: NodeType;
|
|
3068
3071
|
isAlive: boolean;
|
|
3069
3072
|
static _NodeLinkClass: unknown;
|
|
3070
3073
|
/** The provided Options of the Node */
|
|
@@ -3749,13 +3752,13 @@ declare class NodeManager extends EventEmitter {
|
|
|
3749
3752
|
* @param options The options for the node
|
|
3750
3753
|
* @returns The node that was created
|
|
3751
3754
|
*/
|
|
3752
|
-
createNode<T extends LavalinkNode | NodeLinkNode>(options: LavalinkNodeOptions): T;
|
|
3755
|
+
createNode<T extends LavalinkNode | NodeLinkNode>(options: LavalinkNodeOptions | NodeLinkNode | LavalinkNode): T;
|
|
3753
3756
|
/**
|
|
3754
3757
|
* Get the nodes sorted for the least usage, by a sorttype
|
|
3755
3758
|
* @param sortType The type of sorting to use
|
|
3756
3759
|
* @returns
|
|
3757
3760
|
*/
|
|
3758
|
-
leastUsedNodes(sortType?: "memory" | "cpuLavalink" | "cpuSystem" | "calls" | "playingPlayers" | "players"): LavalinkNode[];
|
|
3761
|
+
leastUsedNodes(sortType?: "memory" | "cpuLavalink" | "cpuSystem" | "calls" | "playingPlayers" | "players", filterForNodeTypes?: (NodeType | NodeLinkNode | LavalinkNode)[]): LavalinkNode[];
|
|
3759
3762
|
/**
|
|
3760
3763
|
* Delete a node from the nodeManager and destroy it
|
|
3761
3764
|
* @param node The node to delete
|
|
@@ -3775,10 +3778,10 @@ declare class NodeManager extends EventEmitter {
|
|
|
3775
3778
|
deleteNode(node: LavalinkNodeIdentifier | LavalinkNode | NodeLinkNode, movePlayers?: boolean): void;
|
|
3776
3779
|
/**
|
|
3777
3780
|
* Get a node from the nodeManager
|
|
3778
|
-
* @param node The node to get
|
|
3781
|
+
* @param node The node to get either by idetnifier, by class or by enum
|
|
3779
3782
|
* @returns The node that was retrieved
|
|
3780
3783
|
*/
|
|
3781
|
-
getNode(node: LavalinkNodeIdentifier | LavalinkNode | NodeLinkNode): LavalinkNode | NodeLinkNode | undefined;
|
|
3784
|
+
getNode(node: LavalinkNodeIdentifier | LavalinkNode | NodeLinkNode | NodeType): LavalinkNode | NodeLinkNode | undefined;
|
|
3782
3785
|
}
|
|
3783
3786
|
|
|
3784
3787
|
/**
|
|
@@ -4038,7 +4041,7 @@ type PlayerConstructor<T extends Player = Player> = new (options: PlayerOptions,
|
|
|
4038
4041
|
/** Manager Options used to create the manager */
|
|
4039
4042
|
interface ManagerOptions<CustomPlayerT extends Player = Player> {
|
|
4040
4043
|
/** The Node Options, for all Nodes! (on init) */
|
|
4041
|
-
nodes: LavalinkNodeOptions[];
|
|
4044
|
+
nodes: (LavalinkNodeOptions | NodeLinkNode | LavalinkNode)[];
|
|
4042
4045
|
/** @async The Function to send the voice connection changes from Lavalink to Discord */
|
|
4043
4046
|
sendToShard: (guildId: string, payload: GuildShardPayload) => void;
|
|
4044
4047
|
/** The Bot Client's Data for Authorization */
|
|
@@ -4169,48 +4172,50 @@ declare class LavalinkManager<CustomPlayerT extends Player = Player> extends Eve
|
|
|
4169
4172
|
* port: 2333,
|
|
4170
4173
|
* id: "testnode"
|
|
4171
4174
|
* },
|
|
4175
|
+
* // you can also use the util like this, and it will return a valid node option object. must start with: lavalink:// | nodelink://
|
|
4176
|
+
* // parseLavalinkConnUrl("nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>")
|
|
4172
4177
|
* sendToShard(guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
|
|
4173
|
-
*
|
|
4174
|
-
*
|
|
4175
|
-
*
|
|
4176
|
-
*
|
|
4177
|
-
*
|
|
4178
|
-
*
|
|
4179
|
-
*
|
|
4180
|
-
*
|
|
4181
|
-
*
|
|
4182
|
-
*
|
|
4183
|
-
*
|
|
4184
|
-
*
|
|
4185
|
-
*
|
|
4186
|
-
*
|
|
4187
|
-
*
|
|
4188
|
-
*
|
|
4189
|
-
*
|
|
4190
|
-
* onEmptyQueue: {
|
|
4191
|
-
* destroyAfterMs: 30_000,
|
|
4192
|
-
* //autoPlayFunction: YourAutoplayFunction,
|
|
4193
|
-
* },
|
|
4194
|
-
* useUnresolvedData: true
|
|
4178
|
+
* ],
|
|
4179
|
+
* client: {
|
|
4180
|
+
* id: process.env.CLIENT_ID,
|
|
4181
|
+
* username: "TESTBOT"
|
|
4182
|
+
* },
|
|
4183
|
+
* // optional Options:
|
|
4184
|
+
* autoSkip: true,
|
|
4185
|
+
* playerOptions: {
|
|
4186
|
+
* applyVolumeAsFilter: false,
|
|
4187
|
+
* clientBasedPositionUpdateInterval: 150,
|
|
4188
|
+
* defaultSearchPlatform: "ytmsearch",
|
|
4189
|
+
* allowCustomSources: false,
|
|
4190
|
+
* volumeDecrementer: 0.75,
|
|
4191
|
+
* //requesterTransformer: YourRequesterTransformerFunction,
|
|
4192
|
+
* onDisconnect: {
|
|
4193
|
+
* autoReconnect: true,
|
|
4194
|
+
* destroyPlayer: false
|
|
4195
4195
|
* },
|
|
4196
|
-
*
|
|
4197
|
-
*
|
|
4198
|
-
* //
|
|
4199
|
-
* //queueChangesWatcher: yourCustomQueueChangesWatcherClass
|
|
4196
|
+
* onEmptyQueue: {
|
|
4197
|
+
* destroyAfterMs: 30_000,
|
|
4198
|
+
* //autoPlayFunction: YourAutoplayFunction,
|
|
4200
4199
|
* },
|
|
4201
|
-
*
|
|
4202
|
-
*
|
|
4203
|
-
*
|
|
4204
|
-
*
|
|
4205
|
-
*
|
|
4206
|
-
*
|
|
4207
|
-
*
|
|
4208
|
-
*
|
|
4209
|
-
*
|
|
4210
|
-
*
|
|
4200
|
+
* useUnresolvedData: true
|
|
4201
|
+
* },
|
|
4202
|
+
* queueOptions: {
|
|
4203
|
+
* maxPreviousTracks: 25,
|
|
4204
|
+
* //queueStore: yourCustomQueueStoreManagerClass,
|
|
4205
|
+
* //queueChangesWatcher: yourCustomQueueChangesWatcherClass
|
|
4206
|
+
* },
|
|
4207
|
+
* linksBlacklist: [],
|
|
4208
|
+
* linksWhitelist: [],
|
|
4209
|
+
* advancedOptions: {
|
|
4210
|
+
* maxFilterFixDuration: 600_000,
|
|
4211
|
+
* debugOptions: {
|
|
4212
|
+
* noAudio: false,
|
|
4213
|
+
* playerDestroy: {
|
|
4214
|
+
* dontThrowError: false,
|
|
4215
|
+
* debugLogs: false
|
|
4211
4216
|
* }
|
|
4212
4217
|
* }
|
|
4213
|
-
*
|
|
4218
|
+
* }
|
|
4214
4219
|
* })
|
|
4215
4220
|
* ```
|
|
4216
4221
|
*/
|
|
@@ -4339,4 +4344,4 @@ declare const LavalinkPlugins: {
|
|
|
4339
4344
|
/** Lavalink Sources regexes for url validations */
|
|
4340
4345
|
declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
|
|
4341
4346
|
|
|
4342
|
-
export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, type NodeLinkConnectionMetrics, NodeLinkExclusiveEvents, NodeLinkNode, type NodeLink_ChorusFilter, type NodeLink_CompressorFilter, type NodeLink_EchoFilter, type NodeLink_HighPassFilter, type NodeLink_PhaserFilter, type NodeLink_SpatialFilter, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol,
|
|
4347
|
+
export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, type NodeLinkConnectionMetrics, NodeLinkExclusiveEvents, NodeLinkNode, type NodeLink_ChorusFilter, type NodeLink_CompressorFilter, type NodeLink_EchoFilter, type NodeLink_HighPassFilter, type NodeLink_PhaserFilter, type NodeLink_SpatialFilter, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, NodeType, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, RecommendationsStrings, ReconnectionState, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackRequester, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };
|