lavalink-client 2.2.0 → 2.2.2
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 +116 -15
- package/dist/cjs/structures/Filters.d.ts +1 -1
- package/dist/cjs/structures/Filters.js +9 -9
- package/dist/cjs/structures/LavalinkManager.d.ts +24 -7
- package/dist/cjs/structures/LavalinkManager.js +15 -2
- package/dist/cjs/structures/LavalinkManagerStatics.d.ts +3 -0
- package/dist/cjs/structures/LavalinkManagerStatics.js +4 -1
- package/dist/cjs/structures/Node.d.ts +307 -22
- package/dist/cjs/structures/Node.js +328 -72
- package/dist/cjs/structures/NodeManager.js +3 -1
- package/dist/cjs/structures/Player.d.ts +44 -8
- package/dist/cjs/structures/Player.js +27 -18
- package/dist/cjs/structures/Queue.d.ts +47 -0
- package/dist/cjs/structures/Queue.js +104 -1
- package/dist/cjs/structures/Track.d.ts +1 -0
- package/dist/cjs/structures/Utils.d.ts +3 -0
- package/dist/cjs/structures/Utils.js +6 -4
- package/dist/esm/structures/Filters.d.ts +1 -1
- package/dist/esm/structures/Filters.js +9 -9
- package/dist/esm/structures/LavalinkManager.d.ts +24 -7
- package/dist/esm/structures/LavalinkManager.js +15 -2
- package/dist/esm/structures/LavalinkManagerStatics.d.ts +3 -0
- package/dist/esm/structures/LavalinkManagerStatics.js +4 -1
- package/dist/esm/structures/Node.d.ts +307 -22
- package/dist/esm/structures/Node.js +328 -72
- package/dist/esm/structures/NodeManager.js +3 -1
- package/dist/esm/structures/Player.d.ts +44 -8
- package/dist/esm/structures/Player.js +27 -18
- package/dist/esm/structures/Queue.d.ts +47 -0
- package/dist/esm/structures/Queue.js +104 -1
- package/dist/esm/structures/Track.d.ts +1 -0
- package/dist/esm/structures/Utils.d.ts +3 -0
- package/dist/esm/structures/Utils.js +6 -4
- package/dist/types/structures/Filters.d.ts +1 -1
- package/dist/types/structures/LavalinkManager.d.ts +24 -7
- package/dist/types/structures/LavalinkManagerStatics.d.ts +3 -0
- package/dist/types/structures/Node.d.ts +307 -22
- package/dist/types/structures/Player.d.ts +44 -8
- package/dist/types/structures/Queue.d.ts +47 -0
- package/dist/types/structures/Track.d.ts +1 -0
- package/dist/types/structures/Utils.d.ts +3 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.
|
|
3
3
|
|
|
4
4
|
<div align="center">
|
|
5
|
-
<p>
|
|
5
|
+
<p>
|
|
6
6
|
<img src="https://madewithlove.now.sh/at?heart=true&template=for-the-badge" alt="Made with love in Austria">
|
|
7
7
|
<img alt="Made with TypeScript" src="https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white">
|
|
8
8
|
</p>
|
|
@@ -59,6 +59,8 @@ yarn add tomato6966/lavalink-client
|
|
|
59
59
|
|
|
60
60
|
Check out the [Documentation](https://lc4.gitbook.io/lavalink-client) | or the [TSDocumentation](https://tomato6966.github.io/lavalink-client/) for **Examples**, and **__detailled__ Docs**, and to figure out **how to get started**. *note: it's not fully done yet (see the docs)*
|
|
61
61
|
|
|
62
|
+
- __**INFO Note**__: Please use the **[TSDocumentation (auto generated, folder `/tsDocs`)](https://tomato6966.github.io/lavalink-client/)** to get the entire information of lavalink-client, *I don't have time to update the [custom written gitbook-documentation](https://lc4.gitbook.io/lavalink-client) (folder `/docs`, feel free to update it)*
|
|
63
|
+
|
|
62
64
|
# Used in:
|
|
63
65
|
|
|
64
66
|
- [Betty](https://betty.cx/)
|
|
@@ -73,7 +75,7 @@ Check out the [Documentation](https://lc4.gitbook.io/lavalink-client) | or the [
|
|
|
73
75
|
|
|
74
76
|
- ✨ Choose able queue stores (maps, collections, redis, databases, ...)
|
|
75
77
|
- You can create your own queueStore, thus make it easy to sync queues accross multiple connections (e.g. dashboard-bot)
|
|
76
|
-
- Automated Queue Sync methods
|
|
78
|
+
- Automated Queue Sync methods
|
|
77
79
|
- Automated unresolveable Tracks (save the queries as Partial Track Objects -> Fetch the tracks only once they are gonna play)
|
|
78
80
|
|
|
79
81
|
- 😍 Included Filter & Equalizer Management
|
|
@@ -89,20 +91,20 @@ Check out the [Documentation](https://lc4.gitbook.io/lavalink-client) | or the [
|
|
|
89
91
|
|
|
90
92
|
- 🛡️ Client Validations
|
|
91
93
|
- Allows you to whitelist links and even blacklist links / words / domain names, so that it doesn't allow requests you don't want!
|
|
92
|
-
- Checks almost all Lavalink Requests for out of bound errors, right before the request is made to prevent process breaking errors.
|
|
94
|
+
- Checks almost all Lavalink Requests for out of bound errors, right before the request is made to prevent process breaking errors.
|
|
93
95
|
|
|
94
96
|
- 🧑💻 Memory friendly and easy style
|
|
95
97
|
- Only the required data is displayed, and the store-way & types match Lavalink#IMPLEMENTATION.md
|
|
96
98
|
|
|
97
99
|
- 😘 Automated Handlings
|
|
98
|
-
- Skips the songs, on TrackEnd, TrackStuck, TrackError,
|
|
100
|
+
- Skips the songs, on TrackEnd, TrackStuck, TrackError,
|
|
99
101
|
- Destroys the player on channeldelete
|
|
100
102
|
- Pauses / resumes the player if it get's muted / unmuted (server-wide) [soon]
|
|
101
103
|
- ...
|
|
102
104
|
|
|
103
105
|
- 😁 Much much more!
|
|
104
106
|
|
|
105
|
-
***
|
|
107
|
+
***
|
|
106
108
|
|
|
107
109
|
# All Events:
|
|
108
110
|
|
|
@@ -167,10 +169,10 @@ class myCustomWatcher implements QueueChangesWatcher {
|
|
|
167
169
|
this.client = client;
|
|
168
170
|
}
|
|
169
171
|
shuffled(guildId, oldStoredQueue, newStoredQueue) {
|
|
170
|
-
console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: Queue got shuffled`)
|
|
172
|
+
console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: Queue got shuffled`)
|
|
171
173
|
}
|
|
172
174
|
tracksAdd(guildId, tracks, position, oldStoredQueue, newStoredQueue) {
|
|
173
|
-
console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got added into the Queue at position #${position}`);
|
|
175
|
+
console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got added into the Queue at position #${position}`);
|
|
174
176
|
}
|
|
175
177
|
tracksRemoved(guildId, tracks, position, oldStoredQueue, newStoredQueue) {
|
|
176
178
|
console.log(`${this.client.guilds.cache.get(guildId)?.name || guildId}: ${tracks.length} Tracks got removed from the Queue at position #${position}`);
|
|
@@ -185,8 +187,58 @@ client.lavalink = new LavalinkManager({
|
|
|
185
187
|
})
|
|
186
188
|
```
|
|
187
189
|
|
|
190
|
+
## How to do resuming
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
// 1. while the player is playing, make sure to enable it:
|
|
194
|
+
const durationToKeepPlayingInMS = 600_000;
|
|
195
|
+
await player.node.updateSession(true, durationToKeepPlayingInMS);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```js
|
|
199
|
+
// 2. make sure to have an eventlistener for resuming events somewhere
|
|
200
|
+
client.lavalink.nodeManager.on("resumed", (node, payload, fetchedPlayers) => {
|
|
201
|
+
// create players:
|
|
202
|
+
for(const fetchedPlayer of fetchedPlayers) {
|
|
203
|
+
const player = client.lavalink.createPlayer({
|
|
204
|
+
guildId: fetchedPlayer.guildId,
|
|
205
|
+
});
|
|
206
|
+
player.setVolume(fetchedPlayer.volume);
|
|
207
|
+
// and apply other things (e.g. paused, voice, filters, state, ...) (stuff like vc channel, text channel you need to store somewhere)
|
|
208
|
+
await player.queue.utils.sync(); // only works with a queuestore
|
|
209
|
+
// you can now overwride the player.queue.current track from the fetchedPlayer, or use the one from the queue.uztils.sync function
|
|
210
|
+
// continue with your resuming code...
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
***
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
### How to use flowertts with custom options
|
|
219
|
+
|
|
220
|
+
- First enable flowertts within the lava-src plugin
|
|
221
|
+
- Then make sure to pass through the extraQueryUrlParams object
|
|
222
|
+
|
|
223
|
+
```js
|
|
224
|
+
const query = interaction.options.getString("text");
|
|
225
|
+
const voice = interaction.options.getString("voice");
|
|
226
|
+
|
|
227
|
+
const extraParams = new URLSearchParams();
|
|
228
|
+
if(voice) extraParams.append(`voice`, voice);
|
|
229
|
+
|
|
230
|
+
// all params for flowertts can be found here: https://flowery.pw/docs
|
|
231
|
+
const response = await player.search({
|
|
232
|
+
query: `${query}`,
|
|
233
|
+
extraQueryUrlParams: extraParams, // as of my knowledge this is currently only used for flowertts, adjusting the playback url dynamically mid-request
|
|
234
|
+
source: "ftts"
|
|
235
|
+
}, interaction.user);
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
|
|
188
239
|
***
|
|
189
240
|
|
|
241
|
+
|
|
190
242
|
# UpdateLog
|
|
191
243
|
|
|
192
244
|
|
|
@@ -202,8 +254,8 @@ client.lavalink = new LavalinkManager({
|
|
|
202
254
|
- `player.deleteSponsorBlock()` / `node.deleteSponsorBlock()`
|
|
203
255
|
- That Plugin adds following **Events** to the **Manager**: `"SegmentsLoaded"`, `"SegmentSkipped"`, `"ChapterStarted"`, `"ChaptersLoaded"`
|
|
204
256
|
- Example Bot show example in autoplayFunction how to "disable" / "enable" Autoplay with bot data variables.
|
|
205
|
-
- Added `ManagerOptions#emitNewSongsOnly`. If set to true, it won't emit "trackStart" Event, when track.loop is active, or the new current track == the previous (current) track.
|
|
206
|
-
- Added `ManagerOptions#linksBlacklist` which allows user to specify an array of regExp / strings to match query strings (for links / words) and if a match happens it doesn't allow the request (blacklist)
|
|
257
|
+
- Added `ManagerOptions#emitNewSongsOnly`. If set to true, it won't emit "trackStart" Event, when track.loop is active, or the new current track == the previous (current) track.
|
|
258
|
+
- Added `ManagerOptions#linksBlacklist` which allows user to specify an array of regExp / strings to match query strings (for links / words) and if a match happens it doesn't allow the request (blacklist)
|
|
207
259
|
- Added `ManagerOptions#linksWhitelist` which allows user to specify an array of regExp / strings to match query strings (for links only) and if a match does NOT HAPPEN it doesn't allow the request (whitelist)
|
|
208
260
|
- Added `ManagerOptions#linksAllowed` if set to false, it does not allow requests which are links
|
|
209
261
|
- Moved `ManaagerOptions#debugOptions` to `ManaagerOptions#advancedOptions.debugOptions`
|
|
@@ -211,10 +263,10 @@ client.lavalink = new LavalinkManager({
|
|
|
211
263
|
### **Version 1.2.1**
|
|
212
264
|
- Adjusted `player.stopPlaying()`
|
|
213
265
|
- There are now following parameters. `stopPlaying(clearQueue:boolean = true, executeAutoplay:boolean = false)`.
|
|
214
|
-
- On Default it now clears the queue and stops playing. Also it does not execute Autoplay on default. IF you want the function to behave differently, you can use the 2 states for that.
|
|
266
|
+
- On Default it now clears the queue and stops playing. Also it does not execute Autoplay on default. IF you want the function to behave differently, you can use the 2 states for that.
|
|
215
267
|
- Fixed that it looped the current track if repeatmode === "track" / "queue". (it stops playing and loop stays)
|
|
216
268
|
- Implemented a `parseLavalinkConnUrl(connectionUrl:string)` Util Function.
|
|
217
|
-
- It allows you to parse Lavalink Connection Data of a Lavalink Connection Url.
|
|
269
|
+
- It allows you to parse Lavalink Connection Data of a Lavalink Connection Url.
|
|
218
270
|
Pattern: `lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>`
|
|
219
271
|
- Note that the nodeId and NodeAuthorization must be encoded via encodeURIComponents before you provide it into the function.
|
|
220
272
|
- The function will return the following: `{ id: string, authorization: string, host: string, port: number }`
|
|
@@ -241,15 +293,15 @@ client.lavalink = new LavalinkManager({
|
|
|
241
293
|
|
|
242
294
|
# Node Resuming got supported
|
|
243
295
|
# First enable it by doing:
|
|
244
|
-
+ await player.node.
|
|
296
|
+
+ await player.node.updateSession(true, 360_000);
|
|
245
297
|
# then when reconnecting to the node add to the node.createeOptions the sessionId: "" of the previous session
|
|
246
298
|
# and after connecting the nodeManager.on("resumed", (node, payload, players) => {}) will be executed, where you can sync the players!
|
|
247
299
|
|
|
248
300
|
# Node Options got adjusted # It's a property not a method should be treated readonly
|
|
249
|
-
+ node.resuming: { enabled: boolean, timeout: number | null };
|
|
301
|
+
+ node.resuming: { enabled: boolean, timeout: number | null };
|
|
250
302
|
|
|
251
303
|
# Player function got added to stop playing without disconnecting
|
|
252
|
-
+ player.stopPlaying(clearQueue:boolean = true, executeAutoplay:boolean = false);
|
|
304
|
+
+ player.stopPlaying(clearQueue:boolean = true, executeAutoplay:boolean = false);
|
|
253
305
|
|
|
254
306
|
# Node functions for sponsorBlock Plugin (https://github.com/topi314/Sponsorblock-Plugin) got added
|
|
255
307
|
+ deleteSponsorBlock(player:Player)
|
|
@@ -269,7 +321,7 @@ client.lavalink = new LavalinkManager({
|
|
|
269
321
|
# Lavalink track.userData got added (basically same feature as my custom pluginInfo.clientData system)
|
|
270
322
|
# You only get the track.userData data through playerUpdate object
|
|
271
323
|
```
|
|
272
|
-
In one of the next updates, there will be more queueWatcher options and more custom nodeevents to trace
|
|
324
|
+
In one of the next updates, there will be more queueWatcher options and more custom nodeevents to trace
|
|
273
325
|
|
|
274
326
|
Most features of this update got tested, but if you encounter any bugs feel free to open an issue!
|
|
275
327
|
|
|
@@ -309,3 +361,52 @@ Most features of this update got tested, but if you encounter any bugs feel free
|
|
|
309
361
|
- Exporting events
|
|
310
362
|
- Added new debugOption: logCustomSearches
|
|
311
363
|
- *(Next version update i will remove the internal interval for position update, to calculations)*
|
|
364
|
+
|
|
365
|
+
## **Version 2.2.1**
|
|
366
|
+
- Player position is now calculated instead of using intervals
|
|
367
|
+
- Instaplayer fix update now requires quite good internet connection on the lavalink server due to removal of intervals for updating player.position (everything above 300mbps should be good)
|
|
368
|
+
- Internal updates for handling query params and url-requests (url-parsing) to fix quite few bugs and make the code more readable, now you don't have to ever provide stuff encoded via encodeURIComponent anymore.
|
|
369
|
+
- Added a bunch of jsdoc information, to make the autogenerated docs more accurate!
|
|
370
|
+
|
|
371
|
+
- Because of the adjustments from the encoding, you now need to pass url params for stuff like flowery tts like this:
|
|
372
|
+
|
|
373
|
+
```js
|
|
374
|
+
const query = interaction.options.getString("text");
|
|
375
|
+
const voice = interaction.options.getString("voice");
|
|
376
|
+
|
|
377
|
+
const extraParams = new URLSearchParams();
|
|
378
|
+
if(voice) extraParams.append(`voice`, voice);
|
|
379
|
+
|
|
380
|
+
// all params for flowertts can be found here: https://flowery.pw/docs
|
|
381
|
+
const response = await player.search({
|
|
382
|
+
query: `${query}`,
|
|
383
|
+
extraQueryUrlParams: extraParams, // as of my knowledge this is currently only used for flowertts, adjusting the playback url dynamically mid-request
|
|
384
|
+
source: "ftts"
|
|
385
|
+
}, interaction.user);
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
## **Version 2.2.2**
|
|
390
|
+
- Fixed a bug in player.pause() where when you pause the track longer than the left over currentTrack.info.duration is, then it would auto skip the track on resume.
|
|
391
|
+
- Fixed the handling of the previous track array ( sometimes it adds "null", due to lavalink errors )
|
|
392
|
+
- Added new functions for the queue, to make migrations and coding easier for beginners,
|
|
393
|
+
- ` const previousTrack = await player.queue.shiftPrevious() ` -> removes the previously played track from the player.queue.previous array, and returns it, so you can use it for something like "play previous"
|
|
394
|
+
- *Neat 1-liner: ` await player.queue.shiftPrevious().then(clientTrack => player.play({ clientTrack })) `*
|
|
395
|
+
- ` await player.queue.remove(removeQuery) ` -> Remove function to remove stuff from the queue.tracks array., following params are valid:
|
|
396
|
+
- Array of Tracks / UnresolvedTracks, e.g. ` await player.queue.remove( player.queue.tracks.slice(4, 10) ) ` *(would remove tracks from #4 (incl.) to #10 (excl.) aka those indexes: 4, 5, 6, 7, 8, 9 - this is how array.slice works)*
|
|
397
|
+
- Single Track / UnresolveTrack, e.g. ` await player.queue.remove(player.queue.tracks[player.queue.tracks.length - 1]); ` *(would remove the last track)*
|
|
398
|
+
- Array of track-indexes, e.g. ` await player.queue.remove([1, 4, 5]) ` *(Would remove track #1, #4 and #5)*
|
|
399
|
+
- Single track index, e.g. ` await player.queue.remove(5) ` *(would remove the #5 track from the queue)*
|
|
400
|
+
- **NOTE:** I still highly recommend, to use the ` player.queue.splice() ` function for mutating the queue:
|
|
401
|
+
- it is possible to remove single tracks, multiple tracks and insert tracks at specific positions!
|
|
402
|
+
- *the remove function haven't been fully tested yet*
|
|
403
|
+
- Added `track.pluginInfo.clientData?.previousTrack` handling:
|
|
404
|
+
- If a track has this property in the pluginInfo in the clientData object set to "true" then it won't get added to the previous track array. Example:
|
|
405
|
+
```js
|
|
406
|
+
const previousTrack = await player.queue.shiftPrevious();
|
|
407
|
+
if(previousTrack) {
|
|
408
|
+
const previousClientData = previousTrack.pluginInfo.clientData || {};
|
|
409
|
+
previousTrack.pluginInfo.clientData = { previousTrack: true, ...previousClientData }
|
|
410
|
+
await player.play({ clientTrack: previousTrack });
|
|
411
|
+
}
|
|
412
|
+
```
|
|
@@ -7,7 +7,7 @@ export declare class FilterManager {
|
|
|
7
7
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
8
8
|
equalizerBands: EQBand[];
|
|
9
9
|
/** Private Util for the instaFix Filters option */
|
|
10
|
-
filterUpdatedState:
|
|
10
|
+
filterUpdatedState: boolean;
|
|
11
11
|
/** All "Active" / "disabled" Player Filters */
|
|
12
12
|
filters: PlayerFilters;
|
|
13
13
|
/** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
|
|
@@ -8,7 +8,7 @@ class FilterManager {
|
|
|
8
8
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
9
9
|
equalizerBands = [];
|
|
10
10
|
/** Private Util for the instaFix Filters option */
|
|
11
|
-
filterUpdatedState =
|
|
11
|
+
filterUpdatedState = false;
|
|
12
12
|
/** All "Active" / "disabled" Player Filters */
|
|
13
13
|
filters = {
|
|
14
14
|
volume: false,
|
|
@@ -78,9 +78,9 @@ class FilterManager {
|
|
|
78
78
|
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
79
79
|
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
80
80
|
},
|
|
81
|
-
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
81
|
+
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
82
82
|
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
83
|
-
// "adaptive": true // false
|
|
83
|
+
// "adaptive": true // false
|
|
84
84
|
},
|
|
85
85
|
"echo": { // Self-explanatory; provides an echo effect.
|
|
86
86
|
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
@@ -160,6 +160,8 @@ class FilterManager {
|
|
|
160
160
|
delete sendData[key];
|
|
161
161
|
}
|
|
162
162
|
const now = performance.now();
|
|
163
|
+
if (this.player.options.instaUpdateFiltersFix === true)
|
|
164
|
+
this.filterUpdatedState = true;
|
|
163
165
|
await this.player.node.updatePlayer({
|
|
164
166
|
guildId: this.player.guildId,
|
|
165
167
|
playerOptions: {
|
|
@@ -167,8 +169,6 @@ class FilterManager {
|
|
|
167
169
|
}
|
|
168
170
|
});
|
|
169
171
|
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
170
|
-
if (this.player.options.instaUpdateFiltersFix === true)
|
|
171
|
-
this.filterUpdatedState = 1;
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
@@ -253,9 +253,9 @@ class FilterManager {
|
|
|
253
253
|
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
254
254
|
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
255
255
|
},
|
|
256
|
-
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
256
|
+
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
257
257
|
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
258
|
-
// "adaptive": true // false
|
|
258
|
+
// "adaptive": true // false
|
|
259
259
|
},
|
|
260
260
|
"echo": { // Self-explanatory; provides an echo effect.
|
|
261
261
|
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
@@ -654,6 +654,8 @@ class FilterManager {
|
|
|
654
654
|
if (!this.player.node.sessionId)
|
|
655
655
|
throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
656
656
|
const now = performance.now();
|
|
657
|
+
if (this.player.options.instaUpdateFiltersFix === true)
|
|
658
|
+
this.filterUpdatedState = true;
|
|
657
659
|
await this.player.node.updatePlayer({
|
|
658
660
|
guildId: this.player.guildId,
|
|
659
661
|
playerOptions: {
|
|
@@ -661,8 +663,6 @@ class FilterManager {
|
|
|
661
663
|
}
|
|
662
664
|
});
|
|
663
665
|
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
664
|
-
if (this.player.options.instaUpdateFiltersFix === true)
|
|
665
|
-
this.filterUpdatedState = 1;
|
|
666
666
|
return this;
|
|
667
667
|
}
|
|
668
668
|
/** Clears the equalizer bands. */
|
|
@@ -6,6 +6,7 @@ import { DestroyReasonsType, Player, PlayerJson, PlayerOptions } from "./Player"
|
|
|
6
6
|
import { ManagerQueueOptions } from "./Queue";
|
|
7
7
|
import { Track, UnresolvedTrack } from "./Track";
|
|
8
8
|
import { ChannelDeletePacket, GuildShardPayload, ManagerUtils, MiniMap, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent } from "./Utils";
|
|
9
|
+
/** How the botclient is allowed to be structured */
|
|
9
10
|
export interface BotClientOptions {
|
|
10
11
|
/** Bot Client Id */
|
|
11
12
|
id: string;
|
|
@@ -14,6 +15,7 @@ export interface BotClientOptions {
|
|
|
14
15
|
/** So users can pass entire objects / classes */
|
|
15
16
|
[x: string | number | symbol]: unknown;
|
|
16
17
|
}
|
|
18
|
+
/** Sub Manager Options, for player specific things */
|
|
17
19
|
export interface ManagerPlayerOptions {
|
|
18
20
|
/** If the Lavalink Volume should be decremented by x number */
|
|
19
21
|
volumeDecrementer?: number;
|
|
@@ -39,6 +41,7 @@ export interface ManagerPlayerOptions {
|
|
|
39
41
|
};
|
|
40
42
|
useUnresolvedData?: boolean;
|
|
41
43
|
}
|
|
44
|
+
/** Manager Options used to create the manager */
|
|
42
45
|
export interface ManagerOptions {
|
|
43
46
|
/** The Node Options, for all Nodes! (on init) */
|
|
44
47
|
nodes: LavalinkNodeOptions[];
|
|
@@ -64,6 +67,8 @@ export interface ManagerOptions {
|
|
|
64
67
|
linksAllowed?: boolean;
|
|
65
68
|
/** Advanced Options for the Library, which may or may not be "library breaking" */
|
|
66
69
|
advancedOptions?: {
|
|
70
|
+
/** Max duration for that the filter fix duration works (in ms) - default is 8mins */
|
|
71
|
+
maxFilterFixDuration?: number;
|
|
67
72
|
/** optional */
|
|
68
73
|
debugOptions?: {
|
|
69
74
|
/** For logging custom searches */
|
|
@@ -90,7 +95,7 @@ export interface LavalinkManagerEvents {
|
|
|
90
95
|
* Emitted when a Track finished.
|
|
91
96
|
* @event Manager#trackEnd
|
|
92
97
|
*/
|
|
93
|
-
"trackEnd": (player: Player, track: Track, payload: TrackEndEvent) => void;
|
|
98
|
+
"trackEnd": (player: Player, track: Track | null, payload: TrackEndEvent) => void;
|
|
94
99
|
/**
|
|
95
100
|
* Emitted when a Track got stuck while playing.
|
|
96
101
|
* @event Manager#trackStuck
|
|
@@ -105,7 +110,7 @@ export interface LavalinkManagerEvents {
|
|
|
105
110
|
* Emitted when the Playing finished and no more tracks in the queue.
|
|
106
111
|
* @event Manager#queueEnd
|
|
107
112
|
*/
|
|
108
|
-
"queueEnd": (player: Player, track: Track, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
|
|
113
|
+
"queueEnd": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
|
|
109
114
|
/**
|
|
110
115
|
* Emitted when a Player is created.
|
|
111
116
|
* @event Manager#playerCreate
|
|
@@ -142,28 +147,28 @@ export interface LavalinkManagerEvents {
|
|
|
142
147
|
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
|
|
143
148
|
* @event Manager#trackError
|
|
144
149
|
*/
|
|
145
|
-
"SegmentsLoaded": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockSegmentsLoaded) => void;
|
|
150
|
+
"SegmentsLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentsLoaded) => void;
|
|
146
151
|
/**
|
|
147
152
|
* SPONSORBLOCK-PLUGIN EVENT
|
|
148
153
|
* Emitted when a specific Segment was skipped
|
|
149
154
|
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentskipped
|
|
150
155
|
* @event Manager#trackError
|
|
151
156
|
*/
|
|
152
|
-
"SegmentSkipped": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockSegmentSkipped) => void;
|
|
157
|
+
"SegmentSkipped": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentSkipped) => void;
|
|
153
158
|
/**
|
|
154
159
|
* SPONSORBLOCK-PLUGIN EVENT
|
|
155
160
|
* Emitted when a specific Chapter starts playing
|
|
156
161
|
* @link https://github.com/topi314/Sponsorblock-Plugin#chapterstarted
|
|
157
162
|
* @event Manager#trackError
|
|
158
163
|
*/
|
|
159
|
-
"ChapterStarted": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockChapterStarted) => void;
|
|
164
|
+
"ChapterStarted": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChapterStarted) => void;
|
|
160
165
|
/**
|
|
161
166
|
* SPONSORBLOCK-PLUGIN EVENT
|
|
162
167
|
* Emitted when Chapters are loaded
|
|
163
168
|
* @link https://github.com/topi314/Sponsorblock-Plugin#chaptersloaded
|
|
164
169
|
* @event Manager#trackError
|
|
165
170
|
*/
|
|
166
|
-
"ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack, payload: SponsorBlockChaptersLoaded) => void;
|
|
171
|
+
"ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
|
|
167
172
|
}
|
|
168
173
|
export interface LavalinkManager {
|
|
169
174
|
/** @private */
|
|
@@ -239,6 +244,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
239
244
|
* linksBlacklist: [],
|
|
240
245
|
* linksWhitelist: [],
|
|
241
246
|
* advancedOptions: {
|
|
247
|
+
* maxFilterFixDuration: 600_000,
|
|
242
248
|
* debugOptions: {
|
|
243
249
|
* noAudio: false,
|
|
244
250
|
* playerDestroy: {
|
|
@@ -309,10 +315,22 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
309
315
|
* Delete's a player from the cache without destroying it on lavalink (only works when it's disconnected)
|
|
310
316
|
* @param guildId
|
|
311
317
|
* @returns
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* client.lavalink.deletePlayer(interaction.guildId);
|
|
322
|
+
* // shouldn't be used except you know what you are doing.
|
|
323
|
+
* ```
|
|
312
324
|
*/
|
|
313
325
|
deletePlayer(guildId: string): boolean;
|
|
314
326
|
/**
|
|
315
327
|
* Checks wether the the lib is useable based on if any node is connected
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* if(!client.lavalink.useable) return console.error("can'T search yet, because there is no useable lavalink node.")
|
|
332
|
+
* // continue with code e.g. createing a player and searching
|
|
333
|
+
* ```
|
|
316
334
|
*/
|
|
317
335
|
get useable(): boolean;
|
|
318
336
|
/**
|
|
@@ -320,7 +338,6 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
320
338
|
* @param clientData
|
|
321
339
|
*
|
|
322
340
|
* @example
|
|
323
|
-
*
|
|
324
341
|
* ```ts
|
|
325
342
|
* // on the bot ready event
|
|
326
343
|
* client.on("ready", () => {
|
|
@@ -58,6 +58,7 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
58
58
|
queueStore: options?.queueOptions?.queueStore ?? new Queue_1.DefaultQueueStore(),
|
|
59
59
|
},
|
|
60
60
|
advancedOptions: {
|
|
61
|
+
maxFilterFixDuration: options?.advancedOptions?.maxFilterFixDuration ?? 600000,
|
|
61
62
|
debugOptions: {
|
|
62
63
|
logCustomSearches: options?.advancedOptions?.debugOptions?.logCustomSearches ?? false,
|
|
63
64
|
noAudio: options?.advancedOptions?.debugOptions?.noAudio ?? false,
|
|
@@ -150,6 +151,7 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
150
151
|
* linksBlacklist: [],
|
|
151
152
|
* linksWhitelist: [],
|
|
152
153
|
* advancedOptions: {
|
|
154
|
+
* maxFilterFixDuration: 600_000,
|
|
153
155
|
* debugOptions: {
|
|
154
156
|
* noAudio: false,
|
|
155
157
|
* playerDestroy: {
|
|
@@ -244,12 +246,18 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
244
246
|
* Delete's a player from the cache without destroying it on lavalink (only works when it's disconnected)
|
|
245
247
|
* @param guildId
|
|
246
248
|
* @returns
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* client.lavalink.deletePlayer(interaction.guildId);
|
|
253
|
+
* // shouldn't be used except you know what you are doing.
|
|
254
|
+
* ```
|
|
247
255
|
*/
|
|
248
256
|
deletePlayer(guildId) {
|
|
249
257
|
const oldPlayer = this.getPlayer(guildId);
|
|
250
258
|
if (!oldPlayer)
|
|
251
259
|
return;
|
|
252
|
-
// oldPlayer.connected is operational. you could also do oldPlayer.voice?.token
|
|
260
|
+
// oldPlayer.connected is operational. you could also do oldPlayer.voice?.token
|
|
253
261
|
if (oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
254
262
|
if (!this.options?.advancedOptions?.debugOptions?.playerDestroy?.dontThrowError)
|
|
255
263
|
throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${JSON.stringify(oldPlayer.toJSON?.())}`);
|
|
@@ -260,6 +268,12 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
260
268
|
}
|
|
261
269
|
/**
|
|
262
270
|
* Checks wether the the lib is useable based on if any node is connected
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* if(!client.lavalink.useable) return console.error("can'T search yet, because there is no useable lavalink node.")
|
|
275
|
+
* // continue with code e.g. createing a player and searching
|
|
276
|
+
* ```
|
|
263
277
|
*/
|
|
264
278
|
get useable() {
|
|
265
279
|
return this.nodeManager.nodes.filter(v => v.connected).size > 0;
|
|
@@ -269,7 +283,6 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
269
283
|
* @param clientData
|
|
270
284
|
*
|
|
271
285
|
* @example
|
|
272
|
-
*
|
|
273
286
|
* ```ts
|
|
274
287
|
* // on the bot ready event
|
|
275
288
|
* client.on("ready", () => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
|
|
2
|
+
/** Default Sources Record, to allow source parsing with multiple inputs. */
|
|
2
3
|
export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
|
|
4
|
+
/** Lavalink Plugins definiton */
|
|
3
5
|
export declare const LavalinkPlugins: {
|
|
4
6
|
DuncteBot_Plugin: string;
|
|
5
7
|
LavaSrc: string;
|
|
@@ -7,4 +9,5 @@ export declare const LavalinkPlugins: {
|
|
|
7
9
|
LavaSearch: string;
|
|
8
10
|
LavalinkFilterPlugin: string;
|
|
9
11
|
};
|
|
12
|
+
/** Lavalink Sources regexes for url validations */
|
|
10
13
|
export declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SourceLinksRegexes = exports.LavalinkPlugins = exports.DefaultSources = void 0;
|
|
4
|
+
/** Default Sources Record, to allow source parsing with multiple inputs. */
|
|
4
5
|
exports.DefaultSources = {
|
|
5
6
|
// youtubemusic
|
|
6
7
|
"youtube music": "ytmsearch",
|
|
@@ -25,7 +26,7 @@ exports.DefaultSources = {
|
|
|
25
26
|
"am": "amsearch",
|
|
26
27
|
"musicapple": "amsearch",
|
|
27
28
|
"music apple": "amsearch",
|
|
28
|
-
// spotify
|
|
29
|
+
// spotify
|
|
29
30
|
"spotify": "spsearch",
|
|
30
31
|
"spsearch": "spsearch",
|
|
31
32
|
"sp": "spsearch",
|
|
@@ -66,6 +67,7 @@ exports.DefaultSources = {
|
|
|
66
67
|
"link": "link",
|
|
67
68
|
"uri": "uri"
|
|
68
69
|
};
|
|
70
|
+
/** Lavalink Plugins definiton */
|
|
69
71
|
exports.LavalinkPlugins = {
|
|
70
72
|
DuncteBot_Plugin: "DuncteBot-plugin",
|
|
71
73
|
LavaSrc: "lavasrc-plugin",
|
|
@@ -73,6 +75,7 @@ exports.LavalinkPlugins = {
|
|
|
73
75
|
LavaSearch: "lavasearch-plugin",
|
|
74
76
|
LavalinkFilterPlugin: "lavalink-filter-plugin"
|
|
75
77
|
};
|
|
78
|
+
/** Lavalink Sources regexes for url validations */
|
|
76
79
|
exports.SourceLinksRegexes = {
|
|
77
80
|
/** DEFAULT SUPPORTED BY LAVALINK */
|
|
78
81
|
YoutubeRegex: /https?:\/\/?(?:www\.)?(?:(m|www)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|shorts|playlist\?|watch\?v=|watch\?.+(?:&|&);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&)index=((?:\d){1,3}))?(?:(?:\?|&|&)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?/,
|