lavalink-client 2.5.8 → 2.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +28 -0
- package/dist/index.mjs +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ Check out the [Documentation](https://tomato6966.github.io/lavalink-client/)
|
|
|
70
70
|
- [Mintone (@appujet)](https://mintone.tech/)
|
|
71
71
|
- [Stelle (@EvilG-MC)](https://github.com/Ganyu-Studios/stelle-music)
|
|
72
72
|
- [Panais (@LucasB25)](https://panais.xyz/)
|
|
73
|
+
- [Akyn (@notdeltaxd)](https://akynbot.vercel.app/)
|
|
73
74
|
- **Community:**
|
|
74
75
|
- [Soundy (@idMJA)](https://github.com/idMJA/Soundy)
|
|
75
76
|
|
package/dist/index.d.mts
CHANGED
|
@@ -850,6 +850,14 @@ declare class Player {
|
|
|
850
850
|
* ```
|
|
851
851
|
*/
|
|
852
852
|
changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
|
|
853
|
+
/**
|
|
854
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
855
|
+
* @param node the id of the node to move to
|
|
856
|
+
* @returns the player
|
|
857
|
+
* @throws RangeError if there is no available nodes.
|
|
858
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
859
|
+
*/
|
|
860
|
+
moveNode(node?: string): Promise<string | this>;
|
|
853
861
|
/** Converts the Player including Queue to a Json state */
|
|
854
862
|
toJSON(): PlayerJson;
|
|
855
863
|
}
|
|
@@ -2759,6 +2767,8 @@ interface ManagerOptions {
|
|
|
2759
2767
|
playerOptions?: ManagerPlayerOptions;
|
|
2760
2768
|
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
2761
2769
|
autoSkip?: boolean;
|
|
2770
|
+
/** If it should automatically move the player to the next node when node is down */
|
|
2771
|
+
autoMove?: boolean;
|
|
2762
2772
|
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
2763
2773
|
autoSkipOnResolveError?: boolean;
|
|
2764
2774
|
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
package/dist/index.d.ts
CHANGED
|
@@ -850,6 +850,14 @@ declare class Player {
|
|
|
850
850
|
* ```
|
|
851
851
|
*/
|
|
852
852
|
changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
|
|
853
|
+
/**
|
|
854
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
855
|
+
* @param node the id of the node to move to
|
|
856
|
+
* @returns the player
|
|
857
|
+
* @throws RangeError if there is no available nodes.
|
|
858
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
859
|
+
*/
|
|
860
|
+
moveNode(node?: string): Promise<string | this>;
|
|
853
861
|
/** Converts the Player including Queue to a Json state */
|
|
854
862
|
toJSON(): PlayerJson;
|
|
855
863
|
}
|
|
@@ -2759,6 +2767,8 @@ interface ManagerOptions {
|
|
|
2759
2767
|
playerOptions?: ManagerPlayerOptions;
|
|
2760
2768
|
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
2761
2769
|
autoSkip?: boolean;
|
|
2770
|
+
/** If it should automatically move the player to the next node when node is down */
|
|
2771
|
+
autoMove?: boolean;
|
|
2762
2772
|
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
2763
2773
|
autoSkipOnResolveError?: boolean;
|
|
2764
2774
|
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
package/dist/index.js
CHANGED
|
@@ -1896,6 +1896,14 @@ var LavalinkNode = class {
|
|
|
1896
1896
|
this.reconnect();
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
|
+
this.NodeManager.LavalinkManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
|
|
1900
|
+
if (!this.NodeManager.LavalinkManager.options.autoMove) return p.playing = false;
|
|
1901
|
+
if (this.NodeManager.LavalinkManager.options.autoMove) {
|
|
1902
|
+
if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
|
|
1903
|
+
return p.playing = false;
|
|
1904
|
+
p.moveNode();
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1899
1907
|
}
|
|
1900
1908
|
/** @private util function for handling error events from websocket */
|
|
1901
1909
|
error(error) {
|
|
@@ -4344,6 +4352,26 @@ var Player = class {
|
|
|
4344
4352
|
this.set("internal_nodeChanging", void 0);
|
|
4345
4353
|
}
|
|
4346
4354
|
}
|
|
4355
|
+
/**
|
|
4356
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
4357
|
+
* @param node the id of the node to move to
|
|
4358
|
+
* @returns the player
|
|
4359
|
+
* @throws RangeError if there is no available nodes.
|
|
4360
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
4361
|
+
*/
|
|
4362
|
+
async moveNode(node) {
|
|
4363
|
+
try {
|
|
4364
|
+
if (!node) node = Array.from(this.LavalinkManager.nodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.node.options.id).id;
|
|
4365
|
+
if (!node || !this.LavalinkManager.nodeManager.nodes.get(node)) throw new RangeError("No nodes are available.");
|
|
4366
|
+
if (this.node.options.id === node) return this;
|
|
4367
|
+
this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, { state: "log", message: `Player.moveNode() was executed, trying to move from "${this.node.id}" to "${node}"`, functionLayer: "Player > moveNode()" });
|
|
4368
|
+
const updateNode = this.LavalinkManager.nodeManager.nodes.get(node);
|
|
4369
|
+
if (!updateNode) throw new RangeError("No nodes are available.");
|
|
4370
|
+
return await this.changeNode(updateNode);
|
|
4371
|
+
} catch (error) {
|
|
4372
|
+
throw new Error(`Failed to move the node: ${error}`);
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4347
4375
|
/** Converts the Player including Queue to a Json state */
|
|
4348
4376
|
toJSON() {
|
|
4349
4377
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -1836,6 +1836,14 @@ var LavalinkNode = class {
|
|
|
1836
1836
|
this.reconnect();
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
|
+
this.NodeManager.LavalinkManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
|
|
1840
|
+
if (!this.NodeManager.LavalinkManager.options.autoMove) return p.playing = false;
|
|
1841
|
+
if (this.NodeManager.LavalinkManager.options.autoMove) {
|
|
1842
|
+
if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
|
|
1843
|
+
return p.playing = false;
|
|
1844
|
+
p.moveNode();
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1839
1847
|
}
|
|
1840
1848
|
/** @private util function for handling error events from websocket */
|
|
1841
1849
|
error(error) {
|
|
@@ -4284,6 +4292,26 @@ var Player = class {
|
|
|
4284
4292
|
this.set("internal_nodeChanging", void 0);
|
|
4285
4293
|
}
|
|
4286
4294
|
}
|
|
4295
|
+
/**
|
|
4296
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
4297
|
+
* @param node the id of the node to move to
|
|
4298
|
+
* @returns the player
|
|
4299
|
+
* @throws RangeError if there is no available nodes.
|
|
4300
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
4301
|
+
*/
|
|
4302
|
+
async moveNode(node) {
|
|
4303
|
+
try {
|
|
4304
|
+
if (!node) node = Array.from(this.LavalinkManager.nodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.node.options.id).id;
|
|
4305
|
+
if (!node || !this.LavalinkManager.nodeManager.nodes.get(node)) throw new RangeError("No nodes are available.");
|
|
4306
|
+
if (this.node.options.id === node) return this;
|
|
4307
|
+
this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, { state: "log", message: `Player.moveNode() was executed, trying to move from "${this.node.id}" to "${node}"`, functionLayer: "Player > moveNode()" });
|
|
4308
|
+
const updateNode = this.LavalinkManager.nodeManager.nodes.get(node);
|
|
4309
|
+
if (!updateNode) throw new RangeError("No nodes are available.");
|
|
4310
|
+
return await this.changeNode(updateNode);
|
|
4311
|
+
} catch (error) {
|
|
4312
|
+
throw new Error(`Failed to move the node: ${error}`);
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4287
4315
|
/** Converts the Player including Queue to a Json state */
|
|
4288
4316
|
toJSON() {
|
|
4289
4317
|
return {
|
package/package.json
CHANGED