lavalink-client 2.7.2 → 2.7.4
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.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +35 -11
- package/dist/index.mjs +35 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -41,7 +41,8 @@ declare class FilterManager {
|
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
43
|
applyPlayerFilters(): Promise<void>;
|
|
44
|
-
privateNot0
|
|
44
|
+
private privateNot0;
|
|
45
|
+
private getLavalinkFilterData;
|
|
45
46
|
/**
|
|
46
47
|
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
47
48
|
* @param oldFilterTimescale
|
|
@@ -982,11 +983,15 @@ declare class Player {
|
|
|
982
983
|
*/
|
|
983
984
|
changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
|
|
984
985
|
/**
|
|
985
|
-
* 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.
|
|
986
|
+
* (Wrapper-FN for changeNode) 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.
|
|
986
987
|
* @param node the id of the node to move to
|
|
987
988
|
* @returns the player
|
|
988
989
|
* @throws RangeError if there is no available nodes.
|
|
989
990
|
* @throws Error if the node to move to is the same as the current node.
|
|
991
|
+
* @example
|
|
992
|
+
* ```ts
|
|
993
|
+
* const newNodeMovedTo = await player.moveNode(); // no need to specify the new node, it will find a least used node automatically, but you can ofc. use a custom node id.
|
|
994
|
+
* ```
|
|
990
995
|
*/
|
|
991
996
|
moveNode(node?: string): Promise<string | this>;
|
|
992
997
|
/** Converts the Player including Queue to a Json state */
|
|
@@ -2360,7 +2365,7 @@ declare class LavalinkNode {
|
|
|
2360
2365
|
*
|
|
2361
2366
|
* @example
|
|
2362
2367
|
* ```ts
|
|
2363
|
-
* player.node.
|
|
2368
|
+
* player.node.disconnect("Forcefully disconnect the connection to the node.");
|
|
2364
2369
|
* ```
|
|
2365
2370
|
*/
|
|
2366
2371
|
disconnect(disconnectReason?: DisconnectReasonsType): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -41,7 +41,8 @@ declare class FilterManager {
|
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
43
|
applyPlayerFilters(): Promise<void>;
|
|
44
|
-
privateNot0
|
|
44
|
+
private privateNot0;
|
|
45
|
+
private getLavalinkFilterData;
|
|
45
46
|
/**
|
|
46
47
|
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
47
48
|
* @param oldFilterTimescale
|
|
@@ -982,11 +983,15 @@ declare class Player {
|
|
|
982
983
|
*/
|
|
983
984
|
changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
|
|
984
985
|
/**
|
|
985
|
-
* 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.
|
|
986
|
+
* (Wrapper-FN for changeNode) 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.
|
|
986
987
|
* @param node the id of the node to move to
|
|
987
988
|
* @returns the player
|
|
988
989
|
* @throws RangeError if there is no available nodes.
|
|
989
990
|
* @throws Error if the node to move to is the same as the current node.
|
|
991
|
+
* @example
|
|
992
|
+
* ```ts
|
|
993
|
+
* const newNodeMovedTo = await player.moveNode(); // no need to specify the new node, it will find a least used node automatically, but you can ofc. use a custom node id.
|
|
994
|
+
* ```
|
|
990
995
|
*/
|
|
991
996
|
moveNode(node?: string): Promise<string | this>;
|
|
992
997
|
/** Converts the Player including Queue to a Json state */
|
|
@@ -2360,7 +2365,7 @@ declare class LavalinkNode {
|
|
|
2360
2365
|
*
|
|
2361
2366
|
* @example
|
|
2362
2367
|
* ```ts
|
|
2363
|
-
* player.node.
|
|
2368
|
+
* player.node.disconnect("Forcefully disconnect the connection to the node.");
|
|
2364
2369
|
* ```
|
|
2365
2370
|
*/
|
|
2366
2371
|
disconnect(disconnectReason?: DisconnectReasonsType): void;
|
package/dist/index.js
CHANGED
|
@@ -1422,6 +1422,7 @@ var LavalinkNode = class {
|
|
|
1422
1422
|
* ```
|
|
1423
1423
|
*/
|
|
1424
1424
|
destroy(destroyReason, deleteNode = true, movePlayers = false) {
|
|
1425
|
+
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1425
1426
|
const players = this.NodeManager.LavalinkManager.players.filter((p) => p.node.id === this.id);
|
|
1426
1427
|
if (players.size) {
|
|
1427
1428
|
const enableDebugEvents = this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents;
|
|
@@ -1497,7 +1498,7 @@ var LavalinkNode = class {
|
|
|
1497
1498
|
*
|
|
1498
1499
|
* @example
|
|
1499
1500
|
* ```ts
|
|
1500
|
-
* player.node.
|
|
1501
|
+
* player.node.disconnect("Forcefully disconnect the connection to the node.");
|
|
1501
1502
|
* ```
|
|
1502
1503
|
*/
|
|
1503
1504
|
disconnect(disconnectReason) {
|
|
@@ -1505,6 +1506,7 @@ var LavalinkNode = class {
|
|
|
1505
1506
|
this.socket?.close(1e3, "Node-Disconnect");
|
|
1506
1507
|
this.socket?.removeAllListeners();
|
|
1507
1508
|
this.socket = null;
|
|
1509
|
+
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1508
1510
|
this.resetReconnectionAttempts();
|
|
1509
1511
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: disconnectReason });
|
|
1510
1512
|
}
|
|
@@ -1969,10 +1971,10 @@ var LavalinkNode = class {
|
|
|
1969
1971
|
});
|
|
1970
1972
|
this.heartBeatInterval = setInterval(() => {
|
|
1971
1973
|
if (!this.socket) return console.error("Node-Heartbeat-Interval - Socket not available - maybe reconnecting?");
|
|
1972
|
-
if (!this.isAlive) this.close(500, "Node-Heartbeat-Timeout");
|
|
1974
|
+
if (!this.isAlive) return this.close(500, "Node-Heartbeat-Timeout");
|
|
1973
1975
|
this.isAlive = false;
|
|
1974
1976
|
this.heartBeatPingTimestamp = performance.now();
|
|
1975
|
-
this.socket
|
|
1977
|
+
this.socket?.ping?.();
|
|
1976
1978
|
}, this.options.heartBeatInterval || 3e4);
|
|
1977
1979
|
}
|
|
1978
1980
|
this.info = await this.fetchInfo().catch((e) => (console.error(e, "ON-OPEN-FETCH"), null));
|
|
@@ -2021,6 +2023,7 @@ var LavalinkNode = class {
|
|
|
2021
2023
|
error(error) {
|
|
2022
2024
|
if (!error) return;
|
|
2023
2025
|
this.NodeManager.emit("error", this, error);
|
|
2026
|
+
this.reconnectionState = "IDLE" /* IDLE */;
|
|
2024
2027
|
this.reconnect();
|
|
2025
2028
|
if (this.options.closeOnError) {
|
|
2026
2029
|
if (this.heartBeatInterval) clearInterval(this.heartBeatInterval);
|
|
@@ -2961,6 +2964,19 @@ var FilterManager = class {
|
|
|
2961
2964
|
privateNot0(value) {
|
|
2962
2965
|
return typeof value === "number" && value !== 0;
|
|
2963
2966
|
}
|
|
2967
|
+
getLavalinkFilterData() {
|
|
2968
|
+
return this.data.pluginFilters?.["lavalink-filter-plugin"] || {
|
|
2969
|
+
echo: {
|
|
2970
|
+
decay: this.data.pluginFilters?.echo?.decay && !this.data.pluginFilters?.echo?.echoLength ? this.data.pluginFilters?.echo?.decay : 0,
|
|
2971
|
+
delay: this.data.pluginFilters?.echo?.delay || 0
|
|
2972
|
+
},
|
|
2973
|
+
reverb: {
|
|
2974
|
+
gains: [],
|
|
2975
|
+
delays: [],
|
|
2976
|
+
...this.data.pluginFilters?.reverb
|
|
2977
|
+
}
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2964
2980
|
/**
|
|
2965
2981
|
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
2966
2982
|
* @param oldFilterTimescale
|
|
@@ -2979,13 +2995,17 @@ var FilterManager = class {
|
|
|
2979
2995
|
this.filters.rotation = this.privateNot0(this.data.rotation?.rotationHz);
|
|
2980
2996
|
this.filters.vibrato = this.privateNot0(this.data.vibrato?.frequency) || this.privateNot0(this.data.vibrato?.depth);
|
|
2981
2997
|
this.filters.tremolo = this.privateNot0(this.data.tremolo?.frequency) || this.privateNot0(this.data.tremolo?.depth);
|
|
2982
|
-
const lavalinkFilterData = this.
|
|
2983
|
-
this.filters.lavalinkFilterPlugin
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
this.filters.lavalinkLavaDspxPlugin
|
|
2988
|
-
|
|
2998
|
+
const lavalinkFilterData = this.getLavalinkFilterData();
|
|
2999
|
+
this.filters.lavalinkFilterPlugin = {
|
|
3000
|
+
echo: this.privateNot0(lavalinkFilterData?.echo?.decay) || this.privateNot0(lavalinkFilterData?.echo?.delay),
|
|
3001
|
+
reverb: this.privateNot0(lavalinkFilterData?.reverb?.delays?.length) || this.privateNot0(lavalinkFilterData?.reverb?.gains?.length)
|
|
3002
|
+
};
|
|
3003
|
+
this.filters.lavalinkLavaDspxPlugin = {
|
|
3004
|
+
lowPass: Object.values(this.data.pluginFilters?.["low-pass"] || {})?.length > 0,
|
|
3005
|
+
highPass: Object.values(this.data.pluginFilters?.["high-pass"] || {})?.length > 0,
|
|
3006
|
+
normalization: Object.values(this.data.pluginFilters?.normalization || {})?.length > 0,
|
|
3007
|
+
echo: Object.values(this.data.pluginFilters?.echo || {})?.length > 0 && typeof this.data.pluginFilters?.echo?.delay === "undefined"
|
|
3008
|
+
};
|
|
2989
3009
|
this.filters.lowPass = this.privateNot0(this.data.lowPass?.smoothing);
|
|
2990
3010
|
this.filters.karaoke = Object.values(this.data.karaoke ?? {}).some((v) => v !== 0);
|
|
2991
3011
|
if ((this.filters.nightcore || this.filters.vaporwave) && oldFilterTimescale) {
|
|
@@ -4622,11 +4642,15 @@ var Player = class {
|
|
|
4622
4642
|
}
|
|
4623
4643
|
}
|
|
4624
4644
|
/**
|
|
4625
|
-
* 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.
|
|
4645
|
+
* (Wrapper-FN for changeNode) 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.
|
|
4626
4646
|
* @param node the id of the node to move to
|
|
4627
4647
|
* @returns the player
|
|
4628
4648
|
* @throws RangeError if there is no available nodes.
|
|
4629
4649
|
* @throws Error if the node to move to is the same as the current node.
|
|
4650
|
+
* @example
|
|
4651
|
+
* ```ts
|
|
4652
|
+
* const newNodeMovedTo = await player.moveNode(); // no need to specify the new node, it will find a least used node automatically, but you can ofc. use a custom node id.
|
|
4653
|
+
* ```
|
|
4630
4654
|
*/
|
|
4631
4655
|
async moveNode(node) {
|
|
4632
4656
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -1361,6 +1361,7 @@ var LavalinkNode = class {
|
|
|
1361
1361
|
* ```
|
|
1362
1362
|
*/
|
|
1363
1363
|
destroy(destroyReason, deleteNode = true, movePlayers = false) {
|
|
1364
|
+
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1364
1365
|
const players = this.NodeManager.LavalinkManager.players.filter((p) => p.node.id === this.id);
|
|
1365
1366
|
if (players.size) {
|
|
1366
1367
|
const enableDebugEvents = this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents;
|
|
@@ -1436,7 +1437,7 @@ var LavalinkNode = class {
|
|
|
1436
1437
|
*
|
|
1437
1438
|
* @example
|
|
1438
1439
|
* ```ts
|
|
1439
|
-
* player.node.
|
|
1440
|
+
* player.node.disconnect("Forcefully disconnect the connection to the node.");
|
|
1440
1441
|
* ```
|
|
1441
1442
|
*/
|
|
1442
1443
|
disconnect(disconnectReason) {
|
|
@@ -1444,6 +1445,7 @@ var LavalinkNode = class {
|
|
|
1444
1445
|
this.socket?.close(1e3, "Node-Disconnect");
|
|
1445
1446
|
this.socket?.removeAllListeners();
|
|
1446
1447
|
this.socket = null;
|
|
1448
|
+
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1447
1449
|
this.resetReconnectionAttempts();
|
|
1448
1450
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: disconnectReason });
|
|
1449
1451
|
}
|
|
@@ -1908,10 +1910,10 @@ var LavalinkNode = class {
|
|
|
1908
1910
|
});
|
|
1909
1911
|
this.heartBeatInterval = setInterval(() => {
|
|
1910
1912
|
if (!this.socket) return console.error("Node-Heartbeat-Interval - Socket not available - maybe reconnecting?");
|
|
1911
|
-
if (!this.isAlive) this.close(500, "Node-Heartbeat-Timeout");
|
|
1913
|
+
if (!this.isAlive) return this.close(500, "Node-Heartbeat-Timeout");
|
|
1912
1914
|
this.isAlive = false;
|
|
1913
1915
|
this.heartBeatPingTimestamp = performance.now();
|
|
1914
|
-
this.socket
|
|
1916
|
+
this.socket?.ping?.();
|
|
1915
1917
|
}, this.options.heartBeatInterval || 3e4);
|
|
1916
1918
|
}
|
|
1917
1919
|
this.info = await this.fetchInfo().catch((e) => (console.error(e, "ON-OPEN-FETCH"), null));
|
|
@@ -1960,6 +1962,7 @@ var LavalinkNode = class {
|
|
|
1960
1962
|
error(error) {
|
|
1961
1963
|
if (!error) return;
|
|
1962
1964
|
this.NodeManager.emit("error", this, error);
|
|
1965
|
+
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1963
1966
|
this.reconnect();
|
|
1964
1967
|
if (this.options.closeOnError) {
|
|
1965
1968
|
if (this.heartBeatInterval) clearInterval(this.heartBeatInterval);
|
|
@@ -2900,6 +2903,19 @@ var FilterManager = class {
|
|
|
2900
2903
|
privateNot0(value) {
|
|
2901
2904
|
return typeof value === "number" && value !== 0;
|
|
2902
2905
|
}
|
|
2906
|
+
getLavalinkFilterData() {
|
|
2907
|
+
return this.data.pluginFilters?.["lavalink-filter-plugin"] || {
|
|
2908
|
+
echo: {
|
|
2909
|
+
decay: this.data.pluginFilters?.echo?.decay && !this.data.pluginFilters?.echo?.echoLength ? this.data.pluginFilters?.echo?.decay : 0,
|
|
2910
|
+
delay: this.data.pluginFilters?.echo?.delay || 0
|
|
2911
|
+
},
|
|
2912
|
+
reverb: {
|
|
2913
|
+
gains: [],
|
|
2914
|
+
delays: [],
|
|
2915
|
+
...this.data.pluginFilters?.reverb
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2903
2919
|
/**
|
|
2904
2920
|
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
2905
2921
|
* @param oldFilterTimescale
|
|
@@ -2918,13 +2934,17 @@ var FilterManager = class {
|
|
|
2918
2934
|
this.filters.rotation = this.privateNot0(this.data.rotation?.rotationHz);
|
|
2919
2935
|
this.filters.vibrato = this.privateNot0(this.data.vibrato?.frequency) || this.privateNot0(this.data.vibrato?.depth);
|
|
2920
2936
|
this.filters.tremolo = this.privateNot0(this.data.tremolo?.frequency) || this.privateNot0(this.data.tremolo?.depth);
|
|
2921
|
-
const lavalinkFilterData = this.
|
|
2922
|
-
this.filters.lavalinkFilterPlugin
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
this.filters.lavalinkLavaDspxPlugin
|
|
2927
|
-
|
|
2937
|
+
const lavalinkFilterData = this.getLavalinkFilterData();
|
|
2938
|
+
this.filters.lavalinkFilterPlugin = {
|
|
2939
|
+
echo: this.privateNot0(lavalinkFilterData?.echo?.decay) || this.privateNot0(lavalinkFilterData?.echo?.delay),
|
|
2940
|
+
reverb: this.privateNot0(lavalinkFilterData?.reverb?.delays?.length) || this.privateNot0(lavalinkFilterData?.reverb?.gains?.length)
|
|
2941
|
+
};
|
|
2942
|
+
this.filters.lavalinkLavaDspxPlugin = {
|
|
2943
|
+
lowPass: Object.values(this.data.pluginFilters?.["low-pass"] || {})?.length > 0,
|
|
2944
|
+
highPass: Object.values(this.data.pluginFilters?.["high-pass"] || {})?.length > 0,
|
|
2945
|
+
normalization: Object.values(this.data.pluginFilters?.normalization || {})?.length > 0,
|
|
2946
|
+
echo: Object.values(this.data.pluginFilters?.echo || {})?.length > 0 && typeof this.data.pluginFilters?.echo?.delay === "undefined"
|
|
2947
|
+
};
|
|
2928
2948
|
this.filters.lowPass = this.privateNot0(this.data.lowPass?.smoothing);
|
|
2929
2949
|
this.filters.karaoke = Object.values(this.data.karaoke ?? {}).some((v) => v !== 0);
|
|
2930
2950
|
if ((this.filters.nightcore || this.filters.vaporwave) && oldFilterTimescale) {
|
|
@@ -4561,11 +4581,15 @@ var Player = class {
|
|
|
4561
4581
|
}
|
|
4562
4582
|
}
|
|
4563
4583
|
/**
|
|
4564
|
-
* 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.
|
|
4584
|
+
* (Wrapper-FN for changeNode) 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.
|
|
4565
4585
|
* @param node the id of the node to move to
|
|
4566
4586
|
* @returns the player
|
|
4567
4587
|
* @throws RangeError if there is no available nodes.
|
|
4568
4588
|
* @throws Error if the node to move to is the same as the current node.
|
|
4589
|
+
* @example
|
|
4590
|
+
* ```ts
|
|
4591
|
+
* const newNodeMovedTo = await player.moveNode(); // no need to specify the new node, it will find a least used node automatically, but you can ofc. use a custom node id.
|
|
4592
|
+
* ```
|
|
4569
4593
|
*/
|
|
4570
4594
|
async moveNode(node) {
|
|
4571
4595
|
try {
|
package/package.json
CHANGED