lavalink-client 2.3.6 → 2.4.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 +56 -7
- package/dist/cjs/structures/Constants.d.ts +4 -0
- package/dist/cjs/structures/Constants.js +7 -2
- package/dist/cjs/structures/Filters.d.ts +24 -0
- package/dist/cjs/structures/Filters.js +34 -10
- package/dist/cjs/structures/LavalinkManager.d.ts +4 -5
- package/dist/cjs/structures/LavalinkManager.js +36 -14
- package/dist/cjs/structures/Node.d.ts +30 -16
- package/dist/cjs/structures/Node.js +165 -84
- package/dist/cjs/structures/NodeManager.d.ts +2 -2
- package/dist/cjs/structures/NodeManager.js +19 -19
- package/dist/cjs/structures/Player.d.ts +10 -3
- package/dist/cjs/structures/Player.js +12 -0
- package/dist/cjs/structures/Queue.d.ts +9 -10
- package/dist/cjs/structures/Queue.js +3 -3
- package/dist/cjs/structures/Types/Manager.d.ts +40 -0
- package/dist/cjs/structures/Types/Node.d.ts +0 -1
- package/dist/cjs/structures/Types/Player.d.ts +5 -1
- package/dist/cjs/structures/Types/Queue.d.ts +6 -6
- package/dist/cjs/structures/Types/Track.d.ts +3 -1
- package/dist/cjs/structures/Types/Utils.d.ts +17 -2
- package/dist/cjs/structures/Utils.js +3 -10
- package/dist/esm/structures/Constants.d.ts +4 -0
- package/dist/esm/structures/Constants.js +6 -1
- package/dist/esm/structures/Filters.d.ts +24 -0
- package/dist/esm/structures/Filters.js +34 -10
- package/dist/esm/structures/LavalinkManager.d.ts +4 -5
- package/dist/esm/structures/LavalinkManager.js +36 -14
- package/dist/esm/structures/Node.d.ts +30 -16
- package/dist/esm/structures/Node.js +165 -84
- package/dist/esm/structures/NodeManager.d.ts +2 -2
- package/dist/esm/structures/NodeManager.js +20 -20
- package/dist/esm/structures/Player.d.ts +10 -3
- package/dist/esm/structures/Player.js +12 -0
- package/dist/esm/structures/Queue.d.ts +9 -10
- package/dist/esm/structures/Queue.js +3 -3
- package/dist/esm/structures/Types/Manager.d.ts +40 -0
- package/dist/esm/structures/Types/Node.d.ts +0 -1
- package/dist/esm/structures/Types/Player.d.ts +5 -1
- package/dist/esm/structures/Types/Queue.d.ts +6 -6
- package/dist/esm/structures/Types/Track.d.ts +3 -1
- package/dist/esm/structures/Types/Utils.d.ts +17 -2
- package/dist/esm/structures/Utils.js +0 -7
- package/dist/types/structures/Constants.d.ts +4 -0
- package/dist/types/structures/Filters.d.ts +24 -0
- package/dist/types/structures/LavalinkManager.d.ts +4 -5
- package/dist/types/structures/Node.d.ts +30 -16
- package/dist/types/structures/NodeManager.d.ts +2 -2
- package/dist/types/structures/Player.d.ts +10 -3
- package/dist/types/structures/Queue.d.ts +9 -10
- package/dist/types/structures/Types/Manager.d.ts +40 -0
- package/dist/types/structures/Types/Node.d.ts +0 -1
- package/dist/types/structures/Types/Player.d.ts +5 -1
- package/dist/types/structures/Types/Queue.d.ts +6 -6
- package/dist/types/structures/Types/Track.d.ts +3 -1
- package/dist/types/structures/Types/Utils.d.ts +17 -2
- package/package.json +29 -18
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Profi
|
|
|
13
13
|
<a href="https://www.npmjs.com/package/lavalink-client">
|
|
14
14
|
<img src="https://img.shields.io/npm/dt/lavalink-client.svg?maxAge=3600&style=for-the-badge&logo=npm&logoColor=red" alt="NPM downloads" />
|
|
15
15
|
</a>
|
|
16
|
-
<a href="https://
|
|
16
|
+
<a href="https://tomato6966.github.io/lavalink-client/">
|
|
17
17
|
<img src="https://img.shields.io/badge/Documation-%230288D1.svg?style=for-the-badge&logo=gitbook&logoColor=white" alt="Get Started Now">
|
|
18
18
|
</a>
|
|
19
19
|
</p>
|
|
@@ -24,7 +24,7 @@ Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Profi
|
|
|
24
24
|
|
|
25
25
|
# Install
|
|
26
26
|
|
|
27
|
-
Latest stable Version: **`v2.
|
|
27
|
+
Latest stable Version: **`v2.4.0`**
|
|
28
28
|
|
|
29
29
|
<details><summary>👉 via NPM</summary>
|
|
30
30
|
|
|
@@ -36,7 +36,7 @@ npm install --save lavalink-client
|
|
|
36
36
|
Dev Version: (Current)
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
npm install tomato6966/lavalink-client
|
|
39
|
+
npm install --save tomato6966/lavalink-client
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
</details>
|
|
@@ -57,9 +57,10 @@ yarn add tomato6966/lavalink-client
|
|
|
57
57
|
|
|
58
58
|
# Documentation
|
|
59
59
|
|
|
60
|
-
Check out the [Documentation](https://
|
|
61
|
-
|
|
62
|
-
-
|
|
60
|
+
Check out the [Documentation](https://tomato6966.github.io/lavalink-client/)
|
|
61
|
+
- See all [Manager-Events, e.g. for Track / player and general errors / logs](https://tomato6966.github.io/lavalink-client/extra/manager-events)
|
|
62
|
+
- See all [NodeManager-Events e.g. for Node Errors / logs](https://tomato6966.github.io/lavalink-client/extra/node-events)
|
|
63
|
+
- See the Guide on [How to do resuming](https://tomato6966.github.io/lavalink-client/extra/resuming)
|
|
63
64
|
|
|
64
65
|
# Used in:
|
|
65
66
|
|
|
@@ -724,7 +725,7 @@ if(previousTrack) {
|
|
|
724
725
|
- Added more samples to the Testbot related configuration
|
|
725
726
|
|
|
726
727
|
|
|
727
|
-
## **Version 2.3.6
|
|
728
|
+
## **Version 2.3.6**
|
|
728
729
|
- Added Lyrics Support:
|
|
729
730
|
- New Player Functions:
|
|
730
731
|
- **` const lyrics = await player.getCurrentLyrics(false); `** -> *Get lyrics of current playing track*
|
|
@@ -740,3 +741,51 @@ if(previousTrack) {
|
|
|
740
741
|
- **` lavalink.on("LyricsLine", (player, track, lyricsLine) => {}); `**
|
|
741
742
|
- **` lavalink.on("LyricsFound", (player, track, data) => {}); `**
|
|
742
743
|
- **` lavalink.on("LyricsNotFound", (player, track, lyricsLine) => {}); `**
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
## **Version 2.4.0**
|
|
747
|
+
- Refactored a little the project folder Structure
|
|
748
|
+
- Added PR Packages to install all commits / packages at once `https://pkg.pr.new/Tomato6966/lavalink-client`
|
|
749
|
+
- Removed the dist folder, and added prepare Scripts
|
|
750
|
+
- Added attributes for git linting
|
|
751
|
+
- Removed the old (gitbook) documentation, and swapped it to a NEW TSDOC Themed Documentation via astro.dev and mdx
|
|
752
|
+
- Added new player events:
|
|
753
|
+
- **`playerMuteChange`**** ➡️ **`(player, selfMuted, serverMuted) => {}`
|
|
754
|
+
*Triggered when the player's voice state related to muting changed*
|
|
755
|
+
|
|
756
|
+
- **`playerDeafChange`** ➡️ `(player, selfDeafed, serverDeafed) => {}`
|
|
757
|
+
*Triggered when the player's voice state related to deafing changed*
|
|
758
|
+
|
|
759
|
+
- **`playerSuppressChange`** ➡️ `(player, suppress) => {}`
|
|
760
|
+
*Triggered when the player's voice state related to suppressing changed*
|
|
761
|
+
|
|
762
|
+
- **`playerQueueEmptyStart`** ➡️ `(player, timeoutMs) => {}`
|
|
763
|
+
*Triggered when the queue empty handler started (the timeout)*
|
|
764
|
+
|
|
765
|
+
- **`playerQueueEmptyEnd`** ➡️ `(player) => {}`
|
|
766
|
+
*Triggered when the queue empty handler finished (successfully) and thus destroyed the player*
|
|
767
|
+
|
|
768
|
+
- **`playerQueueEmptyCancel`** ➡️ `(player) => {}`
|
|
769
|
+
*Triggered when the queue empty handler cancelled (e.g. because a new track got added)*
|
|
770
|
+
|
|
771
|
+
~~- **`playerVoiceEmptyStart`** ➡️ `(player, timeoutMs) => {}`~~
|
|
772
|
+
~~*Triggered when the voice empty handler started (the timeout)*~~
|
|
773
|
+
*Removed again because of memory overhall and not wanting to handle voice states*
|
|
774
|
+
|
|
775
|
+
~~- **`playerVoiceEmptyEnd`** ➡️ `(player) => {}`~~
|
|
776
|
+
~~*Triggered when the voice empty handler finished (successfully) and thus destroyed the player*~~
|
|
777
|
+
*Removed again because of memory overhall and not wanting to handle voice states*
|
|
778
|
+
|
|
779
|
+
~~- **`playerVoiceEmptyCancel`** ➡️ `(player, userId) => {}`~~
|
|
780
|
+
~~*Triggered when the voice empty handler cancelled (e.g. when a user rejoined)*~~
|
|
781
|
+
*Removed again because of memory overhall and not wanting to handle voice states*
|
|
782
|
+
|
|
783
|
+
- **`playerVoiceJoin`** ➡️ `(player, userId) => {}`~~
|
|
784
|
+
*Added instead of the playerVoiceEmpty handler, emitted when a user joins the player-vc while there is a player*
|
|
785
|
+
*Allows you to inmplement a custom playerVoiceEmpty handler*
|
|
786
|
+
|
|
787
|
+
- **`playerVoiceLeave`** ➡️ `(player, userId) => {}`~~
|
|
788
|
+
*Added instead of the playerVoiceEmpty handler, emitted when a user leaves (or. switches away) the player-vc while there is a player*
|
|
789
|
+
*Allows you to inmplement a custom playerVoiceEmpty handler*
|
|
790
|
+
|
|
791
|
+
- Added the new events and configuration to the docs
|
|
@@ -55,6 +55,10 @@ export declare enum DestroyReasons {
|
|
|
55
55
|
TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
|
|
56
56
|
TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
|
|
57
57
|
}
|
|
58
|
+
export declare enum DisconnectReasons {
|
|
59
|
+
Disconnected = "Disconnected",
|
|
60
|
+
DisconnectAllNodes = "DisconnectAllNodes"
|
|
61
|
+
}
|
|
58
62
|
export declare const validSponsorBlocks: string[];
|
|
59
63
|
/** The audio Outputs Data map declaration */
|
|
60
64
|
export declare const audioOutputsData: Record<AudioOutputs, ChannelMixFilter>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EQList = exports.audioOutputsData = exports.validSponsorBlocks = exports.DestroyReasons = exports.DebugEvents = void 0;
|
|
3
|
+
exports.EQList = exports.audioOutputsData = exports.validSponsorBlocks = exports.DisconnectReasons = exports.DestroyReasons = exports.DebugEvents = void 0;
|
|
4
4
|
var DebugEvents;
|
|
5
5
|
(function (DebugEvents) {
|
|
6
6
|
DebugEvents["SetSponsorBlock"] = "SetSponsorBlock";
|
|
@@ -60,11 +60,16 @@ var DestroyReasons;
|
|
|
60
60
|
DestroyReasons["TrackStuckMaxTracksErroredPerTime"] = "TrackStuckMaxTracksErroredPerTime";
|
|
61
61
|
})(DestroyReasons || (exports.DestroyReasons = DestroyReasons = {}));
|
|
62
62
|
;
|
|
63
|
+
var DisconnectReasons;
|
|
64
|
+
(function (DisconnectReasons) {
|
|
65
|
+
DisconnectReasons["Disconnected"] = "Disconnected";
|
|
66
|
+
DisconnectReasons["DisconnectAllNodes"] = "DisconnectAllNodes";
|
|
67
|
+
})(DisconnectReasons || (exports.DisconnectReasons = DisconnectReasons = {}));
|
|
63
68
|
exports.validSponsorBlocks = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "filler"];
|
|
64
69
|
/** The audio Outputs Data map declaration */
|
|
65
70
|
exports.audioOutputsData = {
|
|
66
71
|
mono: {
|
|
67
|
-
leftToLeft: 0.5,
|
|
72
|
+
leftToLeft: 0.5, //each channel should in total 0 | 1, 0 === off, 1 === on, 0.5+0.5 === 1
|
|
68
73
|
leftToRight: 0.5,
|
|
69
74
|
rightToLeft: 0.5,
|
|
70
75
|
rightToRight: 0.5,
|
|
@@ -87,9 +87,33 @@ export declare class FilterManager {
|
|
|
87
87
|
*/
|
|
88
88
|
toggleLowPass(smoothing?: number): Promise<boolean>;
|
|
89
89
|
lavalinkLavaDspxPlugin: {
|
|
90
|
+
/**
|
|
91
|
+
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
92
|
+
* @param boostFactor
|
|
93
|
+
* @param cutoffFrequency
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
90
96
|
toggleLowPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
99
|
+
* @param boostFactor
|
|
100
|
+
* @param cutoffFrequency
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
91
103
|
toggleHighPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Enables / Disables the Normalization effect.
|
|
106
|
+
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
107
|
+
* @param {boolean} [adaptive=true] - Whether to use adaptive normalization or not.
|
|
108
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
109
|
+
*/
|
|
92
110
|
toggleNormalization: (maxAmplitude?: number, adaptive?: boolean) => Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
113
|
+
* @param {number} [decay=0.5] - The decay of the echo effect.
|
|
114
|
+
* @param {number} [echoLength=0.5] - The length of the echo effect.
|
|
115
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
116
|
+
*/
|
|
93
117
|
toggleEcho: (decay?: number, echoLength?: number) => Promise<boolean>;
|
|
94
118
|
};
|
|
95
119
|
lavalinkFilterPlugin: {
|
|
@@ -45,29 +45,29 @@ class FilterManager {
|
|
|
45
45
|
filterWidth: 0
|
|
46
46
|
},
|
|
47
47
|
timescale: {
|
|
48
|
-
speed: 1,
|
|
49
|
-
pitch: 1,
|
|
48
|
+
speed: 1, // 0 = x
|
|
49
|
+
pitch: 1, // 0 = x
|
|
50
50
|
rate: 1 // 0 = x
|
|
51
51
|
},
|
|
52
52
|
rotation: {
|
|
53
53
|
rotationHz: 0
|
|
54
54
|
},
|
|
55
55
|
tremolo: {
|
|
56
|
-
frequency: 0,
|
|
56
|
+
frequency: 0, // 0 < x
|
|
57
57
|
depth: 0 // 0 < x = 1
|
|
58
58
|
},
|
|
59
59
|
vibrato: {
|
|
60
|
-
frequency: 0,
|
|
60
|
+
frequency: 0, // 0 < x <= 14
|
|
61
61
|
depth: 0 // 0 < x <= 1
|
|
62
62
|
},
|
|
63
63
|
pluginFilters: {
|
|
64
64
|
"lavalink-filter-plugin": {
|
|
65
65
|
echo: {
|
|
66
|
-
delay: 0,
|
|
66
|
+
delay: 0, // in seconds
|
|
67
67
|
decay: 0 // 0 < 1
|
|
68
68
|
},
|
|
69
69
|
reverb: {
|
|
70
|
-
delays: [],
|
|
70
|
+
delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
71
71
|
gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
72
72
|
}
|
|
73
73
|
},
|
|
@@ -231,8 +231,8 @@ class FilterManager {
|
|
|
231
231
|
filterWidth: 0
|
|
232
232
|
},
|
|
233
233
|
timescale: {
|
|
234
|
-
speed: 1,
|
|
235
|
-
pitch: 1,
|
|
234
|
+
speed: 1, // 0 = x
|
|
235
|
+
pitch: 1, // 0 = x
|
|
236
236
|
rate: 1 // 0 = x
|
|
237
237
|
},
|
|
238
238
|
pluginFilters: {
|
|
@@ -267,11 +267,11 @@ class FilterManager {
|
|
|
267
267
|
rotationHz: 0
|
|
268
268
|
},
|
|
269
269
|
tremolo: {
|
|
270
|
-
frequency: 0,
|
|
270
|
+
frequency: 0, // 0 < x
|
|
271
271
|
depth: 0 // 0 < x = 1
|
|
272
272
|
},
|
|
273
273
|
vibrato: {
|
|
274
|
-
frequency: 0,
|
|
274
|
+
frequency: 0, // 0 < x = 14
|
|
275
275
|
depth: 0 // 0 < x = 1
|
|
276
276
|
},
|
|
277
277
|
channelMix: Constants_1.audioOutputsData.stereo,
|
|
@@ -431,6 +431,12 @@ class FilterManager {
|
|
|
431
431
|
return this.filters.lowPass;
|
|
432
432
|
}
|
|
433
433
|
lavalinkLavaDspxPlugin = {
|
|
434
|
+
/**
|
|
435
|
+
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
436
|
+
* @param boostFactor
|
|
437
|
+
* @param cutoffFrequency
|
|
438
|
+
* @returns
|
|
439
|
+
*/
|
|
434
440
|
toggleLowPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
435
441
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
436
442
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -455,6 +461,12 @@ class FilterManager {
|
|
|
455
461
|
await this.applyPlayerFilters();
|
|
456
462
|
return this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
457
463
|
},
|
|
464
|
+
/**
|
|
465
|
+
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
466
|
+
* @param boostFactor
|
|
467
|
+
* @param cutoffFrequency
|
|
468
|
+
* @returns
|
|
469
|
+
*/
|
|
458
470
|
toggleHighPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
459
471
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
460
472
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -479,6 +491,12 @@ class FilterManager {
|
|
|
479
491
|
await this.applyPlayerFilters();
|
|
480
492
|
return this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
481
493
|
},
|
|
494
|
+
/**
|
|
495
|
+
* Enables / Disables the Normalization effect.
|
|
496
|
+
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
497
|
+
* @param {boolean} [adaptive=true] - Whether to use adaptive normalization or not.
|
|
498
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
499
|
+
*/
|
|
482
500
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
483
501
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
484
502
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -503,6 +521,12 @@ class FilterManager {
|
|
|
503
521
|
await this.applyPlayerFilters();
|
|
504
522
|
return this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
505
523
|
},
|
|
524
|
+
/**
|
|
525
|
+
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
526
|
+
* @param {number} [decay=0.5] - The decay of the echo effect.
|
|
527
|
+
* @param {number} [echoLength=0.5] - The length of the echo effect.
|
|
528
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
529
|
+
*/
|
|
506
530
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
507
531
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
508
532
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { EventEmitter } from "events";
|
|
3
2
|
import { NodeManager } from "./NodeManager.js";
|
|
4
3
|
import { Player } from "./Player.js";
|
|
@@ -137,7 +136,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
137
136
|
* ```
|
|
138
137
|
* @returns
|
|
139
138
|
*/
|
|
140
|
-
getPlayer(guildId: string): Player;
|
|
139
|
+
getPlayer(guildId: string): Player | undefined;
|
|
141
140
|
/**
|
|
142
141
|
* Create a Music-Player. If a player exists, then it returns it before creating a new one
|
|
143
142
|
* @param options
|
|
@@ -175,7 +174,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
175
174
|
* // recommend to do it on the player tho: player.destroy("forcefully destroyed the player");
|
|
176
175
|
* ```
|
|
177
176
|
*/
|
|
178
|
-
destroyPlayer(guildId: string, destroyReason?: string): Promise<Player>;
|
|
177
|
+
destroyPlayer(guildId: string, destroyReason?: string): Promise<void | Player>;
|
|
179
178
|
/**
|
|
180
179
|
* Delete's a player from the cache without destroying it on lavalink (only works when it's disconnected)
|
|
181
180
|
* @param guildId
|
|
@@ -187,7 +186,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
187
186
|
* // shouldn't be used except you know what you are doing.
|
|
188
187
|
* ```
|
|
189
188
|
*/
|
|
190
|
-
deletePlayer(guildId: string): boolean;
|
|
189
|
+
deletePlayer(guildId: string): boolean | void;
|
|
191
190
|
/**
|
|
192
191
|
* Checks wether the the lib is useable based on if any node is connected
|
|
193
192
|
*
|
|
@@ -213,7 +212,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
213
212
|
* });
|
|
214
213
|
* ```
|
|
215
214
|
*/
|
|
216
|
-
init(clientData: BotClientOptions): Promise<
|
|
215
|
+
init(clientData: BotClientOptions): Promise<LavalinkManager>;
|
|
217
216
|
/**
|
|
218
217
|
* Sends voice data to the Lavalink server.
|
|
219
218
|
* ! Without this the library won't work
|
|
@@ -92,9 +92,9 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
92
92
|
volumeDecrementer: options?.playerOptions?.volumeDecrementer ?? 1,
|
|
93
93
|
requesterTransformer: options?.playerOptions?.requesterTransformer ?? null,
|
|
94
94
|
useUnresolvedData: options?.playerOptions?.useUnresolvedData ?? false,
|
|
95
|
-
minAutoPlayMs: options?.playerOptions?.minAutoPlayMs ??
|
|
95
|
+
minAutoPlayMs: options?.playerOptions?.minAutoPlayMs ?? 10_000,
|
|
96
96
|
maxErrorsPerTime: {
|
|
97
|
-
threshold: options?.playerOptions?.maxErrorsPerTime?.threshold ??
|
|
97
|
+
threshold: options?.playerOptions?.maxErrorsPerTime?.threshold ?? 35_000,
|
|
98
98
|
maxAmount: options?.playerOptions?.maxErrorsPerTime?.maxAmount ?? 3
|
|
99
99
|
}
|
|
100
100
|
},
|
|
@@ -111,7 +111,7 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
111
111
|
},
|
|
112
112
|
advancedOptions: {
|
|
113
113
|
enableDebugEvents: options?.advancedOptions?.enableDebugEvents ?? false,
|
|
114
|
-
maxFilterFixDuration: options?.advancedOptions?.maxFilterFixDuration ??
|
|
114
|
+
maxFilterFixDuration: options?.advancedOptions?.maxFilterFixDuration ?? 600_000,
|
|
115
115
|
debugOptions: {
|
|
116
116
|
logCustomSearches: options?.advancedOptions?.debugOptions?.logCustomSearches ?? false,
|
|
117
117
|
noAudio: options?.advancedOptions?.debugOptions?.noAudio ?? false,
|
|
@@ -509,11 +509,16 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
509
509
|
}
|
|
510
510
|
/* voice state update */
|
|
511
511
|
if (update.user_id !== this.options?.client.id) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
512
|
+
if (update.user_id && player.voiceChannelId) {
|
|
513
|
+
this.emit(update.channel_id === player.voiceChannelId ? "playerVoiceJoin" : "playerVoiceLeave", player, update.user_id);
|
|
514
|
+
}
|
|
515
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
516
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
517
|
+
state: "warn",
|
|
518
|
+
message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
|
|
519
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
520
|
+
});
|
|
521
|
+
}
|
|
517
522
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
518
523
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, voice update user is not equal to provided client id of the manageroptions#client#id", "user:", update.user_id, "manager client id:", this.options?.client.id);
|
|
519
524
|
return;
|
|
@@ -523,6 +528,22 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
523
528
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
524
529
|
player.voice.sessionId = update.session_id;
|
|
525
530
|
player.voiceChannelId = update.channel_id;
|
|
531
|
+
const selfMuteChanged = typeof update.self_mute === "boolean" && player.voiceState.selfMute !== update.self_mute;
|
|
532
|
+
const serverMuteChanged = typeof update.mute === "boolean" && player.voiceState.serverMute !== update.mute;
|
|
533
|
+
const selfDeafChanged = typeof update.self_deaf === "boolean" && player.voiceState.selfDeaf !== update.self_deaf;
|
|
534
|
+
const serverDeafChanged = typeof update.deaf === "boolean" && player.voiceState.serverDeaf !== update.deaf;
|
|
535
|
+
const suppressChange = typeof update.suppress === "boolean" && player.voiceState.suppress !== update.suppress;
|
|
536
|
+
player.voiceState.selfDeaf = update.self_deaf ?? player.voiceState?.selfDeaf;
|
|
537
|
+
player.voiceState.selfMute = update.self_mute ?? player.voiceState?.selfMute;
|
|
538
|
+
player.voiceState.serverDeaf = update.deaf ?? player.voiceState?.serverDeaf;
|
|
539
|
+
player.voiceState.serverMute = update.mute ?? player.voiceState?.serverMute;
|
|
540
|
+
player.voiceState.suppress = update.suppress ?? player.voiceState?.suppress;
|
|
541
|
+
if (selfMuteChanged || serverMuteChanged)
|
|
542
|
+
this.emit("playerMuteChange", player, player.voiceState.selfMute, player.voiceState.serverMute);
|
|
543
|
+
if (selfDeafChanged || serverDeafChanged)
|
|
544
|
+
this.emit("playerDeafChange", player, player.voiceState.selfDeaf, player.voiceState.serverDeaf);
|
|
545
|
+
if (suppressChange)
|
|
546
|
+
this.emit("playerSuppressChange", player, player.voiceState.suppress);
|
|
526
547
|
}
|
|
527
548
|
else {
|
|
528
549
|
if (this.options?.playerOptions?.onDisconnect?.destroyPlayer === true) {
|
|
@@ -532,11 +553,13 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
532
553
|
if (this.options?.playerOptions?.onDisconnect?.autoReconnect === true) {
|
|
533
554
|
try {
|
|
534
555
|
const positionPrevios = player.position;
|
|
535
|
-
this.
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
556
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
557
|
+
this.emit("debug", Constants_1.DebugEvents.PlayerAutoReconnect, {
|
|
558
|
+
state: "log",
|
|
559
|
+
message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
|
|
560
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
561
|
+
});
|
|
562
|
+
}
|
|
540
563
|
await player.connect();
|
|
541
564
|
// replay the current playing stream
|
|
542
565
|
await player.play({
|
|
@@ -554,7 +577,6 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
554
577
|
player.voice = Object.assign({});
|
|
555
578
|
return;
|
|
556
579
|
}
|
|
557
|
-
return;
|
|
558
580
|
}
|
|
559
581
|
}
|
|
560
582
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Player } from "./Player.js";
|
|
2
|
-
import type { DestroyReasonsType } from "./Types/Player.js";
|
|
2
|
+
import type { DestroyReasonsType, DisconnectReasonsType } from "./Types/Player.js";
|
|
3
3
|
import type { Track } from "./Types/Track.js";
|
|
4
4
|
import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils.js";
|
|
5
5
|
import type { NodeManager } from "./NodeManager.js";
|
|
@@ -13,6 +13,7 @@ export declare class LavalinkNode {
|
|
|
13
13
|
get heartBeatPing(): number;
|
|
14
14
|
private heartBeatInterval?;
|
|
15
15
|
private pingTimeout?;
|
|
16
|
+
isAlive: boolean;
|
|
16
17
|
/** The provided Options of the Node */
|
|
17
18
|
options: LavalinkNodeOptions;
|
|
18
19
|
/** The amount of rest calls the node has made. */
|
|
@@ -88,7 +89,8 @@ export declare class LavalinkNode {
|
|
|
88
89
|
* player.node.request(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET", false);
|
|
89
90
|
* ```
|
|
90
91
|
*/
|
|
91
|
-
request(endpoint: string, modify
|
|
92
|
+
request(endpoint: string, modify: ModifyRequest | undefined, parseAsText: true): Promise<string>;
|
|
93
|
+
request(endpoint: string, modify?: ModifyRequest, parseAsText?: false): Promise<any>;
|
|
92
94
|
/**
|
|
93
95
|
* Search something raw on the node, please note only add tracks to players of that node
|
|
94
96
|
* @param query SearchQuery Object
|
|
@@ -109,7 +111,7 @@ export declare class LavalinkNode {
|
|
|
109
111
|
* @param query LavaSearchQuery Object
|
|
110
112
|
* @param requestUser Request User for creating the player(s)
|
|
111
113
|
* @param throwOnEmpty Wether to throw on an empty result or not
|
|
112
|
-
* @returns LavaSearchresult
|
|
114
|
+
* @returns LavaSearchresult (SearchResult if link is provided)
|
|
113
115
|
*
|
|
114
116
|
* @example
|
|
115
117
|
* ```ts
|
|
@@ -117,7 +119,7 @@ export declare class LavalinkNode {
|
|
|
117
119
|
* player.node.lavaSearch({ types: ["playlist", "album"], query: "Rick Astley", source: "spotify" }, interaction.user);
|
|
118
120
|
* ```
|
|
119
121
|
*/
|
|
120
|
-
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<
|
|
122
|
+
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<LavaSearchResponse | SearchResult>;
|
|
121
123
|
/**
|
|
122
124
|
* Update the Player State on the Lavalink Server
|
|
123
125
|
* @param data data to send to lavalink and sync locally
|
|
@@ -141,7 +143,7 @@ export declare class LavalinkNode {
|
|
|
141
143
|
* player.node.destroyPlayer(player.guildId);
|
|
142
144
|
* ```
|
|
143
145
|
*/
|
|
144
|
-
destroyPlayer(guildId: any): Promise<
|
|
146
|
+
destroyPlayer(guildId: any): Promise<void>;
|
|
145
147
|
/**
|
|
146
148
|
* Connect to the Lavalink Node
|
|
147
149
|
* @param sessionId Provide the Session Id of the previous connection, to resume the node and it's player(s)
|
|
@@ -169,7 +171,7 @@ export declare class LavalinkNode {
|
|
|
169
171
|
get id(): string;
|
|
170
172
|
/**
|
|
171
173
|
* Destroys the Node-Connection (Websocket) and all player's of the node
|
|
172
|
-
* @param destroyReason
|
|
174
|
+
* @param destroyReason Destroy Reason to use when destroying the players
|
|
173
175
|
* @param deleteNode wether to delete the nodte from the nodes list too, if false it will emit a disconnect. @default true
|
|
174
176
|
* @returns void
|
|
175
177
|
*
|
|
@@ -179,6 +181,19 @@ export declare class LavalinkNode {
|
|
|
179
181
|
* ```
|
|
180
182
|
*/
|
|
181
183
|
destroy(destroyReason?: DestroyReasonsType, deleteNode?: boolean): void;
|
|
184
|
+
/**
|
|
185
|
+
* Disconnects the Node-Connection (Websocket)
|
|
186
|
+
* @param disconnectReason Disconnect Reason to use when disconnecting Node
|
|
187
|
+
* @returns void
|
|
188
|
+
*
|
|
189
|
+
* Also the node will not get re-connected again.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* player.node.destroy("custom Player Destroy Reason", true);
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
disconnect(disconnectReason?: DisconnectReasonsType): void;
|
|
182
197
|
/**
|
|
183
198
|
* Returns if connected to the Node.
|
|
184
199
|
*
|
|
@@ -189,7 +204,6 @@ export declare class LavalinkNode {
|
|
|
189
204
|
* ```
|
|
190
205
|
*/
|
|
191
206
|
get connected(): boolean;
|
|
192
|
-
isAlive: boolean;
|
|
193
207
|
/**
|
|
194
208
|
* Returns the current ConnectionStatus
|
|
195
209
|
*
|
|
@@ -214,7 +228,7 @@ export declare class LavalinkNode {
|
|
|
214
228
|
* const playersOfLavalink = await node?.fetchAllPlayers();
|
|
215
229
|
* ```
|
|
216
230
|
*/
|
|
217
|
-
fetchAllPlayers(): Promise<LavalinkPlayer[] | InvalidLavalinkRestRequest>;
|
|
231
|
+
fetchAllPlayers(): Promise<LavalinkPlayer[] | InvalidLavalinkRestRequest | null>;
|
|
218
232
|
/**
|
|
219
233
|
* Gets specific Player Information
|
|
220
234
|
* @returns lavalink player object if player exists on lavalink
|
|
@@ -225,7 +239,7 @@ export declare class LavalinkNode {
|
|
|
225
239
|
* const playerInformation = await node?.fetchPlayer("guildId");
|
|
226
240
|
* ```
|
|
227
241
|
*/
|
|
228
|
-
fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest>;
|
|
242
|
+
fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest | null>;
|
|
229
243
|
/**
|
|
230
244
|
* Updates the session with and enables/disables resuming and timeout
|
|
231
245
|
* @param resuming Whether resuming is enabled for this session or not
|
|
@@ -238,7 +252,7 @@ export declare class LavalinkNode {
|
|
|
238
252
|
* await node?.updateSession(true, 180e3); // will enable resuming for 180seconds
|
|
239
253
|
* ```
|
|
240
254
|
*/
|
|
241
|
-
updateSession(resuming?: boolean, timeout?: number): Promise<InvalidLavalinkRestRequest |
|
|
255
|
+
updateSession(resuming?: boolean, timeout?: number): Promise<Session | InvalidLavalinkRestRequest | null>;
|
|
242
256
|
/**
|
|
243
257
|
* Decode Track or Tracks
|
|
244
258
|
*/
|
|
@@ -285,7 +299,7 @@ export declare class LavalinkNode {
|
|
|
285
299
|
* // const lyrics = await player.getLyrics(track, true);
|
|
286
300
|
* ```
|
|
287
301
|
*/
|
|
288
|
-
get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult>;
|
|
302
|
+
get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
|
|
289
303
|
/**
|
|
290
304
|
* Get the lyrics of the current playing track
|
|
291
305
|
*
|
|
@@ -299,7 +313,7 @@ export declare class LavalinkNode {
|
|
|
299
313
|
* // const lyrics = await player.getCurrentLyrics();
|
|
300
314
|
* ```
|
|
301
315
|
*/
|
|
302
|
-
getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult>;
|
|
316
|
+
getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
|
|
303
317
|
/**
|
|
304
318
|
* subscribe to lyrics updates for a guild
|
|
305
319
|
* @param guildId the guild id of the player
|
|
@@ -312,7 +326,7 @@ export declare class LavalinkNode {
|
|
|
312
326
|
* // const lyrics = await player.subscribeLyrics();
|
|
313
327
|
* ```
|
|
314
328
|
*/
|
|
315
|
-
subscribe: (guildId: string) => Promise<
|
|
329
|
+
subscribe: (guildId: string) => Promise<unknown>;
|
|
316
330
|
/**
|
|
317
331
|
* unsubscribe from lyrics updates for a guild
|
|
318
332
|
* @param guildId the guild id of the player
|
|
@@ -325,7 +339,7 @@ export declare class LavalinkNode {
|
|
|
325
339
|
* // const lyrics = await player.unsubscribeLyrics();
|
|
326
340
|
* ```
|
|
327
341
|
*/
|
|
328
|
-
unsubscribe: (guildId: string) => Promise<
|
|
342
|
+
unsubscribe: (guildId: string) => Promise<void>;
|
|
329
343
|
};
|
|
330
344
|
/**
|
|
331
345
|
* Request Lavalink statistics.
|
|
@@ -385,7 +399,7 @@ export declare class LavalinkNode {
|
|
|
385
399
|
* await player.node.routePlannerApi.unmarkFailedAddress("ipv6address");
|
|
386
400
|
* ```
|
|
387
401
|
*/
|
|
388
|
-
unmarkFailedAddress: (address: string) => Promise<
|
|
402
|
+
unmarkFailedAddress: (address: string) => Promise<unknown>;
|
|
389
403
|
/**
|
|
390
404
|
* Release all blacklisted IP addresses into pool of IPs
|
|
391
405
|
* @returns request data of the request
|
|
@@ -395,7 +409,7 @@ export declare class LavalinkNode {
|
|
|
395
409
|
* await player.node.routePlannerApi.unmarkAllFailedAddresses();
|
|
396
410
|
* ```
|
|
397
411
|
*/
|
|
398
|
-
unmarkAllFailedAddresses: () => Promise<
|
|
412
|
+
unmarkAllFailedAddresses: () => Promise<unknown>;
|
|
399
413
|
};
|
|
400
414
|
/** @private Utils for validating the */
|
|
401
415
|
private validate;
|