lavalink-client 2.7.0 → 2.7.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/dist/index.d.mts CHANGED
@@ -1,1122 +1,416 @@
1
1
  import { EventEmitter } from 'events';
2
2
 
3
- /** The Audio Outputs type */
4
- type AudioOutputs = "mono" | "stereo" | "left" | "right";
5
- /** The "active" / "disabled" Player Filters */
6
- interface PlayerFilters {
7
- /** Sets nightcore to false, and vaporwave to false */
8
- custom: boolean;
9
- /** Sets custom to false, and vaporwave to false */
10
- nightcore: boolean;
11
- /** Sets custom to false, and nightcore to false */
12
- vaporwave: boolean;
13
- /** If rotation filter is enabled / not */
14
- rotation: boolean;
15
- /** if karaoke filter is enabled / not */
16
- karaoke: boolean;
17
- /** if tremolo filter is enabled / not */
18
- tremolo: boolean;
19
- /** if vibrato filter is enabled / not */
20
- vibrato: boolean;
21
- lowPass: boolean;
22
- /** audio Output (default stereo, mono sounds the fullest and best for not-stereo tracks) */
23
- audioOutput: AudioOutputs;
24
- /** Lavalink Volume FILTER (not player Volume, think of it as a gain booster) */
25
- volume: boolean;
26
- /** Filters for the Lavalink Filter Plugin */
27
- lavalinkFilterPlugin: {
28
- /** if echo filter is enabled / not */
29
- echo: boolean;
30
- /** if reverb filter is enabled / not */
31
- reverb: boolean;
32
- };
33
- lavalinkLavaDspxPlugin: {
34
- /** if lowPass filter is enabled / not */
35
- lowPass: boolean;
36
- /** if highPass filter is enabled / not */
37
- highPass: boolean;
38
- /** if normalization filter is enabled / not */
39
- normalization: boolean;
40
- /** if echo filter is enabled / not */
41
- echo: boolean;
42
- };
43
- }
44
- /**
45
- * There are 15 bands (0-14) that can be changed.
46
- * "gain" is the multiplier for the given band.
47
- * The default value is 0.
48
- * Valid values range from -0.25 to 1.0, where -0.25 means the given band is completely muted, and 0.25 means it is doubled.
49
- * Modifying the gain could also change the volume of the output.
50
- */
51
- interface EQBand {
52
- /** On what band position (0-14) it should work */
53
- band: IntegerNumber | number;
54
- /** The gain (-0.25 to 1.0) */
55
- gain: FloatNumber | number;
56
- }
57
- /**
58
- * Uses equalization to eliminate part of a band, usually targeting vocals.
59
- */
60
- interface KaraokeFilter {
61
- /** The level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
62
- level?: number;
63
- /** The mono level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
64
- monoLevel?: number;
65
- /** The filter band (in Hz) */
66
- filterBand?: number;
67
- /** The filter width */
68
- filterWidth?: number;
69
- }
70
- /**
71
- * Changes the speed, pitch, and rate
72
- */
73
- interface TimescaleFilter {
74
- /** The playback speed 0.0 ≤ x */
75
- speed?: number;
76
- /** The pitch 0.0 ≤ x */
77
- pitch?: number;
78
- /** The rate 0.0 ≤ x */
79
- rate?: number;
80
- }
81
- /**
82
- * Uses amplification to create a shuddering effect, where the volume quickly oscillates.
83
- * Demo: https://en.wikipedia.org/wiki/File:Fuse_Electronics_Tremolo_MK-III_Quick_Demo.ogv
84
- */
85
- interface TremoloFilter {
86
- /** The frequency 0.0 < x */
87
- frequency?: number;
88
- /** The tremolo depth 0.0 < x ≤ 1.0 */
89
- depth?: number;
90
- }
91
- /**
92
- * Similar to tremolo. While tremolo oscillates the volume, vibrato oscillates the pitch.
93
- */
94
- interface VibratoFilter {
95
- /** The frequency 0.0 < x ≤ 14.0 */
96
- frequency?: number;
97
- /** The vibrato depth 0.0 < x ≤ 1.0 */
98
- depth?: number;
99
- }
100
- /**
101
- * Rotates the sound around the stereo channels/user headphones (aka Audio Panning).
102
- * It can produce an effect similar to https://youtu.be/QB9EB8mTKcc (without the reverb).
103
- */
104
- interface RotationFilter {
105
- /** The frequency of the audio rotating around the listener in Hz. 0.2 is similar to the example video above */
106
- rotationHz?: number;
107
- }
108
- /**
109
- * Distortion effect. It can generate some pretty unique audio effects.
110
- */
111
- interface DistortionFilter {
112
- sinOffset?: number;
113
- sinScale?: number;
114
- cosOffset?: number;
115
- cosScale?: number;
116
- tanOffset?: number;
117
- tanScale?: number;
118
- offset?: number;
119
- scale?: number;
120
- }
121
- /**
122
- * Mixes both channels (left and right), with a configurable factor on how much each channel affects the other.
123
- * With the defaults, both channels are kept independent of each other.
124
- * Setting all factors to 0.5 means both channels get the same audio.
125
- */
126
- interface ChannelMixFilter {
127
- /** The left to left channel mix factor (0.0 ≤ x ≤ 1.0) */
128
- leftToLeft?: number;
129
- /** The left to right channel mix factor (0.0 ≤ x ≤ 1.0) */
130
- leftToRight?: number;
131
- /** The right to left channel mix factor (0.0 ≤ x ≤ 1.0) */
132
- rightToLeft?: number;
133
- /** The right to right channel mix factor (0.0 ≤ x ≤ 1.0) */
134
- rightToRight?: number;
135
- }
136
- /**
137
- * Higher frequencies get suppressed, while lower frequencies pass through this filter, thus the name low pass.
138
- * Any smoothing values equal to or less than 1.0 will disable the filter.
139
- */
140
- interface LowPassFilter {
141
- /** The smoothing factor (1.0 < x) */
142
- smoothing?: number;
143
- }
144
- /**
145
- * Filter Data stored in the Client and partially sent to Lavalink
146
- */
147
- interface FilterData {
148
- volume?: number;
149
- karaoke?: KaraokeFilter;
150
- timescale?: TimescaleFilter;
151
- tremolo?: TremoloFilter;
152
- vibrato?: VibratoFilter;
153
- rotation?: RotationFilter;
154
- distortion?: DistortionFilter;
155
- channelMix?: ChannelMixFilter;
156
- lowPass?: LowPassFilter;
157
- pluginFilters?: {
158
- "lavalink-filter-plugin"?: {
159
- "echo"?: {
160
- delay?: number;
161
- decay?: number;
162
- };
163
- "reverb"?: {
164
- delays?: number[];
165
- gains?: number[];
166
- };
167
- };
168
- "high-pass"?: {
169
- cutoffFrequency?: number;
170
- boostFactor?: number;
171
- };
172
- "low-pass"?: {
173
- cutoffFrequency?: number;
174
- boostFactor?: number;
175
- };
176
- normalization?: {
177
- maxAmplitude?: number;
178
- adaptive?: boolean;
179
- };
180
- echo?: {
181
- echoLength?: number;
182
- decay?: number;
183
- };
184
- };
185
- }
186
- /**
187
- * Actual Filter Data sent to Lavalink
188
- */
189
- interface LavalinkFilterData extends FilterData {
190
- equalizer?: EQBand[];
191
- }
192
-
193
- /**
194
- * Debug events for more detailed logging
195
- */
196
- declare enum DebugEvents {
197
- SetSponsorBlock = "SetSponsorBlock",
198
- DeleteSponsorBlock = "DeleteSponsorBlock",
199
- TrackEndReplaced = "TrackEndReplaced",
200
- AutoplayExecution = "AutoplayExecution",
201
- AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
202
- AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
203
- TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
204
- QueueEnded = "QueueEnded",
205
- TrackStartNewSongsOnly = "TrackStartNewSongsOnly",
206
- TrackStartNoTrack = "TrackStartNoTrack",
207
- ResumingFetchingError = "ResumingFetchingError",
208
- PlayerUpdateNoPlayer = "PlayerUpdateNoPlayer",
209
- PlayerUpdateFilterFixApply = "PlayerUpdateFilterFixApply",
210
- PlayerUpdateSuccess = "PlayerUpdateSuccess",
211
- HeartBeatTriggered = "HeartBeatTriggered",
212
- NoSocketOnDestroy = "NoSocketOnDestroy",
213
- SocketCleanupError = "SocketCleanupError",
214
- SocketTerminateHeartBeatTimeout = "SocketTerminateHeartBeatTimeout",
215
- TryingConnectWhileConnected = "TryingConnectWhileConnected",
216
- LavaSearchNothingFound = "LavaSearchNothingFound",
217
- SearchNothingFound = "SearchNothingFound",
218
- ValidatingBlacklistLinks = "ValidatingBlacklistLinks",
219
- ValidatingWhitelistLinks = "ValidatingWhitelistLinks",
220
- TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
221
- TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime",
222
- PlayerDestroyingSomewhereElse = "PlayerDestroyingSomewhereElse",
223
- PlayerCreateNodeNotFound = "PlayerCreateNodeNotFound",
224
- PlayerPlayQueueEmptyTimeoutClear = "PlayerPlayQueueEmptyTimeoutClear",
225
- PlayerPlayWithTrackReplace = "PlayerPlayWithTrackReplace",
226
- PlayerPlayUnresolvedTrack = "PlayerPlayUnresolvedTrack",
227
- PlayerPlayUnresolvedTrackFailed = "PlayerPlayUnresolvedTrackFailed",
228
- PlayerVolumeAsFilter = "PlayerVolumeAsFilter",
229
- BandcampSearchLokalEngine = "BandcampSearchLokalEngine",
230
- PlayerChangeNode = "PlayerChangeNode",
231
- BuildTrackError = "BuildTrackError",
232
- TransformRequesterFunctionFailed = "TransformRequesterFunctionFailed",
233
- GetClosestTrackFailed = "GetClosestTrackFailed",
234
- PlayerDeleteInsteadOfDestroy = "PlayerDeleteInsteadOfDestroy",
235
- FailedToConnectToNodes = "FailedToConnectToNodes",
236
- NoAudioDebug = "NoAudioDebug",
237
- PlayerAutoReconnect = "PlayerAutoReconnect"
238
- }
239
- /**
240
- * Reasons why a player got destroyed
241
- */
242
- declare enum DestroyReasons {
243
- QueueEmpty = "QueueEmpty",
244
- NodeDestroy = "NodeDestroy",
245
- NodeDeleted = "NodeDeleted",
246
- LavalinkNoVoice = "LavalinkNoVoice",
247
- NodeReconnectFail = "NodeReconnectFail",
248
- Disconnected = "Disconnected",
249
- PlayerReconnectFail = "PlayerReconnectFail",
250
- PlayerChangeNodeFail = "PlayerChangeNodeFail",
251
- PlayerChangeNodeFailNoEligibleNode = "PlayerChangeNodeFailNoEligibleNode",
252
- ChannelDeleted = "ChannelDeleted",
253
- DisconnectAllNodes = "DisconnectAllNodes",
254
- ReconnectAllNodes = "ReconnectAllNodes",
255
- TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
256
- TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
257
- }
258
- /**
259
- * Reasons why a player got disconnected
260
- */
261
- declare enum DisconnectReasons {
262
- Disconnected = "Disconnected",
263
- DisconnectAllNodes = "DisconnectAllNodes"
264
- }
265
- /** The valid SponsorBlock categories */
266
- declare const validSponsorBlocks: string[];
267
- /** The audio Outputs Data map declaration */
268
- declare const audioOutputsData: Record<AudioOutputs, ChannelMixFilter>;
269
- /** Equalizer Presets */
270
- declare const EQList: {
271
- /** A Bassboost Equalizer, so high it distorts the audio */
272
- BassboostEarrape: EQBand[];
273
- /** A High and decent Bassboost Equalizer */
274
- BassboostHigh: EQBand[];
275
- /** A decent Bassboost Equalizer */
276
- BassboostMedium: EQBand[];
277
- /** A slight Bassboost Equalizer */
278
- BassboostLow: EQBand[];
279
- /** Makes the Music slightly "better" */
280
- BetterMusic: EQBand[];
281
- /** Makes the Music sound like rock music / sound rock music better */
282
- Rock: EQBand[];
283
- /** Makes the Music sound like Classic music / sound Classic music better */
284
- Classic: EQBand[];
285
- /** Makes the Music sound like Pop music / sound Pop music better */
286
- Pop: EQBand[];
287
- /** Makes the Music sound like Electronic music / sound Electronic music better */
288
- Electronic: EQBand[];
289
- /** Boosts all Bands slightly for louder and fuller sound */
290
- FullSound: EQBand[];
291
- /** Boosts basses + lower highs for a pro gaming sound */
292
- Gaming: EQBand[];
293
- };
294
-
295
- declare class FilterManager {
296
- static EQList: {
297
- BassboostEarrape: EQBand[];
298
- BassboostHigh: EQBand[];
299
- BassboostMedium: EQBand[];
300
- BassboostLow: EQBand[];
301
- BetterMusic: EQBand[];
302
- Rock: EQBand[];
303
- Classic: EQBand[];
304
- Pop: EQBand[];
305
- Electronic: EQBand[];
306
- FullSound: EQBand[];
307
- Gaming: EQBand[];
308
- };
309
- /** The Equalizer bands currently applied to the Lavalink Server */
310
- equalizerBands: EQBand[];
311
- /** Private Util for the instaFix Filters option */
312
- filterUpdatedState: boolean;
313
- /** All "Active" / "disabled" Player Filters */
314
- filters: PlayerFilters;
315
- /** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
316
- data: FilterData;
317
- /** The Player assigned to this Filter Manager */
318
- player: Player;
319
- /** The Constructor for the FilterManager */
320
- constructor(player: Player);
321
- /**
322
- * Apply Player filters for lavalink filter sending data, if the filter is enabled / not
323
- *
324
- * @returns {Promise<void>}
325
- *
326
- * @example
327
- * ```ts
328
- * // Apply the filters after changing them manually:
329
- * player.filterManager.data.volume = 0.5;
330
- * // maybe you wanna manually set a distorition filter? then do it like this...
331
- * player.filterManager.data.distortion = { sinOffset: 0.5, sinScale: 2, cosOffset: 0.5, cosScale: 2, tanOffset: 0.5, tanScale: 2, offset: 0.5, scale: 2 };
332
- * await player.filterManager.applyPlayerFilters();
333
- * ```
334
- */
335
- applyPlayerFilters(): Promise<void>;
336
- privateNot0(value: number | undefined): boolean;
337
- /**
338
- * Checks if the filters are correctly stated (active / not-active) - mostly used internally.
339
- * @param oldFilterTimescale
340
- * @returns {boolean} True, if the check was successfull
341
- *
342
- * @example
343
- * ```ts
344
- * // Check the filter states
345
- * player.filterManager.checkFiltersState();
346
- * // Apply the filters after checking
347
- * await player.filterManager.applyPlayerFilters();
348
- * ```
349
- */
350
- checkFiltersState(oldFilterTimescale?: Partial<TimescaleFilter>): boolean;
351
- /**
352
- * Reset all Filters
353
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
354
- *
355
- * @example
356
- * ```ts
357
- * // Reset all filters
358
- * await player.filterManager.resetFilters();
359
- * ```
360
- */
361
- resetFilters(): Promise<FilterManager>;
362
- /**
363
- * Set the Filter Volume
364
- * @param volume the volume (0.0 - 5.0)
365
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
366
- *
367
- * @example
368
- * ```ts
369
- * // Set Volume to 50%
370
- * await player.filterManager.setVolume(0.5);
371
- * // note this is a filter, so it will "jump" to the volume, i think it's like a "volume boost effect" so i marketed it as a filter
372
- * ```
373
- */
374
- setVolume(volume: number): Promise<this>;
375
- /**
376
- * Set the AudioOutput Filter
377
- * @param {AudioOutputs} type the audio output type
378
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
379
- *
380
- * @example
381
- * ```ts
382
- * // Set Audio Output to Mono
383
- * await player.filterManager.setAudioOutput("mono");
384
- *
385
- * // Set Audio Output to Stereo
386
- * await player.filterManager.setAudioOutput("stereo");
387
- *
388
- * // Set Audio Output to Left
389
- * await player.filterManager.setAudioOutput("left");
390
- *
391
- * // Set Audio Output to Right
392
- * await player.filterManager.setAudioOutput("right");
393
- * ```
394
- */
395
- setAudioOutput(type: AudioOutputs): Promise<FilterManager>;
396
- /**
397
- * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
398
- * @param {number} speed set the speed of the filter
399
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
400
- *
401
- * @example
402
- * ```ts
403
- * // Set Speed to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
404
- * await player.filterManager.setSpeed(1.25);
405
- * ```
406
- */
407
- setSpeed(speed?: number): Promise<FilterManager>;
408
- /**
409
- * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
410
- * @param {number} pitch set the pitch of the filter
411
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
412
- *
413
- * @example
414
- * ```ts
415
- * // Set Pitch to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
416
- * await player.filterManager.setPitch(1.25);
417
- * ```
418
- */
419
- setPitch(pitch?: number): Promise<FilterManager>;
420
- /**
421
- * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
422
- * @param {number} rate set the rate of the filter
423
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
424
- *
425
- * @example
426
- * ```ts
427
- * // Set Rate to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
428
- * await player.filterManager.setRate(1.25);
429
- * ```
430
- */
431
- setRate(rate?: number): Promise<FilterManager>;
432
- /**
433
- * Enables / Disables the rotation effect, (Optional: provide your Own Data)
434
- * @param {number} rotationHz set the rotationHz of the filter
435
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
436
- *
437
- * @example
438
- * ```ts
439
- * // Toggle Rotation filter with custom settings
440
- * await player.filterManager.toggleRotation(0.4);
441
- * // or use the defaults
442
- * await player.filterManager.toggleRotation();
443
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
444
- * ```
445
- */
446
- toggleRotation(rotationHz?: number): Promise<FilterManager>;
447
- /**
448
- * Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
449
- * @param {number} frequency set the frequency of the filter
450
- * @param {number} depth set the depth of the filter
451
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
452
- *
453
- * @example
454
- * ```ts
455
- * // Toggle Vibrato filter with custom settings
456
- * await player.filterManager.toggleVibrato(8, 0.5);
457
- * // or use the defaults
458
- * await player.filterManager.toggleVibrato();
459
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
460
- * ```
461
- */
462
- toggleVibrato(frequency?: number, depth?: number): Promise<FilterManager>;
463
- /**
464
- * Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
465
- * @param {number} frequency set the frequency of the filter
466
- * @param {number} depth set the depth of the filter
467
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
468
- *
469
- * @example
470
- * ```ts
471
- * // Toggle Tremolo filter with custom settings
472
- * await player.filterManager.toggleTremolo(5, 0.7);
473
- * // or use the defaults
474
- * await player.filterManager.toggleTremolo();
475
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
476
- * ```
477
- */
478
- toggleTremolo(frequency?: number, depth?: number): Promise<FilterManager>;
479
- /**
480
- * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
481
- * @param {number} smoothing set the smoothing of the filter
482
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
483
- *
484
- * @example
485
- * ```ts
486
- * // Toggle LowPass filter with custom settings
487
- * await player.filterManager.toggleLowPass(30);
488
- * // or use the defaults
489
- * await player.filterManager.toggleLowPass();
490
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
491
- * ```
492
- */
493
- toggleLowPass(smoothing?: number): Promise<FilterManager>;
494
- /**
495
- * Lavalink LavaDspx Plugin Filters
496
- */
497
- lavalinkLavaDspxPlugin: {
498
- /**
499
- * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
500
- * @param {number} boostFactor set the boost factor of the filter
501
- * @param {number} cutoffFrequency set the cutoff frequency of the filter
502
- * @returns {Promise<boolean>} the state of the filter after execution.
503
- *
504
- * @example
505
- * ```ts
506
- * // Toggle LowPass filter with custom settings
507
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(1.2, 300);
508
- * // or use the defaults
509
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass();
510
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
511
- * ```
512
- */
513
- toggleLowPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<FilterManager>;
514
- /**
515
- * Enables / Disables the HighPass effect, (Optional: provide your Own Data)
516
- * @param {number} boostFactor [] set the boost factor of the filter
517
- * @param {number} cutoffFrequency set the cutoff frequency of the filter
518
- * @returns {Promise<boolean>} the state of the filter after execution.
519
- *
520
- * @example
521
- * ```ts
522
- * // Toggle HighPass filter with custom settings
523
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass(1.2, 150); // custom values
524
- * // or use the defaults
525
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass();
526
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
527
- * ```
528
- */
529
- toggleHighPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<FilterManager>;
530
- /**
531
- * Enables / Disables the Normalization effect.
532
- * @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
533
- * @param {boolean} [adaptive=true] Whether to use adaptive normalization or not.
534
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
535
- *
536
- * @example
537
- * ```ts
538
- * // Toggle Normalization filter with custom settings
539
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization(0.9, false); // custom values
540
- * // or use the defaults
541
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization();
542
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
543
- * ```
544
- */
545
- toggleNormalization: (maxAmplitude?: number, adaptive?: boolean) => Promise<FilterManager>;
546
- /**
547
- * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
548
- * @param {number} [decay=0.5] The decay of the echo effect.
549
- * @param {number} [echoLength=0.5] The length of the echo effect.
550
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
551
- *
552
- * @example
553
- * ```ts
554
- * // Toggle Echo filter with custom settings
555
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho(0.7, 0.6); // custom values
556
- * // or use the defaults
557
- * await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho();
558
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
559
- * ```
560
- */
561
- toggleEcho: (decay?: number, echoLength?: number) => Promise<FilterManager>;
562
- };
563
- /**
564
- * LavalinkFilter Plugin specific Filters
565
- */
566
- lavalinkFilterPlugin: {
567
- /**
568
- * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
569
- * @param {number} delay set the delay of the echo
570
- * @param {number} decay set the decay of the echo
571
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
572
- *
573
- * @example
574
- * ```ts
575
- * // Toggle Echo filter with custom settings
576
- * await player.filterManager.lavalinkFilterPlugin.toggleEcho(3, 0.7); // custom values
577
- * // or use the defaults
578
- * await player.filterManager.lavalinkFilterPlugin.toggleEcho();
579
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
580
- * ```
581
- */
582
- toggleEcho: (delay?: number, decay?: number) => Promise<FilterManager>;
583
- /**
584
- * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
585
- * @param {number} delays set the delays of the reverb
586
- * @param {number} gains set the gains of the reverb
587
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
588
- *
589
- * @example
590
- * ```ts
591
- * // Toggle Reverb filter with custom settings
592
- * await player.filterManager.lavalinkFilterPlugin.toggleReverb([0.04, 0.045, 0.05, 0.055], [0.85, 0.84, 0.83, 0.82]);
593
- * // or use the defaults
594
- * await player.filterManager.lavalinkFilterPlugin.toggleReverb();
595
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
596
- * ```
597
- */
598
- toggleReverb: (delays?: number[], gains?: number[]) => Promise<FilterManager>;
3
+ declare class FilterManager {
4
+ static EQList: {
5
+ BassboostEarrape: EQBand[];
6
+ BassboostHigh: EQBand[];
7
+ BassboostMedium: EQBand[];
8
+ BassboostLow: EQBand[];
9
+ BetterMusic: EQBand[];
10
+ Rock: EQBand[];
11
+ Classic: EQBand[];
12
+ Pop: EQBand[];
13
+ Electronic: EQBand[];
14
+ FullSound: EQBand[];
15
+ Gaming: EQBand[];
599
16
  };
17
+ /** The Equalizer bands currently applied to the Lavalink Server */
18
+ equalizerBands: EQBand[];
19
+ /** Private Util for the instaFix Filters option */
20
+ filterUpdatedState: boolean;
21
+ /** All "Active" / "disabled" Player Filters */
22
+ filters: PlayerFilters;
23
+ /** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
24
+ data: FilterData;
25
+ /** The Player assigned to this Filter Manager */
26
+ player: Player;
27
+ /** The Constructor for the FilterManager */
28
+ constructor(player: Player);
600
29
  /**
601
- * Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
602
- * @param {number} speed set the speed of the filter
603
- * @param {number} pitch set the pitch of the filter
604
- * @param {number} rate set the rate of the filter
605
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
606
- *
607
- * @example
608
- * ```ts
609
- * // Toggle Nightcore filter with custom settings
610
- * await player.filterManager.toggleNightcore(1.3, 1.3, 0.9);
611
- * // or use the defaults
612
- * await player.filterManager.toggleNightcore();
613
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
614
- * ```
615
- */
616
- toggleNightcore(speed?: number, pitch?: number, rate?: number): Promise<FilterManager>;
617
- /**
618
- * Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
619
- * @param {number} speed set the speed of the filterq
620
- * @param {number} pitch set the pitch of the filter
621
- * @param {number} rate set the rate of the filter
622
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
623
- *
624
- * @example
625
- * ```ts
626
- * // Toggle Vaporwave filter with custom settings
627
- * await player.filterManager.toggleVaporwave(0.9, 0.7, 1);
628
- * // or use the defaults
629
- * await player.filterManager.toggleVaporwave();
630
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
631
- * ```
632
- */
633
- toggleVaporwave(speed?: number, pitch?: number, rate?: number): Promise<FilterManager>;
634
- /**
635
- * Enable / Disables a Karaoke like Filter Effect
636
- * @param {number} level set the level of the filter
637
- * @param {number} monoLevel set the mono level of the filter
638
- * @param {number} filterBand set the filter band of the filter
639
- * @param {number} filterWidth set the filter width of the filter
640
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
641
- *
642
- * @example
643
- * ```ts
644
- * // Toggle Karaoke filter with custom settings
645
- * await player.filterManager.toggleKaraoke(1.5, 1.0, 220, 100);
646
- * // or use the defaults
647
- * await player.filterManager.toggleKaraoke();
648
- * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
649
- * ```
650
- */
651
- toggleKaraoke(level?: number, monoLevel?: number, filterBand?: number, filterWidth?: number): Promise<FilterManager>;
652
- /**
653
- * Function to find out if currently there is a custom timescamle etc. filter applied
654
- * @returns {boolean} whether a custom filter is active
655
- *
656
- * @example
657
- * ```ts
658
- * // Check if a custom filter is active
659
- * const isCustom = player.filterManager.isCustomFilterActive();
660
- * console.log(`Is custom filter active? ${isCustom}`);
661
- * ```
662
- */
663
- isCustomFilterActive(): boolean;
664
- /**
665
- * Sets the players equalizer bands using one of the predefined presets.
666
- * @param {keyof typeof EQList} preset The preset to use.
667
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
668
- *
669
- * @example
670
- * ```ts
671
- * // Set EQ preset
672
- * await player.filterManager.setEQPreset('BassboostMedium');
673
- * ```
674
- */
675
- setEQPreset(preset: keyof typeof EQList): Promise<this>;
676
- /**
677
- * Sets the players equalizer band on-top of the existing ones.
678
- * @param {number} bands
679
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
680
- *
681
- * @example
682
- * ```ts
683
- * // Set EQ bands
684
- * await player.filterManager.setEQ([
685
- * { band: 0, gain: 0.3 },
686
- * { band: 1, gain: -0.2 },
687
- * { band: 2, gain: 0.1 }
688
- * ]);
30
+ * Apply Player filters for lavalink filter sending data, if the filter is enabled / not
689
31
  *
690
- * // or use one of the templates:
691
- * await player.filterManager.setEQ(player.filterManager.EQList.BassboostMedium); // you can also import EQList from somewhere package if wanted.
692
- * ```
693
- */
694
- setEQ(bands: EQBand | EQBand[]): Promise<this>;
695
- /**
696
- * Clears the equalizer bands.
697
- * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
32
+ * @returns {Promise<void>}
698
33
  *
699
34
  * @example
700
35
  * ```ts
701
- * // Clear all EQ bands
702
- * await player.filterManager.clearEQ();
703
- * ```
704
- */
705
- clearEQ(): Promise<this>;
706
- }
707
-
708
- declare class QueueSaver {
709
- /**
710
- * The queue store manager
711
- */
712
- private _;
713
- /**
714
- * The options for the queue saver
715
- */
716
- options: {
717
- maxPreviousTracks: number;
718
- };
719
- constructor(options: ManagerQueueOptions);
720
- /**
721
- * Get the queue for a guild
722
- * @param guildId The guild ID
723
- * @returns The queue for the guild
724
- */
725
- get(guildId: string): Promise<Partial<StoredQueue>>;
726
- /**
727
- * Delete the queue for a guild
728
- * @param guildId The guild ID
729
- * @returns The queue for the guild
730
- */
731
- delete(guildId: string): Promise<boolean | void>;
732
- /**
733
- * Set the queue for a guild
734
- * @param guildId The guild ID
735
- * @param valueToStringify The queue to set
736
- * @returns The queue for the guild
737
- */
738
- set(guildId: string, valueToStringify: StoredQueue): Promise<boolean | void>;
739
- /**
740
- * Sync the queue for a guild
741
- * @param guildId The guild ID
742
- * @returns The queue for the guild
743
- */
744
- sync(guildId: string): Promise<Partial<StoredQueue>>;
745
- }
746
- declare class DefaultQueueStore implements QueueStoreManager {
747
- private data;
748
- constructor();
749
- /**
750
- * Get the queue for a guild
751
- * @param guildId The guild ID
752
- * @returns The queue for the guild
753
- */
754
- get(guildId: string): StoredQueue | undefined;
755
- /**
756
- * Set the queue for a guild
757
- * @param guildId The guild ID
758
- * @param valueToStringify The queue to set
759
- * @returns The queue for the guild
760
- */
761
- set(guildId: string, valueToStringify: any): boolean;
762
- /**
763
- * Delete the queue for a guild
764
- * @param guildId The guild ID
765
- * @returns The queue for the guild
766
- */
767
- delete(guildId: string): boolean;
768
- /**
769
- * Stringify the queue for a guild
770
- * @param value The queue to stringify
771
- * @returns The stringified queue
772
- */
773
- stringify(value: StoredQueue | string): StoredQueue | string;
774
- /**
775
- * Parse the queue for a guild
776
- * @param value The queue to parse
777
- * @returns The parsed queue
778
- */
779
- parse(value: StoredQueue | string): Partial<StoredQueue>;
780
- }
781
- declare class Queue {
782
- readonly tracks: (Track | UnresolvedTrack)[];
783
- readonly previous: Track[];
784
- current: Track | null;
785
- options: {
786
- maxPreviousTracks: number;
787
- };
788
- private readonly guildId;
789
- private readonly QueueSaver;
790
- private managerUtils;
791
- private queueChanges;
792
- /**
793
- * Create a new Queue
794
- * @param guildId The guild ID
795
- * @param data The data to initialize the queue with
796
- * @param QueueSaver The queue saver to use
797
- * @param queueOptions
798
- */
799
- constructor(guildId: string, data?: Partial<StoredQueue>, QueueSaver?: QueueSaver, queueOptions?: ManagerQueueOptions);
800
- /**
801
- * Utils for a Queue
802
- */
803
- utils: {
804
- /**
805
- * Save the current cached Queue on the database/server (overides the server)
806
- */
807
- save: () => Promise<boolean | void>;
808
- /**
809
- * Sync the current queue database/server with the cached one
810
- * @returns {void}
811
- */
812
- sync: (override?: boolean, dontSyncCurrent?: boolean) => Promise<void>;
813
- destroy: () => Promise<boolean | void>;
814
- /**
815
- * @returns {{current:Track|null, previous:Track[], tracks:Track[]}}The Queue, but in a raw State, which allows easier handling for the QueueStoreManager
816
- */
817
- toJSON: () => StoredQueue;
818
- /**
819
- * Get the Total Duration of the Queue-Songs summed up
820
- * @returns {number}
821
- */
822
- totalDuration: () => number;
823
- };
824
- /**
825
- * Shuffles the current Queue, then saves it
826
- * @returns Amount of Tracks in the Queue
36
+ * // Apply the filters after changing them manually:
37
+ * player.filterManager.data.volume = 0.5;
38
+ * // maybe you wanna manually set a distorition filter? then do it like this...
39
+ * player.filterManager.data.distortion = { sinOffset: 0.5, sinScale: 2, cosOffset: 0.5, cosScale: 2, tanOffset: 0.5, tanScale: 2, offset: 0.5, scale: 2 };
40
+ * await player.filterManager.applyPlayerFilters();
41
+ * ```
827
42
  */
828
- shuffle(): Promise<number>;
43
+ applyPlayerFilters(): Promise<void>;
44
+ privateNot0(value: number | undefined): boolean;
829
45
  /**
830
- * Add a Track to the Queue, and after saved in the "db" it returns the amount of the Tracks
831
- * @param {Track | Track[]} TrackOrTracks
832
- * @param {number} index At what position to add the Track
833
- * @returns {number} Queue-Size (for the next Tracks)
46
+ * Checks if the filters are correctly stated (active / not-active) - mostly used internally.
47
+ * @param oldFilterTimescale
48
+ * @returns {boolean} True, if the check was successfull
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // Check the filter states
53
+ * player.filterManager.checkFiltersState();
54
+ * // Apply the filters after checking
55
+ * await player.filterManager.applyPlayerFilters();
56
+ * ```
834
57
  */
835
- add(TrackOrTracks: Track | UnresolvedTrack | (Track | UnresolvedTrack)[], index?: number): any;
58
+ checkFiltersState(oldFilterTimescale?: Partial<TimescaleFilter>): boolean;
836
59
  /**
837
- * Splice the tracks in the Queue
838
- * @param {number} index Where to remove the Track
839
- * @param {number} amount How many Tracks to remove?
840
- * @param {Track | Track[]} TrackOrTracks Want to Add more Tracks?
841
- * @returns {Track} Spliced Track
60
+ * Reset all Filters
61
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * // Reset all filters
66
+ * await player.filterManager.resetFilters();
67
+ * ```
842
68
  */
843
- splice(index: number, amount: number, TrackOrTracks?: Track | UnresolvedTrack | (Track | UnresolvedTrack)[]): any;
69
+ resetFilters(): Promise<FilterManager>;
844
70
  /**
845
- * Remove stuff from the queue.tracks array
846
- * - single Track | UnresolvedTrack
847
- * - multiple Track | UnresovedTrack
848
- * - at the index or multiple indexes
849
- * - Since v2.7 the removed tracks get unshifted into the previous queue state instead of pushed (indexed at the start instead of end - as it should)
850
- * @param removeQueryTrack
851
- * @returns null (if nothing was removed) / { removed } where removed is an array with all removed elements
71
+ * Set the Filter Volume
72
+ * @param volume the volume (0.0 - 5.0)
73
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
852
74
  *
853
75
  * @example
854
- * ```js
855
- * // remove single track
856
- *
857
- * const track = player.queue.tracks[4];
858
- * await player.queue.remove(track);
859
- *
860
- * // if you already have the index you can straight up pass it too
861
- * await player.queue.remove(4);
862
- *
863
- *
864
- * // if you want to remove multiple tracks, e.g. from position 4 to position 10 you can do smt like this
865
- * await player.queue.remove(player.queue.tracks.slice(4, 10)) // get's the tracks from 4 - 10, which then get's found in the remove function to be removed
76
+ * ```ts
77
+ * // Set Volume to 50%
78
+ * await player.filterManager.setVolume(0.5);
79
+ * // note this is a filter, so it will "jump" to the volume, i think it's like a "volume boost effect" so i marketed it as a filter
80
+ * ```
81
+ */
82
+ setVolume(volume: number): Promise<this>;
83
+ /**
84
+ * Set the AudioOutput Filter
85
+ * @param {AudioOutputs} type the audio output type
86
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
866
87
  *
867
- * // I still highly suggest to use .splice!
88
+ * @example
89
+ * ```ts
90
+ * // Set Audio Output to Mono
91
+ * await player.filterManager.setAudioOutput("mono");
868
92
  *
869
- * await player.queue.splice(4, 10); // removes at index 4, 10 tracks
93
+ * // Set Audio Output to Stereo
94
+ * await player.filterManager.setAudioOutput("stereo");
870
95
  *
871
- * await player.queue.splice(1, 1); // removes at index 1, 1 track
96
+ * // Set Audio Output to Left
97
+ * await player.filterManager.setAudioOutput("left");
872
98
  *
873
- * await player.queue.splice(4, 0, ...tracks) // removes 0 tracks at position 4, and then inserts all tracks after position 4.
99
+ * // Set Audio Output to Right
100
+ * await player.filterManager.setAudioOutput("right");
874
101
  * ```
875
102
  */
876
- remove<T extends Track | UnresolvedTrack | number | Track[] | UnresolvedTrack[] | number[] | (number | Track | UnresolvedTrack)[]>(removeQueryTrack: T): Promise<{
877
- removed: (Track | UnresolvedTrack)[];
878
- } | null>;
103
+ setAudioOutput(type: AudioOutputs): Promise<FilterManager>;
879
104
  /**
880
- * Shifts the previous array, to return the last previous track & thus remove it from the previous queue
881
- * @returns
105
+ * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
106
+ * @param {number} speed set the speed of the filter
107
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
882
108
  *
883
109
  * @example
884
- * ```js
885
- * // example on how to play the previous track again
886
- * const previous = await player.queue.shiftPrevious(); // get the previous track and remove it from the previous queue array!!
887
- * if(!previous) return console.error("No previous track found");
888
- * await player.play({ clientTrack: previous }); // play it again
110
+ * ```ts
111
+ * // Set Speed to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
112
+ * await player.filterManager.setSpeed(1.25);
889
113
  * ```
890
114
  */
891
- shiftPrevious(): Promise<Track>;
892
- }
893
-
894
- declare class Player {
895
- /** Filter Manager per player */
896
- filterManager: FilterManager;
897
- /** circular reference to the lavalink Manager from the Player for easier use */
898
- LavalinkManager: LavalinkManager;
899
- /** Player options currently used, mutation doesn't affect player's state */
900
- options: PlayerOptions;
901
- /** The lavalink node assigned the the player, don't change it manually */
902
- node: LavalinkNode;
903
- /** The queue from the player */
904
- queue: Queue;
905
- /** The Guild Id of the Player */
906
- guildId: string;
907
- /** The Voice Channel Id of the Player */
908
- voiceChannelId: string | null;
909
- /** The Text Channel Id of the Player */
910
- textChannelId: string | null;
911
- /** States if the Bot is supposed to be outputting audio */
912
- playing: boolean;
913
- /** States if the Bot is paused or not */
914
- paused: boolean;
915
- /** Repeat Mode of the Player */
916
- repeatMode: RepeatMode;
917
- /** Player's ping */
918
- ping: {
919
- lavalink: number;
920
- ws: number;
921
- };
922
- /** The Display Volume */
923
- volume: number;
924
- /** The Volume Lavalink actually is outputting */
925
- lavalinkVolume: number;
926
- /** The current Positin of the player (Calculated) */
927
- get position(): number;
928
- /** The timestamp when the last position change update happened */
929
- lastPositionChange: number | null;
930
- /** The current Positin of the player (from Lavalink) */
931
- lastPosition: number;
932
- lastSavedPosition: number;
933
- /** When the player was created [Timestamp in Ms] (from lavalink) */
934
- createdTimeStamp: number;
935
- /** The Player Connection's State (from Lavalink) */
936
- connected: boolean | undefined;
937
- /** Voice Server Data (from Lavalink) */
938
- voice: LavalinkPlayerVoiceOptions;
939
- voiceState: {
940
- selfDeaf: boolean;
941
- selfMute: boolean;
942
- serverDeaf: boolean;
943
- serverMute: boolean;
944
- suppress: boolean;
945
- };
946
- /** Custom data for the player */
947
- private readonly data;
948
- /**
949
- * Create a new Player
950
- * @param options
951
- * @param LavalinkManager
952
- */
953
- constructor(options: PlayerOptions, LavalinkManager: LavalinkManager, dontEmitPlayerCreateEvent?: boolean);
954
- /**
955
- * Set custom data.
956
- * @param key
957
- * @param value
958
- */
959
- set(key: string, value: unknown): this;
960
- /**
961
- * Get custom data.
962
- * @param key
963
- */
964
- get<T>(key: string): T;
965
- /**
966
- * CLears all the custom data.
967
- */
968
- clearData(): this;
969
- /**
970
- * Get all custom Data
971
- */
972
- getAllData(): Record<string, unknown>;
973
- /**
974
- * Play the next track from the queue / a specific track, with playoptions for Lavalink
975
- * @param options
976
- */
977
- play(options?: Partial<PlayOptions>): any;
978
- /**
979
- * Set the Volume for the Player
980
- * @param volume The Volume in percent
981
- * @param ignoreVolumeDecrementer If it should ignore the volumedecrementer option
982
- */
983
- setVolume(volume: number, ignoreVolumeDecrementer?: boolean): Promise<this>;
984
- /**
985
- * Search for a track
986
- * @param query The query to search for
987
- * @param requestUser The user that requested the track
988
- * @param throwOnEmpty If an error should be thrown if no track is found
989
- * @returns The search result
990
- */
991
- lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<LavaSearchResponse | SearchResult>;
992
- /**
993
- * Set the SponsorBlock
994
- * @param segments The segments to set
995
- */
996
- setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
997
- /**
998
- * Get the SponsorBlock
999
- */
1000
- getSponsorBlock(): Promise<SponsorBlockSegment[]>;
1001
- /**
1002
- * Delete the SponsorBlock
1003
- */
1004
- deleteSponsorBlock(): Promise<void>;
115
+ setSpeed(speed?: number): Promise<FilterManager>;
1005
116
  /**
117
+ * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
118
+ * @param {number} pitch set the pitch of the filter
119
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
1006
120
  *
1007
- * @param query Query for your data
1008
- * @param requestUser
121
+ * @example
122
+ * ```ts
123
+ * // Set Pitch to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
124
+ * await player.filterManager.setPitch(1.25);
125
+ * ```
1009
126
  */
1010
- search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<UnresolvedSearchResult | SearchResult>;
127
+ setPitch(pitch?: number): Promise<FilterManager>;
1011
128
  /**
1012
- * Pause the player
129
+ * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
130
+ * @param {number} rate set the rate of the filter
131
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * // Set Rate to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
136
+ * await player.filterManager.setRate(1.25);
137
+ * ```
1013
138
  */
1014
- pause(): Promise<this>;
139
+ setRate(rate?: number): Promise<FilterManager>;
1015
140
  /**
1016
- * Resume the Player
141
+ * Enables / Disables the rotation effect, (Optional: provide your Own Data)
142
+ * @param {number} rotationHz set the rotationHz of the filter
143
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * // Toggle Rotation filter with custom settings
148
+ * await player.filterManager.toggleRotation(0.4);
149
+ * // or use the defaults
150
+ * await player.filterManager.toggleRotation();
151
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
152
+ * ```
1017
153
  */
1018
- resume(): Promise<this>;
154
+ toggleRotation(rotationHz?: number): Promise<FilterManager>;
1019
155
  /**
1020
- * Seek to a specific Position
1021
- * @param position
156
+ * Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
157
+ * @param {number} frequency set the frequency of the filter
158
+ * @param {number} depth set the depth of the filter
159
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * // Toggle Vibrato filter with custom settings
164
+ * await player.filterManager.toggleVibrato(8, 0.5);
165
+ * // or use the defaults
166
+ * await player.filterManager.toggleVibrato();
167
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
168
+ * ```
1022
169
  */
1023
- seek(position: number): Promise<this>;
170
+ toggleVibrato(frequency?: number, depth?: number): Promise<FilterManager>;
1024
171
  /**
1025
- * Set the Repeatmode of the Player
1026
- * @param repeatMode
172
+ * Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
173
+ * @param {number} frequency set the frequency of the filter
174
+ * @param {number} depth set the depth of the filter
175
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * // Toggle Tremolo filter with custom settings
180
+ * await player.filterManager.toggleTremolo(5, 0.7);
181
+ * // or use the defaults
182
+ * await player.filterManager.toggleTremolo();
183
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
184
+ * ```
1027
185
  */
1028
- setRepeatMode(repeatMode: RepeatMode): Promise<this>;
186
+ toggleTremolo(frequency?: number, depth?: number): Promise<FilterManager>;
1029
187
  /**
1030
- * Skip the current song, or a specific amount of songs
1031
- * @param amount provide the index of the next track to skip to
188
+ * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
189
+ * @param {number} smoothing set the smoothing of the filter
190
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * // Toggle LowPass filter with custom settings
195
+ * await player.filterManager.toggleLowPass(30);
196
+ * // or use the defaults
197
+ * await player.filterManager.toggleLowPass();
198
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
199
+ * ```
1032
200
  */
1033
- skip(skipTo?: number, throwError?: boolean): Promise<this>;
201
+ toggleLowPass(smoothing?: number): Promise<FilterManager>;
1034
202
  /**
1035
- * Clears the queue and stops playing. Does not destroy the Player and not leave the channel
1036
- * @returns
203
+ * Lavalink LavaDspx Plugin Filters
1037
204
  */
1038
- stopPlaying(clearQueue?: boolean, executeAutoplay?: boolean): Promise<this>;
205
+ lavalinkLavaDspxPlugin: {
206
+ /**
207
+ * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
208
+ * @param {number} boostFactor set the boost factor of the filter
209
+ * @param {number} cutoffFrequency set the cutoff frequency of the filter
210
+ * @returns {Promise<boolean>} the state of the filter after execution.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * // Toggle LowPass filter with custom settings
215
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(1.2, 300);
216
+ * // or use the defaults
217
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass();
218
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
219
+ * ```
220
+ */
221
+ toggleLowPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<FilterManager>;
222
+ /**
223
+ * Enables / Disables the HighPass effect, (Optional: provide your Own Data)
224
+ * @param {number} boostFactor [] set the boost factor of the filter
225
+ * @param {number} cutoffFrequency set the cutoff frequency of the filter
226
+ * @returns {Promise<boolean>} the state of the filter after execution.
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * // Toggle HighPass filter with custom settings
231
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass(1.2, 150); // custom values
232
+ * // or use the defaults
233
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass();
234
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
235
+ * ```
236
+ */
237
+ toggleHighPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<FilterManager>;
238
+ /**
239
+ * Enables / Disables the Normalization effect.
240
+ * @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
241
+ * @param {boolean} [adaptive=true] Whether to use adaptive normalization or not.
242
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * // Toggle Normalization filter with custom settings
247
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization(0.9, false); // custom values
248
+ * // or use the defaults
249
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization();
250
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
251
+ * ```
252
+ */
253
+ toggleNormalization: (maxAmplitude?: number, adaptive?: boolean) => Promise<FilterManager>;
254
+ /**
255
+ * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
256
+ * @param {number} [decay=0.5] The decay of the echo effect.
257
+ * @param {number} [echoLength=0.5] The length of the echo effect.
258
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * // Toggle Echo filter with custom settings
263
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho(0.7, 0.6); // custom values
264
+ * // or use the defaults
265
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho();
266
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
267
+ * ```
268
+ */
269
+ toggleEcho: (decay?: number, echoLength?: number) => Promise<FilterManager>;
270
+ };
1039
271
  /**
1040
- * Connects the Player to the Voice Channel
1041
- * @returns
272
+ * LavalinkFilter Plugin specific Filters
1042
273
  */
1043
- connect(): Promise<this>;
1044
- changeVoiceState(data: {
1045
- voiceChannelId?: string;
1046
- selfDeaf?: boolean;
1047
- selfMute?: boolean;
1048
- }): Promise<this>;
274
+ lavalinkFilterPlugin: {
275
+ /**
276
+ * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
277
+ * @param {number} delay set the delay of the echo
278
+ * @param {number} decay set the decay of the echo
279
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
280
+ *
281
+ * @example
282
+ * ```ts
283
+ * // Toggle Echo filter with custom settings
284
+ * await player.filterManager.lavalinkFilterPlugin.toggleEcho(3, 0.7); // custom values
285
+ * // or use the defaults
286
+ * await player.filterManager.lavalinkFilterPlugin.toggleEcho();
287
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
288
+ * ```
289
+ */
290
+ toggleEcho: (delay?: number, decay?: number) => Promise<FilterManager>;
291
+ /**
292
+ * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
293
+ * @param {number} delays set the delays of the reverb
294
+ * @param {number} gains set the gains of the reverb
295
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
296
+ *
297
+ * @example
298
+ * ```ts
299
+ * // Toggle Reverb filter with custom settings
300
+ * await player.filterManager.lavalinkFilterPlugin.toggleReverb([0.04, 0.045, 0.05, 0.055], [0.85, 0.84, 0.83, 0.82]);
301
+ * // or use the defaults
302
+ * await player.filterManager.lavalinkFilterPlugin.toggleReverb();
303
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
304
+ * ```
305
+ */
306
+ toggleReverb: (delays?: number[], gains?: number[]) => Promise<FilterManager>;
307
+ };
1049
308
  /**
1050
- * Disconnects the Player from the Voice Channel, but keeps the player in the cache
1051
- * @param force If false it throws an error, if player thinks it's already disconnected
1052
- * @returns
309
+ * Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
310
+ * @param {number} speed set the speed of the filter
311
+ * @param {number} pitch set the pitch of the filter
312
+ * @param {number} rate set the rate of the filter
313
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
314
+ *
315
+ * @example
316
+ * ```ts
317
+ * // Toggle Nightcore filter with custom settings
318
+ * await player.filterManager.toggleNightcore(1.3, 1.3, 0.9);
319
+ * // or use the defaults
320
+ * await player.filterManager.toggleNightcore();
321
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
322
+ * ```
1053
323
  */
1054
- disconnect(force?: boolean): Promise<this>;
324
+ toggleNightcore(speed?: number, pitch?: number, rate?: number): Promise<FilterManager>;
1055
325
  /**
1056
- * Destroy the player and disconnect from the voice channel
326
+ * Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
327
+ * @param {number} speed set the speed of the filterq
328
+ * @param {number} pitch set the pitch of the filter
329
+ * @param {number} rate set the rate of the filter
330
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * // Toggle Vaporwave filter with custom settings
335
+ * await player.filterManager.toggleVaporwave(0.9, 0.7, 1);
336
+ * // or use the defaults
337
+ * await player.filterManager.toggleVaporwave();
338
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
339
+ * ```
1057
340
  */
1058
- destroy(reason?: DestroyReasons | string, disconnect?: boolean): Promise<this>;
341
+ toggleVaporwave(speed?: number, pitch?: number, rate?: number): Promise<FilterManager>;
1059
342
  /**
1060
- * Get the current lyrics of the track currently playing on the guild
1061
- * @param guildId The guild id to get the current lyrics for
1062
- * @param skipTrackSource If true, it will not try to get the lyrics from the track source
1063
- * @returns The current lyrics
343
+ * Enable / Disables a Karaoke like Filter Effect
344
+ * @param {number} level set the level of the filter
345
+ * @param {number} monoLevel set the mono level of the filter
346
+ * @param {number} filterBand set the filter band of the filter
347
+ * @param {number} filterWidth set the filter width of the filter
348
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
349
+ *
1064
350
  * @example
1065
351
  * ```ts
1066
- * const lyrics = await player.getCurrentLyrics();
352
+ * // Toggle Karaoke filter with custom settings
353
+ * await player.filterManager.toggleKaraoke(1.5, 1.0, 220, 100);
354
+ * // or use the defaults
355
+ * await player.filterManager.toggleKaraoke();
356
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
1067
357
  * ```
1068
358
  */
1069
- getCurrentLyrics(skipTrackSource?: boolean): Promise<LyricsResult>;
359
+ toggleKaraoke(level?: number, monoLevel?: number, filterBand?: number, filterWidth?: number): Promise<FilterManager>;
1070
360
  /**
1071
- * Get the lyrics of a specific track
1072
- * @param track The track to get the lyrics for
1073
- * @param skipTrackSource If true, it will not try to get the lyrics from the track source
1074
- * @returns The lyrics of the track
361
+ * Function to find out if currently there is a custom timescamle etc. filter applied
362
+ * @returns {boolean} whether a custom filter is active
363
+ *
1075
364
  * @example
1076
365
  * ```ts
1077
- * const lyrics = await player.getLyrics(player.queue.tracks[0], true);
366
+ * // Check if a custom filter is active
367
+ * const isCustom = player.filterManager.isCustomFilterActive();
368
+ * console.log(`Is custom filter active? ${isCustom}`);
1078
369
  * ```
1079
370
  */
1080
- getLyrics(track: Track, skipTrackSource?: boolean): Promise<LyricsResult>;
371
+ isCustomFilterActive(): boolean;
1081
372
  /**
1082
- * Subscribe to the lyrics event on a specific guild to active live lyrics events
1083
- * @returns The unsubscribe function
373
+ * Sets the players equalizer bands using one of the predefined presets.
374
+ * @param {keyof typeof EQList} preset The preset to use.
375
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
376
+ *
1084
377
  * @example
1085
378
  * ```ts
1086
- * const lyrics = await player.subscribeLyrics();
379
+ * // Set EQ preset
380
+ * await player.filterManager.setEQPreset('BassboostMedium');
1087
381
  * ```
1088
382
  */
1089
- subscribeLyrics(): Promise<unknown>;
383
+ setEQPreset(preset: keyof typeof EQList): Promise<this>;
1090
384
  /**
1091
- * Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
1092
- * @returns The unsubscribe function
385
+ * Sets the players equalizer band on-top of the existing ones.
386
+ * @param {number} bands
387
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
388
+ *
1093
389
  * @example
1094
390
  * ```ts
1095
- * const lyrics = await player.unsubscribeLyrics();
391
+ * // Set EQ bands
392
+ * await player.filterManager.setEQ([
393
+ * { band: 0, gain: 0.3 },
394
+ * { band: 1, gain: -0.2 },
395
+ * { band: 2, gain: 0.1 }
396
+ * ]);
397
+ *
398
+ * // or use one of the templates:
399
+ * await player.filterManager.setEQ(player.filterManager.EQList.BassboostMedium); // you can also import EQList from somewhere package if wanted.
1096
400
  * ```
1097
401
  */
1098
- unsubscribeLyrics(): Promise<void>;
402
+ setEQ(bands: EQBand | EQBand[]): Promise<this>;
1099
403
  /**
1100
- * Move the player on a different Audio-Node
1101
- * @param newNode New Node / New Node Id
1102
- * @param checkSources If it should check if the sources are supported by the new node @default true
1103
- * @return The new Node Id
404
+ * Clears the equalizer bands.
405
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
406
+ *
1104
407
  * @example
1105
408
  * ```ts
1106
- * const changeNode = await player.changeNode(newNode, true);
409
+ * // Clear all EQ bands
410
+ * await player.filterManager.clearEQ();
1107
411
  * ```
1108
412
  */
1109
- changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
1110
- /**
1111
- * 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.
1112
- * @param node the id of the node to move to
1113
- * @returns the player
1114
- * @throws RangeError if there is no available nodes.
1115
- * @throws Error if the node to move to is the same as the current node.
1116
- */
1117
- moveNode(node?: string): Promise<string | this>;
1118
- /** Converts the Player including Queue to a Json state */
1119
- toJSON(): PlayerJson;
413
+ clearEQ(): Promise<this>;
1120
414
  }
1121
415
 
1122
416
  /** Sourcenames provided by lavalink server */
@@ -1234,398 +528,469 @@ interface UnresolvedTrackInfo extends Partial<TrackInfo> {
1234
528
  }
1235
529
  interface UnresolvedQuery extends UnresolvedTrackInfo {
1236
530
  /** The base64 of the unresolved track to "encode" */
1237
- encoded?: Base64;
1238
- }
1239
- interface UnresolvedTrack {
1240
- /** Required */
1241
- resolve: (player: Player) => Promise<void>;
1242
- /** The Base 64 encoded String */
1243
- encoded?: Base64;
1244
- /** Track Information */
1245
- info: UnresolvedTrackInfo;
1246
- /** Plugin Information from Lavalink */
1247
- pluginInfo: Partial<PluginInfo>;
1248
- /** The userData Object from when you provide to the lavalink request */
1249
- userData?: anyObject;
1250
- /** The Track's Requester */
1251
- requester?: unknown;
1252
- }
1253
-
1254
- interface StoredQueue {
1255
- current: Track | null;
1256
- previous: Track[];
1257
- tracks: (Track | UnresolvedTrack)[];
1258
- }
1259
- interface QueueStoreManager {
1260
- /** @async get a Value (MUST RETURN UNPARSED!) */
1261
- get: (guildId: string) => Awaitable<StoredQueue | string | undefined>;
1262
- /** @async Set a value inside a guildId (MUST BE UNPARSED) */
1263
- set: (guildId: string, value: StoredQueue | string) => Awaitable<void | boolean>;
1264
- /** @async Delete a Database Value based of it's guildId */
1265
- delete: (guildId: string) => Awaitable<void | boolean>;
1266
- /** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
1267
- stringify: (value: StoredQueue | string) => Awaitable<StoredQueue | string>;
1268
- /** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
1269
- parse: (value: StoredQueue | string) => Awaitable<Partial<StoredQueue>>;
1270
- }
1271
- interface ManagerQueueOptions {
1272
- /** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
1273
- maxPreviousTracks?: number;
1274
- /** Custom Queue Store option */
1275
- queueStore?: QueueStoreManager;
1276
- /** Custom Queue Watcher class */
1277
- queueChangesWatcher?: QueueChangesWatcher;
1278
- }
1279
- interface QueueChangesWatcher {
1280
- /** get a Value (MUST RETURN UNPARSED!) */
1281
- tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
1282
- /** Set a value inside a guildId (MUST BE UNPARSED) */
1283
- tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number | number[], oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
1284
- /** Set a value inside a guildId (MUST BE UNPARSED) */
1285
- shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
1286
- }
1287
-
1288
- type DestroyReasonsType = keyof typeof DestroyReasons | string;
1289
- type DisconnectReasonsType = keyof typeof DisconnectReasons | string;
1290
- interface PlayerJson {
1291
- /** Guild Id where the player was playing in */
1292
- guildId: string;
1293
- /** Options provided to the player */
1294
- options: PlayerOptions;
1295
- /** Voice Channel Id the player was playing in */
1296
- voiceChannelId: string;
1297
- /** Text Channel Id the player was synced to */
1298
- textChannelId?: string;
1299
- /** Position the player was at */
1300
- position: number;
1301
- /** Lavalink's position the player was at */
1302
- lastPosition: number;
1303
- /** Last time the position was sent from lavalink */
1304
- lastPositionChange: number | null;
1305
- /** Volume in % from the player (without volumeDecrementer) */
1306
- volume: number;
1307
- /** Real Volume used in lavalink (with the volumeDecrementer) */
1308
- lavalinkVolume: number;
1309
- /** The repeatmode from the player */
1310
- repeatMode: RepeatMode;
1311
- /** Pause state */
1312
- paused: boolean;
1313
- /** Wether the player was playing or not */
1314
- playing: boolean;
1315
- /** When the player was created */
1316
- createdTimeStamp?: number;
1317
- /** All current used fitlers Data */
1318
- filters: FilterData;
1319
- /** The player's ping object */
1320
- ping: {
1321
- /** Ping to the voice websocket server */
1322
- ws: number;
1323
- /** Avg. calc. Ping to the lavalink server */
1324
- lavalink: number;
1325
- };
1326
- /** Equalizer Bands used in lavalink */
1327
- equalizer: EQBand[];
1328
- /** The Id of the last used node */
1329
- nodeId?: string;
1330
- /** The SessionId of the node */
1331
- nodeSessionId?: string;
1332
- /** The stored queue */
1333
- queue?: StoredQueue;
1334
- }
1335
- type RepeatMode = "queue" | "track" | "off";
1336
- interface PlayerOptions {
1337
- /** Guild id of the player */
1338
- guildId: string;
1339
- /** The Voice Channel Id */
1340
- voiceChannelId: string;
1341
- /** The Text Channel Id of the Player */
1342
- textChannelId?: string;
1343
- /** instantly change volume with the one play request */
1344
- volume?: number;
1345
- /** VC Region for node selections */
1346
- vcRegion?: string;
1347
- /** if it should join deafened */
1348
- selfDeaf?: boolean;
1349
- /** If it should join muted */
1350
- selfMute?: boolean;
1351
- /** If it should use a specific lavalink node */
1352
- node?: LavalinkNode | string;
1353
- /** If when applying filters, it should use the insta apply filters fix */
1354
- instaUpdateFiltersFix?: boolean;
1355
- /** If a volume should be applied via filters instead of lavalink-volume */
1356
- applyVolumeAsFilter?: boolean;
1357
- /** Custom Data for the player get/set datastorage */
1358
- customData?: anyObject;
1359
- }
1360
- type anyObject = {
1361
- [key: string | number]: string | number | null | anyObject;
1362
- };
1363
- interface BasePlayOptions {
1364
- /** The position to start the track. */
1365
- position?: number;
1366
- /** The position to end the track. */
1367
- endTime?: number;
1368
- /** If to start "paused" */
1369
- paused?: boolean;
1370
- /** The Volume to start with */
1371
- volume?: number;
1372
- /** The Lavalink Filters to use | only with the new REST API */
1373
- filters?: Partial<LavalinkFilterData>;
1374
- /** Voice Update for Lavalink */
1375
- voice?: LavalinkPlayerVoiceOptions;
1376
- }
1377
- interface LavalinkPlayOptions extends BasePlayOptions {
1378
- /** Which Track to play | don't provide, if it should pick from the Queue */
1379
- track?: {
1380
- /** The track encoded base64 string to use instead of the one from the queue system */
1381
- encoded?: Base64 | null;
1382
- /** The identifier of the track to use */
1383
- identifier?: string;
1384
- /** Custom User Data for the track to provide, will then be on the userData object from the track */
1385
- userData?: anyObject;
1386
- /** The Track requester for when u provide encodedTrack / identifer */
1387
- requester?: unknown;
1388
- };
1389
- }
1390
- interface PlayOptions extends LavalinkPlayOptions {
1391
- /** Whether to not replace the track if a play payload is sent. */
1392
- noReplace?: boolean;
1393
- /** Adds track on queue and skips to it */
1394
- clientTrack?: Track | UnresolvedTrack;
1395
- }
1396
-
1397
- /** Ability to manipulate fetch requests */
1398
- type ModifyRequest = (options: RequestInit & {
1399
- path: string;
1400
- extraQueryUrlParams?: URLSearchParams;
1401
- }) => void;
1402
- type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
1403
- /**
1404
- * Node Options for creating a lavalink node
1405
- */
1406
- interface LavalinkNodeOptions {
1407
- /** The Lavalink Server-Ip / Domain-URL */
1408
- host: string;
1409
- /** The Lavalink Connection Port */
1410
- port: number;
1411
- /** The Lavalink Password / Authorization-Key */
1412
- authorization: string;
1413
- /** Does the Server use ssl (https) */
1414
- secure?: boolean;
1415
- /** RESUME THE PLAYER? by providing a sessionid on the node-creation */
1416
- sessionId?: string;
1417
- /** Add a Custom ID to the node, for later use */
1418
- id?: string;
1419
- /** Voice Regions of this Node */
1420
- regions?: string[];
1421
- /** The retryAmount for the node. */
1422
- retryAmount?: number;
1423
- /** The retryDelay for the node. */
1424
- retryDelay?: number;
1425
- /** signal for cancelling requests - default: AbortSignal.timeout(options.requestSignalTimeoutMS || 10000) - put <= 0 to disable */
1426
- requestSignalTimeoutMS?: number;
1427
- /** Close on error */
1428
- closeOnError?: boolean;
1429
- /** Heartbeat interval , set to <= 0 to disable heartbeat system */
1430
- heartBeatInterval?: number;
1431
- /** Recommended, to check wether the client is still connected or not on the stats endpoint */
1432
- enablePingOnStatsCheck?: boolean;
1433
- }
1434
- /**
1435
- * Memory Stats object from lavalink
1436
- */
1437
- interface MemoryStats {
1438
- /** The free memory of the allocated amount. */
1439
- free: number;
1440
- /** The used memory of the allocated amount. */
1441
- used: number;
1442
- /** The total allocated memory. */
1443
- allocated: number;
1444
- /** The reservable memory. */
1445
- reservable: number;
1446
- }
1447
- /**
1448
- * CPU Stats object from lavalink
1449
- */
1450
- interface CPUStats {
1451
- /** The core amount the host machine has. */
1452
- cores: number;
1453
- /** The system load. */
1454
- systemLoad: number;
1455
- /** The lavalink load. */
1456
- lavalinkLoad: number;
1457
- }
1458
- /**
1459
- * FrameStats Object from lavalink
1460
- */
1461
- interface FrameStats {
1462
- /** The amount of sent frames. */
1463
- sent?: number;
1464
- /** The amount of nulled frames. */
1465
- nulled?: number;
1466
- /** The amount of deficit frames. */
1467
- deficit?: number;
531
+ encoded?: Base64;
1468
532
  }
1469
- /**
1470
- * BaseNodeStats object from Lavalink
1471
- */
1472
- interface BaseNodeStats {
1473
- /** The amount of players on the node. */
1474
- players: number;
1475
- /** The amount of playing players on the node. */
1476
- playingPlayers: number;
1477
- /** The uptime for the node. */
1478
- uptime: number;
1479
- /** The memory stats for the node. */
1480
- memory: MemoryStats;
1481
- /** The cpu stats for the node. */
1482
- cpu: CPUStats;
1483
- /** The frame stats for the node. */
1484
- frameStats: FrameStats;
533
+ interface UnresolvedTrack {
534
+ /** Required */
535
+ resolve: (player: Player) => Promise<void>;
536
+ /** The Base 64 encoded String */
537
+ encoded?: Base64;
538
+ /** Track Information */
539
+ info: UnresolvedTrackInfo;
540
+ /** Plugin Information from Lavalink */
541
+ pluginInfo: Partial<PluginInfo>;
542
+ /** The userData Object from when you provide to the lavalink request */
543
+ userData?: anyObject;
544
+ /** The Track's Requester */
545
+ requester?: unknown;
1485
546
  }
1486
- /**
1487
- * Interface for nodeStats from lavalink
1488
- */
1489
- interface NodeStats extends BaseNodeStats {
1490
- /** The frame stats for the node. */
1491
- frameStats: FrameStats;
547
+
548
+ interface StoredQueue {
549
+ current: Track | null;
550
+ previous: Track[];
551
+ tracks: (Track | UnresolvedTrack)[];
1492
552
  }
1493
- /**
1494
- * Entire lavalink information object from lavalink
1495
- */
1496
- interface LavalinkInfo {
1497
- /** The version of this Lavalink server */
1498
- version: VersionObject;
1499
- /** The millisecond unix timestamp when this Lavalink jar was built */
1500
- buildTime: number;
1501
- /** The git information of this Lavalink server */
1502
- git: GitObject;
1503
- /** The JVM version this Lavalink server runs on */
1504
- jvm: string;
1505
- /** The Lavaplayer version being used by this server */
1506
- lavaplayer: string;
1507
- /** The enabled source managers for this server */
1508
- sourceManagers: string[];
1509
- /** The enabled filters for this server */
1510
- filters: string[];
1511
- /** The enabled plugins for this server */
1512
- plugins: PluginObject[];
553
+ interface QueueStoreManager {
554
+ /** @async get a Value (MUST RETURN UNPARSED!) */
555
+ get: (guildId: string) => Awaitable<StoredQueue | string | undefined>;
556
+ /** @async Set a value inside a guildId (MUST BE UNPARSED) */
557
+ set: (guildId: string, value: StoredQueue | string) => Awaitable<void | boolean>;
558
+ /** @async Delete a Database Value based of it's guildId */
559
+ delete: (guildId: string) => Awaitable<void | boolean>;
560
+ /** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
561
+ stringify: (value: StoredQueue | string) => Awaitable<StoredQueue | string>;
562
+ /** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
563
+ parse: (value: StoredQueue | string) => Awaitable<Partial<StoredQueue>>;
1513
564
  }
1514
- /**
1515
- * Lavalink's version object from lavalink
1516
- */
1517
- interface VersionObject {
1518
- /** The full version string of this Lavalink server */
1519
- semver: string;
1520
- /** The major version of this Lavalink server */
1521
- major: number;
1522
- /** The minor version of this Lavalink server */
1523
- minor: number;
1524
- /** The patch version of this Lavalink server */
1525
- patch: number;
1526
- /** The pre-release version according to semver as a . separated list of identifiers */
1527
- preRelease?: string;
1528
- /** The build metadata according to semver as a . separated list of identifiers */
1529
- build?: string;
565
+ interface ManagerQueueOptions {
566
+ /** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
567
+ maxPreviousTracks?: number;
568
+ /** Custom Queue Store option */
569
+ queueStore?: QueueStoreManager;
570
+ /** Custom Queue Watcher class */
571
+ queueChangesWatcher?: QueueChangesWatcher;
1530
572
  }
1531
- /**
1532
- * Git information object from lavalink
1533
- */
1534
- interface GitObject {
1535
- /** The branch this Lavalink server was built on */
1536
- branch: string;
1537
- /** The commit this Lavalink server was built on */
1538
- commit: string;
1539
- /** The millisecond unix timestamp for when the commit was created */
1540
- commitTime: string;
573
+ interface QueueChangesWatcher {
574
+ /** get a Value (MUST RETURN UNPARSED!) */
575
+ tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
576
+ /** Set a value inside a guildId (MUST BE UNPARSED) */
577
+ tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number | number[], oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
578
+ /** Set a value inside a guildId (MUST BE UNPARSED) */
579
+ shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
1541
580
  }
1542
- /**
1543
- * Lavalink's plugins object from lavalink's plugin
1544
- */
1545
- interface PluginObject {
1546
- /** The name of the plugin */
1547
- name: string;
1548
- /** The version of the plugin */
1549
- version: string;
581
+
582
+ declare class QueueSaver {
583
+ /**
584
+ * The queue store manager
585
+ */
586
+ private _;
587
+ /**
588
+ * The options for the queue saver
589
+ */
590
+ options: {
591
+ maxPreviousTracks: number;
592
+ };
593
+ constructor(options: ManagerQueueOptions);
594
+ /**
595
+ * Get the queue for a guild
596
+ * @param guildId The guild ID
597
+ * @returns The queue for the guild
598
+ */
599
+ get(guildId: string): Promise<Partial<StoredQueue>>;
600
+ /**
601
+ * Delete the queue for a guild
602
+ * @param guildId The guild ID
603
+ * @returns The queue for the guild
604
+ */
605
+ delete(guildId: string): Promise<boolean | void>;
606
+ /**
607
+ * Set the queue for a guild
608
+ * @param guildId The guild ID
609
+ * @param valueToStringify The queue to set
610
+ * @returns The queue for the guild
611
+ */
612
+ set(guildId: string, valueToStringify: StoredQueue): Promise<boolean | void>;
613
+ /**
614
+ * Sync the queue for a guild
615
+ * @param guildId The guild ID
616
+ * @returns The queue for the guild
617
+ */
618
+ sync(guildId: string): Promise<Partial<StoredQueue>>;
1550
619
  }
1551
- interface LyricsResult {
1552
- /**The name of the source */
1553
- sourceName: string;
1554
- /**The name of the provider */
1555
- provider: string;
1556
- /**The result text */
1557
- text: string | null;
1558
- /**The lyrics lines */
1559
- lines: LyricsLine[];
1560
- /**Information about the plugin */
1561
- plugin: PluginInfo;
620
+ declare class DefaultQueueStore implements QueueStoreManager {
621
+ private data;
622
+ constructor();
623
+ /**
624
+ * Get the queue for a guild
625
+ * @param guildId The guild ID
626
+ * @returns The queue for the guild
627
+ */
628
+ get(guildId: string): StoredQueue | undefined;
629
+ /**
630
+ * Set the queue for a guild
631
+ * @param guildId The guild ID
632
+ * @param valueToStringify The queue to set
633
+ * @returns The queue for the guild
634
+ */
635
+ set(guildId: string, valueToStringify: any): boolean;
636
+ /**
637
+ * Delete the queue for a guild
638
+ * @param guildId The guild ID
639
+ * @returns The queue for the guild
640
+ */
641
+ delete(guildId: string): boolean;
642
+ /**
643
+ * Stringify the queue for a guild
644
+ * @param value The queue to stringify
645
+ * @returns The stringified queue
646
+ */
647
+ stringify(value: StoredQueue | string): StoredQueue | string;
648
+ /**
649
+ * Parse the queue for a guild
650
+ * @param value The queue to parse
651
+ * @returns The parsed queue
652
+ */
653
+ parse(value: StoredQueue | string): Partial<StoredQueue>;
1562
654
  }
1563
- interface LyricsLine {
1564
- /**The millisecond timestamp */
1565
- timestamp: number;
1566
- /**The line duration in milliseconds */
1567
- duration: number | null;
1568
- /**The line text */
1569
- line: string;
1570
- /**Information about the plugin */
1571
- plugin: PluginInfo;
655
+ declare class Queue {
656
+ readonly tracks: (Track | UnresolvedTrack)[];
657
+ readonly previous: Track[];
658
+ current: Track | null;
659
+ options: {
660
+ maxPreviousTracks: number;
661
+ };
662
+ private readonly guildId;
663
+ private readonly QueueSaver;
664
+ private managerUtils;
665
+ private queueChanges;
666
+ /**
667
+ * Create a new Queue
668
+ * @param guildId The guild ID
669
+ * @param data The data to initialize the queue with
670
+ * @param QueueSaver The queue saver to use
671
+ * @param queueOptions
672
+ */
673
+ constructor(guildId: string, data?: Partial<StoredQueue>, QueueSaver?: QueueSaver, queueOptions?: ManagerQueueOptions);
674
+ /**
675
+ * Utils for a Queue
676
+ */
677
+ utils: {
678
+ /**
679
+ * Save the current cached Queue on the database/server (overides the server)
680
+ */
681
+ save: () => Promise<boolean | void>;
682
+ /**
683
+ * Sync the current queue database/server with the cached one
684
+ * @returns {void}
685
+ */
686
+ sync: (override?: boolean, dontSyncCurrent?: boolean) => Promise<void>;
687
+ destroy: () => Promise<boolean | void>;
688
+ /**
689
+ * @returns {{current:Track|null, previous:Track[], tracks:Track[]}}The Queue, but in a raw State, which allows easier handling for the QueueStoreManager
690
+ */
691
+ toJSON: () => StoredQueue;
692
+ /**
693
+ * Get the Total Duration of the Queue-Songs summed up
694
+ * @returns {number}
695
+ */
696
+ totalDuration: () => number;
697
+ };
698
+ /**
699
+ * Shuffles the current Queue, then saves it
700
+ * @returns Amount of Tracks in the Queue
701
+ */
702
+ shuffle(): Promise<number>;
703
+ /**
704
+ * Add a Track to the Queue, and after saved in the "db" it returns the amount of the Tracks
705
+ * @param {Track | Track[]} TrackOrTracks
706
+ * @param {number} index At what position to add the Track
707
+ * @returns {number} Queue-Size (for the next Tracks)
708
+ */
709
+ add(TrackOrTracks: Track | UnresolvedTrack | (Track | UnresolvedTrack)[], index?: number): any;
710
+ /**
711
+ * Splice the tracks in the Queue
712
+ * @param {number} index Where to remove the Track
713
+ * @param {number} amount How many Tracks to remove?
714
+ * @param {Track | Track[]} TrackOrTracks Want to Add more Tracks?
715
+ * @returns {Track} Spliced Track
716
+ */
717
+ splice(index: number, amount: number, TrackOrTracks?: Track | UnresolvedTrack | (Track | UnresolvedTrack)[]): any;
718
+ /**
719
+ * Remove stuff from the queue.tracks array
720
+ * - single Track | UnresolvedTrack
721
+ * - multiple Track | UnresovedTrack
722
+ * - at the index or multiple indexes
723
+ * - Since v2.7 the removed tracks get unshifted into the previous queue state instead of pushed (indexed at the start instead of end - as it should)
724
+ * @param removeQueryTrack
725
+ * @returns null (if nothing was removed) / { removed } where removed is an array with all removed elements
726
+ *
727
+ * @example
728
+ * ```js
729
+ * // remove single track
730
+ *
731
+ * const track = player.queue.tracks[4];
732
+ * await player.queue.remove(track);
733
+ *
734
+ * // if you already have the index you can straight up pass it too
735
+ * await player.queue.remove(4);
736
+ *
737
+ *
738
+ * // if you want to remove multiple tracks, e.g. from position 4 to position 10 you can do smt like this
739
+ * await player.queue.remove(player.queue.tracks.slice(4, 10)) // get's the tracks from 4 - 10, which then get's found in the remove function to be removed
740
+ *
741
+ * // I still highly suggest to use .splice!
742
+ *
743
+ * await player.queue.splice(4, 10); // removes at index 4, 10 tracks
744
+ *
745
+ * await player.queue.splice(1, 1); // removes at index 1, 1 track
746
+ *
747
+ * await player.queue.splice(4, 0, ...tracks) // removes 0 tracks at position 4, and then inserts all tracks after position 4.
748
+ * ```
749
+ */
750
+ remove<T extends Track | UnresolvedTrack | number | Track[] | UnresolvedTrack[] | number[] | (number | Track | UnresolvedTrack)[]>(removeQueryTrack: T): Promise<{
751
+ removed: (Track | UnresolvedTrack)[];
752
+ } | null>;
753
+ /**
754
+ * Shifts the previous array, to return the last previous track & thus remove it from the previous queue
755
+ * @returns
756
+ *
757
+ * @example
758
+ * ```js
759
+ * // example on how to play the previous track again
760
+ * const previous = await player.queue.shiftPrevious(); // get the previous track and remove it from the previous queue array!!
761
+ * if(!previous) return console.error("No previous track found");
762
+ * await player.play({ clientTrack: previous }); // play it again
763
+ * ```
764
+ */
765
+ shiftPrevious(): Promise<Track>;
1572
766
  }
1573
- type LavalinkNodeIdentifier = string;
1574
- interface NodeManagerEvents {
767
+
768
+ declare class Player {
769
+ /** Filter Manager per player */
770
+ filterManager: FilterManager;
771
+ /** circular reference to the lavalink Manager from the Player for easier use */
772
+ LavalinkManager: LavalinkManager;
773
+ /** Player options currently used, mutation doesn't affect player's state */
774
+ options: PlayerOptions;
775
+ /** The lavalink node assigned the the player, don't change it manually */
776
+ node: LavalinkNode;
777
+ /** The queue from the player */
778
+ queue: Queue;
779
+ /** The Guild Id of the Player */
780
+ guildId: string;
781
+ /** The Voice Channel Id of the Player */
782
+ voiceChannelId: string | null;
783
+ /** The Text Channel Id of the Player */
784
+ textChannelId: string | null;
785
+ /** States if the Bot is supposed to be outputting audio */
786
+ playing: boolean;
787
+ /** States if the Bot is paused or not */
788
+ paused: boolean;
789
+ /** Repeat Mode of the Player */
790
+ repeatMode: RepeatMode;
791
+ /** Player's ping */
792
+ ping: {
793
+ lavalink: number;
794
+ ws: number;
795
+ };
796
+ /** The Display Volume */
797
+ volume: number;
798
+ /** The Volume Lavalink actually is outputting */
799
+ lavalinkVolume: number;
800
+ /** The current Positin of the player (Calculated) */
801
+ get position(): number;
802
+ /** The timestamp when the last position change update happened */
803
+ lastPositionChange: number | null;
804
+ /** The current Positin of the player (from Lavalink) */
805
+ lastPosition: number;
806
+ lastSavedPosition: number;
807
+ /** When the player was created [Timestamp in Ms] (from lavalink) */
808
+ createdTimeStamp: number;
809
+ /** The Player Connection's State (from Lavalink) */
810
+ connected: boolean | undefined;
811
+ /** Voice Server Data (from Lavalink) */
812
+ voice: LavalinkPlayerVoiceOptions;
813
+ voiceState: {
814
+ selfDeaf: boolean;
815
+ selfMute: boolean;
816
+ serverDeaf: boolean;
817
+ serverMute: boolean;
818
+ suppress: boolean;
819
+ };
820
+ /** Custom data for the player */
821
+ private readonly data;
1575
822
  /**
1576
- * Emitted when a Node is created.
1577
- * @event Manager.nodeManager#create
823
+ * Create a new Player
824
+ * @param options
825
+ * @param LavalinkManager
826
+ */
827
+ constructor(options: PlayerOptions, LavalinkManager: LavalinkManager, dontEmitPlayerCreateEvent?: boolean);
828
+ /**
829
+ * Set custom data.
830
+ * @param key
831
+ * @param value
832
+ */
833
+ set(key: string, value: unknown): this;
834
+ /**
835
+ * Get custom data.
836
+ * @param key
837
+ */
838
+ get<T>(key: string): T;
839
+ /**
840
+ * CLears all the custom data.
841
+ */
842
+ clearData(): this;
843
+ /**
844
+ * Get all custom Data
845
+ */
846
+ getAllData(): Record<string, unknown>;
847
+ /**
848
+ * Play the next track from the queue / a specific track, with playoptions for Lavalink
849
+ * @param options
850
+ */
851
+ play(options?: Partial<PlayOptions>): any;
852
+ /**
853
+ * Set the Volume for the Player
854
+ * @param volume The Volume in percent
855
+ * @param ignoreVolumeDecrementer If it should ignore the volumedecrementer option
856
+ */
857
+ setVolume(volume: number, ignoreVolumeDecrementer?: boolean): Promise<this>;
858
+ /**
859
+ * Search for a track
860
+ * @param query The query to search for
861
+ * @param requestUser The user that requested the track
862
+ * @param throwOnEmpty If an error should be thrown if no track is found
863
+ * @returns The search result
864
+ */
865
+ lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<LavaSearchResponse | SearchResult>;
866
+ /**
867
+ * Set the SponsorBlock
868
+ * @param segments The segments to set
869
+ */
870
+ setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
871
+ /**
872
+ * Get the SponsorBlock
873
+ */
874
+ getSponsorBlock(): Promise<SponsorBlockSegment[]>;
875
+ /**
876
+ * Delete the SponsorBlock
877
+ */
878
+ deleteSponsorBlock(): Promise<void>;
879
+ /**
880
+ *
881
+ * @param query Query for your data
882
+ * @param requestUser
883
+ */
884
+ search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<UnresolvedSearchResult | SearchResult>;
885
+ /**
886
+ * Pause the player
887
+ */
888
+ pause(): Promise<this>;
889
+ /**
890
+ * Resume the Player
891
+ */
892
+ resume(): Promise<this>;
893
+ /**
894
+ * Seek to a specific Position
895
+ * @param position
896
+ */
897
+ seek(position: number): Promise<this>;
898
+ /**
899
+ * Set the Repeatmode of the Player
900
+ * @param repeatMode
901
+ */
902
+ setRepeatMode(repeatMode: RepeatMode): Promise<this>;
903
+ /**
904
+ * Skip the current song, or a specific amount of songs
905
+ * @param amount provide the index of the next track to skip to
906
+ */
907
+ skip(skipTo?: number, throwError?: boolean): Promise<this>;
908
+ /**
909
+ * Clears the queue and stops playing. Does not destroy the Player and not leave the channel
910
+ * @returns
911
+ */
912
+ stopPlaying(clearQueue?: boolean, executeAutoplay?: boolean): Promise<this>;
913
+ /**
914
+ * Connects the Player to the Voice Channel
915
+ * @returns
916
+ */
917
+ connect(): Promise<this>;
918
+ changeVoiceState(data: {
919
+ voiceChannelId?: string;
920
+ selfDeaf?: boolean;
921
+ selfMute?: boolean;
922
+ }): Promise<this>;
923
+ /**
924
+ * Disconnects the Player from the Voice Channel, but keeps the player in the cache
925
+ * @param force If false it throws an error, if player thinks it's already disconnected
926
+ * @returns
927
+ */
928
+ disconnect(force?: boolean): Promise<this>;
929
+ /**
930
+ * Destroy the player and disconnect from the voice channel
931
+ */
932
+ destroy(reason?: DestroyReasons | string, disconnect?: boolean): Promise<this>;
933
+ /**
934
+ * Get the current lyrics of the track currently playing on the guild
935
+ * @param guildId The guild id to get the current lyrics for
936
+ * @param skipTrackSource If true, it will not try to get the lyrics from the track source
937
+ * @returns The current lyrics
938
+ * @example
939
+ * ```ts
940
+ * const lyrics = await player.getCurrentLyrics();
941
+ * ```
942
+ */
943
+ getCurrentLyrics(skipTrackSource?: boolean): Promise<LyricsResult>;
944
+ /**
945
+ * Get the lyrics of a specific track
946
+ * @param track The track to get the lyrics for
947
+ * @param skipTrackSource If true, it will not try to get the lyrics from the track source
948
+ * @returns The lyrics of the track
949
+ * @example
950
+ * ```ts
951
+ * const lyrics = await player.getLyrics(player.queue.tracks[0], true);
952
+ * ```
1578
953
  */
1579
- "create": (node: LavalinkNode) => void;
954
+ getLyrics(track: Track, skipTrackSource?: boolean): Promise<LyricsResult>;
1580
955
  /**
1581
- * Emitted when a Node is destroyed.
1582
- * @event Manager.nodeManager#destroy
956
+ * Subscribe to the lyrics event on a specific guild to active live lyrics events
957
+ * @returns The unsubscribe function
958
+ * @example
959
+ * ```ts
960
+ * const lyrics = await player.subscribeLyrics();
961
+ * ```
1583
962
  */
1584
- "destroy": (node: LavalinkNode, destroyReason?: DestroyReasonsType) => void;
963
+ subscribeLyrics(): Promise<unknown>;
1585
964
  /**
1586
- * Emitted when a Node is connected.
1587
- * @event Manager.nodeManager#connect
965
+ * Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
966
+ * @returns The unsubscribe function
967
+ * @example
968
+ * ```ts
969
+ * const lyrics = await player.unsubscribeLyrics();
970
+ * ```
1588
971
  */
1589
- "connect": (node: LavalinkNode) => void;
1590
- /**
1591
- * Emitted when a Node is reconnecting.
1592
- * @event Manager.nodeManager#reconnecting
1593
- */
1594
- "reconnecting": (node: LavalinkNode) => void;
972
+ unsubscribeLyrics(): Promise<void>;
1595
973
  /**
1596
- * Emitted When a node starts to reconnect (if you have a reconnection delay, the reconnecting event will be emitted after the retryDelay.)
1597
- * Useful to check wether the internal node reconnect system works or not
1598
- * @event Manager.nodeManager#reconnectinprogress
974
+ * Move the player on a different Audio-Node
975
+ * @param newNode New Node / New Node Id
976
+ * @param checkSources If it should check if the sources are supported by the new node @default true
977
+ * @return The new Node Id
978
+ * @example
979
+ * ```ts
980
+ * const changeNode = await player.changeNode(newNode, true);
981
+ * ```
1599
982
  */
1600
- "reconnectinprogress": (node: LavalinkNode) => void;
1601
- /**
1602
- * Emitted when a Node is disconnects.
1603
- * @event Manager.nodeManager#disconnect
1604
- */
1605
- "disconnect": (node: LavalinkNode, reason: {
1606
- code?: number;
1607
- reason?: string;
1608
- }) => void;
1609
- /**
1610
- * Emitted when a Node is error.
1611
- * @event Manager.nodeManager#error
1612
- */
1613
- "error": (node: LavalinkNode, error: Error, payload?: unknown) => void;
1614
- /**
1615
- * Emits every single Node event.
1616
- * @event Manager.nodeManager#raw
1617
- */
1618
- "raw": (node: LavalinkNode, payload: unknown) => void;
983
+ changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
1619
984
  /**
1620
- * Emits when the node connects resumed. You then need to create all players within this event for your usecase.
1621
- * Aka for that you need to be able to save player data like vc channel + text channel in a db and then sync it again
1622
- * @event Manager.nodeManager#nodeResumed
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
+ * @param node the id of the node to move to
987
+ * @returns the player
988
+ * @throws RangeError if there is no available nodes.
989
+ * @throws Error if the node to move to is the same as the current node.
1623
990
  */
1624
- "resumed": (node: LavalinkNode, payload: {
1625
- resumed: true;
1626
- sessionId: string;
1627
- op: "ready";
1628
- }, players: LavalinkPlayer[] | InvalidLavalinkRestRequest) => void;
991
+ moveNode(node?: string): Promise<string | this>;
992
+ /** Converts the Player including Queue to a Json state */
993
+ toJSON(): PlayerJson;
1629
994
  }
1630
995
 
1631
996
  declare const TrackSymbol: unique symbol;
@@ -1711,464 +1076,1107 @@ declare class ManagerUtils {
1711
1076
  types: string[];
1712
1077
  source: any;
1713
1078
  };
1714
- validateSourceString(node: LavalinkNode, sourceString: SearchPlatform): void;
1079
+ validateSourceString(node: LavalinkNode, sourceString: SearchPlatform): void;
1080
+ }
1081
+ /**
1082
+ * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
1083
+ *
1084
+ * @internal
1085
+ */
1086
+ interface MiniMap<K, V> extends Map<K, V> {
1087
+ constructor: MiniMapConstructor;
1088
+ }
1089
+ declare class MiniMap<K, V> extends Map<K, V> {
1090
+ constructor(data?: [K, V][]);
1091
+ /**
1092
+ * Identical to
1093
+ * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
1094
+ * but returns a MiniMap instead of an Array.
1095
+ *
1096
+ * @param fn The function to test with (should return boolean)
1097
+ * @param thisArg Value to use as `this` when executing function
1098
+ *
1099
+ * @example
1100
+ * miniMap.filter(user => user.username === 'Bob');
1101
+ */
1102
+ filter<K2 extends K>(fn: (value: V, key: K, miniMap: this) => key is K2): MiniMap<K2, V>;
1103
+ filter<V2 extends V>(fn: (value: V, key: K, miniMap: this) => value is V2): MiniMap<K, V2>;
1104
+ filter(fn: (value: V, key: K, miniMap: this) => boolean): MiniMap<K, V>;
1105
+ filter<This, K2 extends K>(fn: (this: This, value: V, key: K, miniMap: this) => key is K2, thisArg: This): MiniMap<K2, V>;
1106
+ filter<This, V2 extends V>(fn: (this: This, value: V, key: K, miniMap: this) => value is V2, thisArg: This): MiniMap<K, V2>;
1107
+ filter<This>(fn: (this: This, value: V, key: K, miniMap: this) => boolean, thisArg: This): MiniMap<K, V>;
1108
+ toJSON(): [K, V][];
1109
+ /**
1110
+ * Maps each item to another value into an array. Identical in behavior to
1111
+ * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
1112
+ *
1113
+ * @param fn Function that produces an element of the new array, taking three arguments
1114
+ * @param thisArg Value to use as `this` when executing function
1115
+ *
1116
+ * @example
1117
+ * miniMap.map(user => user.tag);
1118
+ */
1119
+ map<T>(fn: (value: V, key: K, miniMap: this) => T): T[];
1120
+ map<This, T>(fn: (this: This, value: V, key: K, miniMap: this) => T, thisArg: This): T[];
1121
+ }
1122
+ declare function queueTrackEnd(player: Player, dontShiftQueue?: boolean): Promise<Track>;
1123
+ declare function safeStringify(obj: any, padding?: number): string;
1124
+
1125
+ /** Helper for generating Opaque types. */
1126
+ type Opaque<T, K> = T & {
1127
+ __opaque__: K;
1128
+ };
1129
+ /** Opqaue tyep for integernumber */
1130
+ type IntegerNumber = Opaque<number, 'Int'>;
1131
+ /** Opqaue tyep for floatnumber */
1132
+ type FloatNumber = Opaque<number, 'Float'>;
1133
+ type LavaSrcSearchPlatformBase = "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "dzrec" | "ymsearch" | "ymrec" | "vksearch" | "vkrec" | "tdsearch" | "tdrec" | "qbsearch" | "qbisrc" | "qbrec" | "pdsearch" | "pdisrc" | "pdrec";
1134
+ type LavaSrcSearchPlatform = LavaSrcSearchPlatformBase | "ftts";
1135
+ type JioSaavnSearchPlatform = "jssearch" | "jsrec";
1136
+ type DuncteSearchPlatform = "speak" | "phsearch" | "pornhub" | "porn" | "tts";
1137
+ type LavalinkClientSearchPlatform = "bcsearch";
1138
+ type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
1139
+ type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | "bcsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | JioSaavnSearchPlatform | LavalinkClientSearchPlatform;
1140
+ type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
1141
+ type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
1142
+ "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "vk" | "vk music" | "vkmusic" | "tidal" | "tidal music" | "qobuz" | "pandora" | "pd" | "pandora music" | "pandoramusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform | "js" | "jiosaavn" | "td" | "tidal" | "tdrec";
1143
+ type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
1144
+ type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "jiosaavn" | "appleMusic" | "tidal" | "PandoraTrackRegex" | "PandoraAlbumRegex" | "PandoraArtistRegex" | "PandoraPlaylistRegex" | "AllPandoraRegex" | "TwitchTv" | "vimeo";
1145
+ interface PlaylistInfo {
1146
+ /** The playlist name */
1147
+ name: string;
1148
+ /** The playlist title (same as name) */
1149
+ title: string;
1150
+ /** The playlist Author */
1151
+ author?: string;
1152
+ /** The playlist Thumbnail */
1153
+ thumbnail?: string;
1154
+ /** A Uri to the playlist */
1155
+ uri?: string;
1156
+ /** The playlist selected track. */
1157
+ selectedTrack: Track | null;
1158
+ /** The duration of the entire playlist. (calcualted) */
1159
+ duration: number;
1160
+ }
1161
+ interface SearchResult {
1162
+ loadType: LoadTypes;
1163
+ exception: Exception | null;
1164
+ pluginInfo: PluginInfo;
1165
+ playlist: PlaylistInfo | null;
1166
+ tracks: Track[];
1167
+ }
1168
+ interface UnresolvedSearchResult {
1169
+ loadType: LoadTypes;
1170
+ exception: Exception | null;
1171
+ pluginInfo: PluginInfo;
1172
+ playlist: PlaylistInfo | null;
1173
+ tracks: UnresolvedTrack[];
1174
+ }
1175
+ /**
1176
+ * @internal
1177
+ */
1178
+ interface MiniMapConstructor {
1179
+ new (): MiniMap<unknown, unknown>;
1180
+ new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): MiniMap<K, V>;
1181
+ new <K, V>(iterable: Iterable<readonly [K, V]>): MiniMap<K, V>;
1182
+ readonly prototype: MiniMap<unknown, unknown>;
1183
+ readonly [Symbol.species]: MiniMapConstructor;
1184
+ }
1185
+ type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents | LyricsEvent;
1186
+ type Severity = "COMMON" | "SUSPICIOUS" | "FAULT";
1187
+ interface Exception {
1188
+ /** Severity of the error */
1189
+ severity: Severity;
1190
+ /** Nodejs Error */
1191
+ error?: Error;
1192
+ /** Message by lavalink */
1193
+ message: string;
1194
+ /** Cause by lavalink */
1195
+ cause: string;
1196
+ /** causeStackTrace by lavalink */
1197
+ causeStackTrace: string;
1198
+ }
1199
+ interface PlayerEvent {
1200
+ op: "event";
1201
+ type: PlayerEventType;
1202
+ guildId: string;
1203
+ }
1204
+ interface TrackStartEvent extends PlayerEvent {
1205
+ type: "TrackStartEvent";
1206
+ track: LavalinkTrack;
1207
+ }
1208
+ interface TrackEndEvent extends PlayerEvent {
1209
+ type: "TrackEndEvent";
1210
+ track: LavalinkTrack;
1211
+ reason: TrackEndReason;
1212
+ }
1213
+ interface TrackExceptionEvent extends PlayerEvent {
1214
+ type: "TrackExceptionEvent";
1215
+ exception?: Exception;
1216
+ track: LavalinkTrack;
1217
+ error: string;
1218
+ }
1219
+ interface TrackStuckEvent extends PlayerEvent {
1220
+ type: "TrackStuckEvent";
1221
+ thresholdMs: number;
1222
+ track: LavalinkTrack;
1223
+ }
1224
+ interface WebSocketClosedEvent extends PlayerEvent {
1225
+ type: "WebSocketClosedEvent";
1226
+ code: number;
1227
+ byRemote: boolean;
1228
+ reason: string;
1229
+ }
1230
+ /**
1231
+ * Types & Events for Sponsorblock-plugin from Lavalink: https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
1232
+ */
1233
+ type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded;
1234
+ type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
1235
+ interface SponsorBlockSegmentsLoaded extends PlayerEvent {
1236
+ type: "SegmentsLoaded";
1237
+ segments: {
1238
+ category: string;
1239
+ start: number;
1240
+ end: number;
1241
+ }[];
1242
+ }
1243
+ interface SponsorBlockSegmentSkipped extends PlayerEvent {
1244
+ type: "SegmentSkipped";
1245
+ segment: {
1246
+ category: string;
1247
+ start: number;
1248
+ end: number;
1249
+ };
1250
+ }
1251
+ interface SponsorBlockChapterStarted extends PlayerEvent {
1252
+ type: "ChapterStarted";
1253
+ /** The Chapter which started */
1254
+ chapter: {
1255
+ /** The Name of the Chapter */
1256
+ name: string;
1257
+ start: number;
1258
+ end: number;
1259
+ duration: number;
1260
+ };
1261
+ }
1262
+ interface SponsorBlockChaptersLoaded extends PlayerEvent {
1263
+ type: "ChaptersLoaded";
1264
+ /** All Chapters loaded */
1265
+ chapters: {
1266
+ /** The Name of the Chapter */
1267
+ name: string;
1268
+ start: number;
1269
+ end: number;
1270
+ duration: number;
1271
+ }[];
1715
1272
  }
1716
1273
  /**
1717
- * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
1718
- *
1719
- * @internal
1274
+ * Types & Events for Lyrics plugin from Lavalink: https://github.com/topi314/LavaLyrics
1720
1275
  */
1721
- interface MiniMap<K, V> extends Map<K, V> {
1722
- constructor: MiniMapConstructor;
1276
+ type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent;
1277
+ type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
1278
+ interface LyricsFoundEvent extends PlayerEvent {
1279
+ /** The lyricsfound event */
1280
+ type: "LyricsFoundEvent";
1281
+ /** The guildId */
1282
+ guildId: string;
1283
+ /** The lyrics */
1284
+ lyrics: LyricsResult;
1723
1285
  }
1724
- declare class MiniMap<K, V> extends Map<K, V> {
1725
- constructor(data?: [K, V][]);
1726
- /**
1727
- * Identical to
1728
- * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
1729
- * but returns a MiniMap instead of an Array.
1730
- *
1731
- * @param fn The function to test with (should return boolean)
1732
- * @param thisArg Value to use as `this` when executing function
1733
- *
1734
- * @example
1735
- * miniMap.filter(user => user.username === 'Bob');
1736
- */
1737
- filter<K2 extends K>(fn: (value: V, key: K, miniMap: this) => key is K2): MiniMap<K2, V>;
1738
- filter<V2 extends V>(fn: (value: V, key: K, miniMap: this) => value is V2): MiniMap<K, V2>;
1739
- filter(fn: (value: V, key: K, miniMap: this) => boolean): MiniMap<K, V>;
1740
- filter<This, K2 extends K>(fn: (this: This, value: V, key: K, miniMap: this) => key is K2, thisArg: This): MiniMap<K2, V>;
1741
- filter<This, V2 extends V>(fn: (this: This, value: V, key: K, miniMap: this) => value is V2, thisArg: This): MiniMap<K, V2>;
1742
- filter<This>(fn: (this: This, value: V, key: K, miniMap: this) => boolean, thisArg: This): MiniMap<K, V>;
1743
- toJSON(): [K, V][];
1744
- /**
1745
- * Maps each item to another value into an array. Identical in behavior to
1746
- * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
1747
- *
1748
- * @param fn Function that produces an element of the new array, taking three arguments
1749
- * @param thisArg Value to use as `this` when executing function
1750
- *
1751
- * @example
1752
- * miniMap.map(user => user.tag);
1753
- */
1754
- map<T>(fn: (value: V, key: K, miniMap: this) => T): T[];
1755
- map<This, T>(fn: (this: This, value: V, key: K, miniMap: this) => T, thisArg: This): T[];
1286
+ interface LyricsNotFoundEvent extends PlayerEvent {
1287
+ /**The lyricsnotfound event*/
1288
+ type: "LyricsNotFoundEvent";
1289
+ /**The guildId*/
1290
+ guildId: string;
1756
1291
  }
1757
- declare function queueTrackEnd(player: Player, dontShiftQueue?: boolean): Promise<Track>;
1758
- declare function safeStringify(obj: any, padding?: number): string;
1759
-
1760
- /** Helper for generating Opaque types. */
1761
- type Opaque<T, K> = T & {
1762
- __opaque__: K;
1763
- };
1764
- /** Opqaue tyep for integernumber */
1765
- type IntegerNumber = Opaque<number, 'Int'>;
1766
- /** Opqaue tyep for floatnumber */
1767
- type FloatNumber = Opaque<number, 'Float'>;
1768
- type LavaSrcSearchPlatformBase = "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "dzrec" | "ymsearch" | "ymrec" | "vksearch" | "vkrec" | "tdsearch" | "tdrec" | "qbsearch" | "qbisrc" | "qbrec" | "pdsearch" | "pdisrc" | "pdrec";
1769
- type LavaSrcSearchPlatform = LavaSrcSearchPlatformBase | "ftts";
1770
- type JioSaavnSearchPlatform = "jssearch" | "jsrec";
1771
- type DuncteSearchPlatform = "speak" | "phsearch" | "pornhub" | "porn" | "tts";
1772
- type LavalinkClientSearchPlatform = "bcsearch";
1773
- type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
1774
- type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | "bcsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | JioSaavnSearchPlatform | LavalinkClientSearchPlatform;
1775
- type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
1776
- type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
1777
- "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "vk" | "vk music" | "vkmusic" | "tidal" | "tidal music" | "qobuz" | "pandora" | "pd" | "pandora music" | "pandoramusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform | "js" | "jiosaavn" | "td" | "tidal" | "tdrec";
1778
- type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
1779
- type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "jiosaavn" | "appleMusic" | "tidal" | "PandoraTrackRegex" | "PandoraAlbumRegex" | "PandoraArtistRegex" | "PandoraPlaylistRegex" | "AllPandoraRegex" | "TwitchTv" | "vimeo";
1780
- interface PlaylistInfo {
1781
- /** The playlist name */
1782
- name: string;
1783
- /** The playlist title (same as name) */
1784
- title: string;
1785
- /** The playlist Author */
1786
- author?: string;
1787
- /** The playlist Thumbnail */
1788
- thumbnail?: string;
1789
- /** A Uri to the playlist */
1790
- uri?: string;
1791
- /** The playlist selected track. */
1792
- selectedTrack: Track | null;
1793
- /** The duration of the entire playlist. (calcualted) */
1794
- duration: number;
1292
+ interface LyricsLineEvent extends PlayerEvent {
1293
+ /**The lyricsline event*/
1294
+ type: "LyricsLineEvent";
1295
+ /** The guildId */
1296
+ guildId: string;
1297
+ /** The line number */
1298
+ lineIndex: number;
1299
+ /** The line */
1300
+ line: LyricsLine;
1301
+ /**skipped is true if the line was skipped */
1302
+ skipped: boolean;
1303
+ }
1304
+ type LoadTypes = "track" | "playlist" | "search" | "error" | "empty";
1305
+ type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING" | "DESTROYING";
1306
+ type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType | LyricsEventType;
1307
+ type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
1308
+ interface InvalidLavalinkRestRequest {
1309
+ /** Rest Request Data for when it was made */
1310
+ timestamp: number;
1311
+ /** Status of the request */
1312
+ status: number;
1313
+ /** Specific Errro which was sent */
1314
+ error: string;
1315
+ /** Specific Message which was created */
1316
+ message?: string;
1317
+ /** The specific error trace from the request */
1318
+ trace?: unknown;
1319
+ /** Path of where it's from */
1320
+ path: string;
1321
+ }
1322
+ interface LavalinkPlayerVoice {
1323
+ /** The Voice Token */
1324
+ token: string;
1325
+ /** The Voice Server Endpoint */
1326
+ endpoint: string;
1327
+ /** The Voice SessionId */
1328
+ sessionId: string;
1329
+ /** Wether or not the player is connected */
1330
+ connected?: boolean;
1331
+ /** The Ping to the voice server */
1332
+ ping?: number;
1333
+ }
1334
+ type LavalinkPlayerVoiceOptions = Omit<LavalinkPlayerVoice, 'connected' | 'ping'>;
1335
+ interface FailingAddress {
1336
+ /** The failing address */
1337
+ failingAddress: string;
1338
+ /** The timestamp when the address failed */
1339
+ failingTimestamp: number;
1340
+ /** The timestamp when the address failed as a pretty string */
1341
+ failingTime: string;
1342
+ }
1343
+ type RoutePlannerTypes = "RotatingIpRoutePlanner" | "NanoIpRoutePlanner" | "RotatingNanoIpRoutePlanner" | "BalancingIpRoutePlanner";
1344
+ interface RoutePlanner {
1345
+ class?: RoutePlannerTypes;
1346
+ details?: {
1347
+ /** The ip block being used */
1348
+ ipBlock: {
1349
+ /** The type of the ip block */
1350
+ type: "Inet4Address" | "Inet6Address";
1351
+ /** The size of the ip block */
1352
+ size: string;
1353
+ };
1354
+ /** The failing addresses */
1355
+ failingAddresses: FailingAddress[];
1356
+ /** The number of rotations */
1357
+ rotateIndex?: string;
1358
+ /** The current offset in the block */
1359
+ ipIndex?: string;
1360
+ /** The current address being used */
1361
+ currentAddress?: string;
1362
+ /** The current offset in the ip block */
1363
+ currentAddressIndex?: string;
1364
+ /** The information in which /64 block ips are chosen. This number increases on each ban. */
1365
+ blockIndex?: string;
1366
+ };
1367
+ }
1368
+ interface Session {
1369
+ /** Wether or not session is resuming or not */
1370
+ resuming: boolean;
1371
+ /** For how long a session is lasting while not connected */
1372
+ timeout: number;
1373
+ }
1374
+ interface GuildShardPayload {
1375
+ /** The OP code */
1376
+ op: number;
1377
+ /** Data to send */
1378
+ d: {
1379
+ /** Guild id to apply voice settings */
1380
+ guild_id: string;
1381
+ /** channel to move/connect to, or null to leave it */
1382
+ channel_id: string | null;
1383
+ /** wether or not mute yourself */
1384
+ self_mute: boolean;
1385
+ /** wether or not deafen yourself */
1386
+ self_deaf: boolean;
1387
+ };
1388
+ }
1389
+ interface PlayerUpdateInfo {
1390
+ /** guild id of the player */
1391
+ guildId: string;
1392
+ /** Player options to provide to lavalink */
1393
+ playerOptions: LavalinkPlayOptions;
1394
+ /** Whether or not replace the current track with the new one (true is recommended) */
1395
+ noReplace?: boolean;
1396
+ }
1397
+ interface LavalinkPlayer {
1398
+ /** Guild Id of the player */
1399
+ guildId: string;
1400
+ /** IF playing a track, all of the track information */
1401
+ track?: LavalinkTrack;
1402
+ /** Lavalink volume (mind volumedecrementer) */
1403
+ volume: number;
1404
+ /** Wether it's paused or not */
1405
+ paused: boolean;
1406
+ /** Voice Endpoint data */
1407
+ voice: LavalinkPlayerVoice;
1408
+ /** All Audio Filters */
1409
+ filters: Partial<LavalinkFilterData>;
1410
+ /** Lavalink-Voice-State Variables */
1411
+ state: {
1412
+ /** Time since connection established */
1413
+ time: number;
1414
+ /** Position of the track */
1415
+ position: number;
1416
+ /** COnnected or not */
1417
+ connected: boolean;
1418
+ /** Ping to voice server */
1419
+ ping: number;
1420
+ };
1421
+ }
1422
+ interface ChannelDeletePacket {
1423
+ /** Packet key for channel delete */
1424
+ t: "CHANNEL_DELETE";
1425
+ /** data which is sent and relevant */
1426
+ d: {
1427
+ /** guild id */
1428
+ guild_id: string;
1429
+ /** Channel id */
1430
+ id: string;
1431
+ };
1432
+ }
1433
+ interface VoiceState {
1434
+ /** OP key from lavalink */
1435
+ op: "voiceUpdate";
1436
+ /** GuildId provided by lavalink */
1437
+ guildId: string;
1438
+ /** Event data */
1439
+ event: VoiceServer;
1440
+ /** Session Id of the voice connection */
1441
+ sessionId?: string;
1442
+ /** guild id of the voice channel */
1443
+ guild_id: string;
1444
+ /** user id from the voice connection */
1445
+ user_id: string;
1446
+ /** Session Id of the voice connection */
1447
+ session_id: string;
1448
+ /** Voice Channel Id */
1449
+ channel_id: string;
1450
+ /** Server Mute status */
1451
+ mute: boolean;
1452
+ /** Server Deaf status */
1453
+ deaf: boolean;
1454
+ /** Self Deaf status */
1455
+ self_deaf: boolean;
1456
+ /** Self Mute status */
1457
+ self_mute: boolean;
1458
+ /** Self Video (Camera) status */
1459
+ self_video: boolean;
1460
+ /** Self Stream status */
1461
+ self_stream: boolean;
1462
+ /** Wether the user requests to speak (stage channel) */
1463
+ request_to_speak_timestamp: boolean;
1464
+ /** Self suppressed status (stage channel) */
1465
+ suppress: boolean;
1795
1466
  }
1796
- interface SearchResult {
1797
- loadType: LoadTypes;
1798
- exception: Exception | null;
1467
+ /** The Base64 decodes tring by lavalink */
1468
+ type Base64 = string;
1469
+ interface VoiceServer {
1470
+ /** Voice Token */
1471
+ token: string;
1472
+ /** Guild Id of the voice server connection */
1473
+ guild_id: string;
1474
+ /** Server Endpoint */
1475
+ endpoint: string;
1476
+ }
1477
+ interface VoicePacket {
1478
+ /** Voice Packet Keys to send */
1479
+ t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE";
1480
+ /** Voice Packets to send */
1481
+ d: VoiceState | VoiceServer;
1482
+ }
1483
+ interface NodeMessage extends NodeStats {
1484
+ /** The type of the event */
1485
+ type: PlayerEventType;
1486
+ /** what ops are applying to that event */
1487
+ op: "stats" | "playerUpdate" | "event";
1488
+ /** The specific guild id for that message */
1489
+ guildId: string;
1490
+ }
1491
+ /** Specific types to filter for lavasearch, will be filtered to correct types */
1492
+ type LavaSearchType = "track" | "album" | "artist" | "playlist" | "text" | "tracks" | "albums" | "artists" | "playlists" | "texts";
1493
+ interface LavaSearchFilteredResponse {
1494
+ /** The Information of a playlist provided by lavasearch */
1495
+ info: PlaylistInfo;
1496
+ /** additional plugin information */
1799
1497
  pluginInfo: PluginInfo;
1800
- playlist: PlaylistInfo | null;
1498
+ /** List of tracks */
1801
1499
  tracks: Track[];
1802
1500
  }
1803
- interface UnresolvedSearchResult {
1804
- loadType: LoadTypes;
1805
- exception: Exception | null;
1501
+ interface LavaSearchResponse {
1502
+ /** An array of tracks, only present if track is in types */
1503
+ tracks: Track[];
1504
+ /** An array of albums, only present if album is in types */
1505
+ albums: LavaSearchFilteredResponse[];
1506
+ /** An array of artists, only present if artist is in types */
1507
+ artists: LavaSearchFilteredResponse[];
1508
+ /** An array of playlists, only present if playlist is in types */
1509
+ playlists: LavaSearchFilteredResponse[];
1510
+ /** An array of text results, only present if text is in types */
1511
+ texts: {
1512
+ text: string;
1513
+ pluginInfo: PluginInfo;
1514
+ }[];
1515
+ /** Addition result data provided by plugins */
1806
1516
  pluginInfo: PluginInfo;
1807
- playlist: PlaylistInfo | null;
1808
- tracks: UnresolvedTrack[];
1517
+ }
1518
+ /** SearchQuery Object for raw lavalink requests */
1519
+ type SearchQuery = {
1520
+ /** lavalink search Query / identifier string */
1521
+ query: string;
1522
+ /** Extra url query params to use, e.g. for flowertts */
1523
+ extraQueryUrlParams?: URLSearchParams;
1524
+ /** Source to append to the search query string */
1525
+ source?: SearchPlatform;
1526
+ } | /** Our just the search query / identifier string */ string;
1527
+ /** SearchQuery Object for Lavalink LavaSearch Plugin requests */
1528
+ type LavaSearchQuery = {
1529
+ /** lavalink search Query / identifier string */
1530
+ query: string;
1531
+ /** Source to append to the search query string */
1532
+ source: LavaSrcSearchPlatformBase;
1533
+ /** The Types to filter the search to */
1534
+ types?: LavaSearchType[];
1535
+ };
1536
+ type Awaitable<T> = Promise<T> | T;
1537
+
1538
+ /** The Audio Outputs type */
1539
+ type AudioOutputs = "mono" | "stereo" | "left" | "right";
1540
+ /** The "active" / "disabled" Player Filters */
1541
+ interface PlayerFilters {
1542
+ /** Sets nightcore to false, and vaporwave to false */
1543
+ custom: boolean;
1544
+ /** Sets custom to false, and vaporwave to false */
1545
+ nightcore: boolean;
1546
+ /** Sets custom to false, and nightcore to false */
1547
+ vaporwave: boolean;
1548
+ /** If rotation filter is enabled / not */
1549
+ rotation: boolean;
1550
+ /** if karaoke filter is enabled / not */
1551
+ karaoke: boolean;
1552
+ /** if tremolo filter is enabled / not */
1553
+ tremolo: boolean;
1554
+ /** if vibrato filter is enabled / not */
1555
+ vibrato: boolean;
1556
+ lowPass: boolean;
1557
+ /** audio Output (default stereo, mono sounds the fullest and best for not-stereo tracks) */
1558
+ audioOutput: AudioOutputs;
1559
+ /** Lavalink Volume FILTER (not player Volume, think of it as a gain booster) */
1560
+ volume: boolean;
1561
+ /** Filters for the Lavalink Filter Plugin */
1562
+ lavalinkFilterPlugin: {
1563
+ /** if echo filter is enabled / not */
1564
+ echo: boolean;
1565
+ /** if reverb filter is enabled / not */
1566
+ reverb: boolean;
1567
+ };
1568
+ lavalinkLavaDspxPlugin: {
1569
+ /** if lowPass filter is enabled / not */
1570
+ lowPass: boolean;
1571
+ /** if highPass filter is enabled / not */
1572
+ highPass: boolean;
1573
+ /** if normalization filter is enabled / not */
1574
+ normalization: boolean;
1575
+ /** if echo filter is enabled / not */
1576
+ echo: boolean;
1577
+ };
1809
1578
  }
1810
1579
  /**
1811
- * @internal
1580
+ * There are 15 bands (0-14) that can be changed.
1581
+ * "gain" is the multiplier for the given band.
1582
+ * The default value is 0.
1583
+ * Valid values range from -0.25 to 1.0, where -0.25 means the given band is completely muted, and 0.25 means it is doubled.
1584
+ * Modifying the gain could also change the volume of the output.
1812
1585
  */
1813
- interface MiniMapConstructor {
1814
- new (): MiniMap<unknown, unknown>;
1815
- new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): MiniMap<K, V>;
1816
- new <K, V>(iterable: Iterable<readonly [K, V]>): MiniMap<K, V>;
1817
- readonly prototype: MiniMap<unknown, unknown>;
1818
- readonly [Symbol.species]: MiniMapConstructor;
1586
+ interface EQBand {
1587
+ /** On what band position (0-14) it should work */
1588
+ band: IntegerNumber | number;
1589
+ /** The gain (-0.25 to 1.0) */
1590
+ gain: FloatNumber | number;
1819
1591
  }
1820
- type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents | LyricsEvent;
1821
- type Severity = "COMMON" | "SUSPICIOUS" | "FAULT";
1822
- interface Exception {
1823
- /** Severity of the error */
1824
- severity: Severity;
1825
- /** Nodejs Error */
1826
- error?: Error;
1827
- /** Message by lavalink */
1828
- message: string;
1829
- /** Cause by lavalink */
1830
- cause: string;
1831
- /** causeStackTrace by lavalink */
1832
- causeStackTrace: string;
1592
+ /**
1593
+ * Uses equalization to eliminate part of a band, usually targeting vocals.
1594
+ */
1595
+ interface KaraokeFilter {
1596
+ /** The level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
1597
+ level?: number;
1598
+ /** The mono level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
1599
+ monoLevel?: number;
1600
+ /** The filter band (in Hz) */
1601
+ filterBand?: number;
1602
+ /** The filter width */
1603
+ filterWidth?: number;
1833
1604
  }
1834
- interface PlayerEvent {
1835
- op: "event";
1836
- type: PlayerEventType;
1837
- guildId: string;
1605
+ /**
1606
+ * Changes the speed, pitch, and rate
1607
+ */
1608
+ interface TimescaleFilter {
1609
+ /** The playback speed 0.0 ≤ x */
1610
+ speed?: number;
1611
+ /** The pitch 0.0 ≤ x */
1612
+ pitch?: number;
1613
+ /** The rate 0.0 ≤ x */
1614
+ rate?: number;
1838
1615
  }
1839
- interface TrackStartEvent extends PlayerEvent {
1840
- type: "TrackStartEvent";
1841
- track: LavalinkTrack;
1616
+ /**
1617
+ * Uses amplification to create a shuddering effect, where the volume quickly oscillates.
1618
+ * Demo: https://en.wikipedia.org/wiki/File:Fuse_Electronics_Tremolo_MK-III_Quick_Demo.ogv
1619
+ */
1620
+ interface TremoloFilter {
1621
+ /** The frequency 0.0 < x */
1622
+ frequency?: number;
1623
+ /** The tremolo depth 0.0 < x ≤ 1.0 */
1624
+ depth?: number;
1842
1625
  }
1843
- interface TrackEndEvent extends PlayerEvent {
1844
- type: "TrackEndEvent";
1845
- track: LavalinkTrack;
1846
- reason: TrackEndReason;
1626
+ /**
1627
+ * Similar to tremolo. While tremolo oscillates the volume, vibrato oscillates the pitch.
1628
+ */
1629
+ interface VibratoFilter {
1630
+ /** The frequency 0.0 < x ≤ 14.0 */
1631
+ frequency?: number;
1632
+ /** The vibrato depth 0.0 < x ≤ 1.0 */
1633
+ depth?: number;
1847
1634
  }
1848
- interface TrackExceptionEvent extends PlayerEvent {
1849
- type: "TrackExceptionEvent";
1850
- exception?: Exception;
1851
- track: LavalinkTrack;
1852
- error: string;
1635
+ /**
1636
+ * Rotates the sound around the stereo channels/user headphones (aka Audio Panning).
1637
+ * It can produce an effect similar to https://youtu.be/QB9EB8mTKcc (without the reverb).
1638
+ */
1639
+ interface RotationFilter {
1640
+ /** The frequency of the audio rotating around the listener in Hz. 0.2 is similar to the example video above */
1641
+ rotationHz?: number;
1853
1642
  }
1854
- interface TrackStuckEvent extends PlayerEvent {
1855
- type: "TrackStuckEvent";
1856
- thresholdMs: number;
1857
- track: LavalinkTrack;
1643
+ /**
1644
+ * Distortion effect. It can generate some pretty unique audio effects.
1645
+ */
1646
+ interface DistortionFilter {
1647
+ sinOffset?: number;
1648
+ sinScale?: number;
1649
+ cosOffset?: number;
1650
+ cosScale?: number;
1651
+ tanOffset?: number;
1652
+ tanScale?: number;
1653
+ offset?: number;
1654
+ scale?: number;
1858
1655
  }
1859
- interface WebSocketClosedEvent extends PlayerEvent {
1860
- type: "WebSocketClosedEvent";
1861
- code: number;
1862
- byRemote: boolean;
1863
- reason: string;
1656
+ /**
1657
+ * Mixes both channels (left and right), with a configurable factor on how much each channel affects the other.
1658
+ * With the defaults, both channels are kept independent of each other.
1659
+ * Setting all factors to 0.5 means both channels get the same audio.
1660
+ */
1661
+ interface ChannelMixFilter {
1662
+ /** The left to left channel mix factor (0.0 ≤ x ≤ 1.0) */
1663
+ leftToLeft?: number;
1664
+ /** The left to right channel mix factor (0.0 ≤ x ≤ 1.0) */
1665
+ leftToRight?: number;
1666
+ /** The right to left channel mix factor (0.0 ≤ x ≤ 1.0) */
1667
+ rightToLeft?: number;
1668
+ /** The right to right channel mix factor (0.0 ≤ x ≤ 1.0) */
1669
+ rightToRight?: number;
1864
1670
  }
1865
1671
  /**
1866
- * Types & Events for Sponsorblock-plugin from Lavalink: https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
1672
+ * Higher frequencies get suppressed, while lower frequencies pass through this filter, thus the name low pass.
1673
+ * Any smoothing values equal to or less than 1.0 will disable the filter.
1867
1674
  */
1868
- type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded;
1869
- type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
1870
- interface SponsorBlockSegmentsLoaded extends PlayerEvent {
1871
- type: "SegmentsLoaded";
1872
- segments: {
1873
- category: string;
1874
- start: number;
1875
- end: number;
1876
- }[];
1675
+ interface LowPassFilter {
1676
+ /** The smoothing factor (1.0 < x) */
1677
+ smoothing?: number;
1877
1678
  }
1878
- interface SponsorBlockSegmentSkipped extends PlayerEvent {
1879
- type: "SegmentSkipped";
1880
- segment: {
1881
- category: string;
1882
- start: number;
1883
- end: number;
1679
+ /**
1680
+ * Filter Data stored in the Client and partially sent to Lavalink
1681
+ */
1682
+ interface FilterData {
1683
+ volume?: number;
1684
+ karaoke?: KaraokeFilter;
1685
+ timescale?: TimescaleFilter;
1686
+ tremolo?: TremoloFilter;
1687
+ vibrato?: VibratoFilter;
1688
+ rotation?: RotationFilter;
1689
+ distortion?: DistortionFilter;
1690
+ channelMix?: ChannelMixFilter;
1691
+ lowPass?: LowPassFilter;
1692
+ pluginFilters?: {
1693
+ "lavalink-filter-plugin"?: {
1694
+ "echo"?: {
1695
+ delay?: number;
1696
+ decay?: number;
1697
+ };
1698
+ "reverb"?: {
1699
+ delays?: number[];
1700
+ gains?: number[];
1701
+ };
1702
+ };
1703
+ "high-pass"?: {
1704
+ cutoffFrequency?: number;
1705
+ boostFactor?: number;
1706
+ };
1707
+ "low-pass"?: {
1708
+ cutoffFrequency?: number;
1709
+ boostFactor?: number;
1710
+ };
1711
+ normalization?: {
1712
+ maxAmplitude?: number;
1713
+ adaptive?: boolean;
1714
+ };
1715
+ echo?: {
1716
+ echoLength?: number;
1717
+ decay?: number;
1718
+ };
1884
1719
  };
1885
1720
  }
1886
- interface SponsorBlockChapterStarted extends PlayerEvent {
1887
- type: "ChapterStarted";
1888
- /** The Chapter which started */
1889
- chapter: {
1890
- /** The Name of the Chapter */
1891
- name: string;
1892
- start: number;
1893
- end: number;
1894
- duration: number;
1895
- };
1721
+ /**
1722
+ * Actual Filter Data sent to Lavalink
1723
+ */
1724
+ interface LavalinkFilterData extends FilterData {
1725
+ equalizer?: EQBand[];
1896
1726
  }
1897
- interface SponsorBlockChaptersLoaded extends PlayerEvent {
1898
- type: "ChaptersLoaded";
1899
- /** All Chapters loaded */
1900
- chapters: {
1901
- /** The Name of the Chapter */
1902
- name: string;
1903
- start: number;
1904
- end: number;
1905
- duration: number;
1906
- }[];
1727
+
1728
+ /**
1729
+ * Debug events for more detailed logging
1730
+ */
1731
+ declare enum DebugEvents {
1732
+ SetSponsorBlock = "SetSponsorBlock",
1733
+ DeleteSponsorBlock = "DeleteSponsorBlock",
1734
+ TrackEndReplaced = "TrackEndReplaced",
1735
+ AutoplayExecution = "AutoplayExecution",
1736
+ AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
1737
+ AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
1738
+ TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
1739
+ QueueEnded = "QueueEnded",
1740
+ TrackStartNewSongsOnly = "TrackStartNewSongsOnly",
1741
+ TrackStartNoTrack = "TrackStartNoTrack",
1742
+ ResumingFetchingError = "ResumingFetchingError",
1743
+ PlayerUpdateNoPlayer = "PlayerUpdateNoPlayer",
1744
+ PlayerUpdateFilterFixApply = "PlayerUpdateFilterFixApply",
1745
+ PlayerUpdateSuccess = "PlayerUpdateSuccess",
1746
+ HeartBeatTriggered = "HeartBeatTriggered",
1747
+ NoSocketOnDestroy = "NoSocketOnDestroy",
1748
+ SocketCleanupError = "SocketCleanupError",
1749
+ SocketTerminateHeartBeatTimeout = "SocketTerminateHeartBeatTimeout",
1750
+ TryingConnectWhileConnected = "TryingConnectWhileConnected",
1751
+ LavaSearchNothingFound = "LavaSearchNothingFound",
1752
+ SearchNothingFound = "SearchNothingFound",
1753
+ ValidatingBlacklistLinks = "ValidatingBlacklistLinks",
1754
+ ValidatingWhitelistLinks = "ValidatingWhitelistLinks",
1755
+ TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
1756
+ TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime",
1757
+ PlayerDestroyingSomewhereElse = "PlayerDestroyingSomewhereElse",
1758
+ PlayerCreateNodeNotFound = "PlayerCreateNodeNotFound",
1759
+ PlayerPlayQueueEmptyTimeoutClear = "PlayerPlayQueueEmptyTimeoutClear",
1760
+ PlayerPlayWithTrackReplace = "PlayerPlayWithTrackReplace",
1761
+ PlayerPlayUnresolvedTrack = "PlayerPlayUnresolvedTrack",
1762
+ PlayerPlayUnresolvedTrackFailed = "PlayerPlayUnresolvedTrackFailed",
1763
+ PlayerVolumeAsFilter = "PlayerVolumeAsFilter",
1764
+ BandcampSearchLokalEngine = "BandcampSearchLokalEngine",
1765
+ PlayerChangeNode = "PlayerChangeNode",
1766
+ BuildTrackError = "BuildTrackError",
1767
+ TransformRequesterFunctionFailed = "TransformRequesterFunctionFailed",
1768
+ GetClosestTrackFailed = "GetClosestTrackFailed",
1769
+ PlayerDeleteInsteadOfDestroy = "PlayerDeleteInsteadOfDestroy",
1770
+ FailedToConnectToNodes = "FailedToConnectToNodes",
1771
+ NoAudioDebug = "NoAudioDebug",
1772
+ PlayerAutoReconnect = "PlayerAutoReconnect"
1907
1773
  }
1908
1774
  /**
1909
- * Types & Events for Lyrics plugin from Lavalink: https://github.com/topi314/LavaLyrics
1775
+ * Reasons why a player got destroyed
1910
1776
  */
1911
- type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent;
1912
- type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
1913
- interface LyricsFoundEvent extends PlayerEvent {
1914
- /** The lyricsfound event */
1915
- type: "LyricsFoundEvent";
1916
- /** The guildId */
1917
- guildId: string;
1918
- /** The lyrics */
1919
- lyrics: LyricsResult;
1777
+ declare enum DestroyReasons {
1778
+ QueueEmpty = "QueueEmpty",
1779
+ NodeDestroy = "NodeDestroy",
1780
+ NodeDeleted = "NodeDeleted",
1781
+ LavalinkNoVoice = "LavalinkNoVoice",
1782
+ NodeReconnectFail = "NodeReconnectFail",
1783
+ Disconnected = "Disconnected",
1784
+ PlayerReconnectFail = "PlayerReconnectFail",
1785
+ PlayerChangeNodeFail = "PlayerChangeNodeFail",
1786
+ PlayerChangeNodeFailNoEligibleNode = "PlayerChangeNodeFailNoEligibleNode",
1787
+ ChannelDeleted = "ChannelDeleted",
1788
+ DisconnectAllNodes = "DisconnectAllNodes",
1789
+ ReconnectAllNodes = "ReconnectAllNodes",
1790
+ TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
1791
+ TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
1920
1792
  }
1921
- interface LyricsNotFoundEvent extends PlayerEvent {
1922
- /**The lyricsnotfound event*/
1923
- type: "LyricsNotFoundEvent";
1924
- /**The guildId*/
1925
- guildId: string;
1793
+ /**
1794
+ * Reasons why a player got disconnected
1795
+ */
1796
+ declare enum DisconnectReasons {
1797
+ Disconnected = "Disconnected",
1798
+ DisconnectAllNodes = "DisconnectAllNodes"
1926
1799
  }
1927
- interface LyricsLineEvent extends PlayerEvent {
1928
- /**The lyricsline event*/
1929
- type: "LyricsLineEvent";
1930
- /** The guildId */
1800
+ /** The valid SponsorBlock categories */
1801
+ declare const validSponsorBlocks: string[];
1802
+ /** The audio Outputs Data map declaration */
1803
+ declare const audioOutputsData: Record<AudioOutputs, ChannelMixFilter>;
1804
+ /** Equalizer Presets */
1805
+ declare const EQList: {
1806
+ /** A Bassboost Equalizer, so high it distorts the audio */
1807
+ BassboostEarrape: EQBand[];
1808
+ /** A High and decent Bassboost Equalizer */
1809
+ BassboostHigh: EQBand[];
1810
+ /** A decent Bassboost Equalizer */
1811
+ BassboostMedium: EQBand[];
1812
+ /** A slight Bassboost Equalizer */
1813
+ BassboostLow: EQBand[];
1814
+ /** Makes the Music slightly "better" */
1815
+ BetterMusic: EQBand[];
1816
+ /** Makes the Music sound like rock music / sound rock music better */
1817
+ Rock: EQBand[];
1818
+ /** Makes the Music sound like Classic music / sound Classic music better */
1819
+ Classic: EQBand[];
1820
+ /** Makes the Music sound like Pop music / sound Pop music better */
1821
+ Pop: EQBand[];
1822
+ /** Makes the Music sound like Electronic music / sound Electronic music better */
1823
+ Electronic: EQBand[];
1824
+ /** Boosts all Bands slightly for louder and fuller sound */
1825
+ FullSound: EQBand[];
1826
+ /** Boosts basses + lower highs for a pro gaming sound */
1827
+ Gaming: EQBand[];
1828
+ };
1829
+
1830
+ type DestroyReasonsType = keyof typeof DestroyReasons | string;
1831
+ type DisconnectReasonsType = keyof typeof DisconnectReasons | string;
1832
+ interface PlayerJson {
1833
+ /** Guild Id where the player was playing in */
1834
+ guildId: string;
1835
+ /** Options provided to the player */
1836
+ options: PlayerOptions;
1837
+ /** Voice Channel Id the player was playing in */
1838
+ voiceChannelId: string;
1839
+ /** Text Channel Id the player was synced to */
1840
+ textChannelId?: string;
1841
+ /** Position the player was at */
1842
+ position: number;
1843
+ /** Lavalink's position the player was at */
1844
+ lastPosition: number;
1845
+ /** Last time the position was sent from lavalink */
1846
+ lastPositionChange: number | null;
1847
+ /** Volume in % from the player (without volumeDecrementer) */
1848
+ volume: number;
1849
+ /** Real Volume used in lavalink (with the volumeDecrementer) */
1850
+ lavalinkVolume: number;
1851
+ /** The repeatmode from the player */
1852
+ repeatMode: RepeatMode;
1853
+ /** Pause state */
1854
+ paused: boolean;
1855
+ /** Wether the player was playing or not */
1856
+ playing: boolean;
1857
+ /** When the player was created */
1858
+ createdTimeStamp?: number;
1859
+ /** All current used fitlers Data */
1860
+ filters: FilterData;
1861
+ /** The player's ping object */
1862
+ ping: {
1863
+ /** Ping to the voice websocket server */
1864
+ ws: number;
1865
+ /** Avg. calc. Ping to the lavalink server */
1866
+ lavalink: number;
1867
+ };
1868
+ /** Equalizer Bands used in lavalink */
1869
+ equalizer: EQBand[];
1870
+ /** The Id of the last used node */
1871
+ nodeId?: string;
1872
+ /** The SessionId of the node */
1873
+ nodeSessionId?: string;
1874
+ /** The stored queue */
1875
+ queue?: StoredQueue;
1876
+ }
1877
+ type RepeatMode = "queue" | "track" | "off";
1878
+ interface PlayerOptions {
1879
+ /** Guild id of the player */
1931
1880
  guildId: string;
1932
- /** The line number */
1933
- lineIndex: number;
1934
- /** The line */
1935
- line: LyricsLine;
1936
- /**skipped is true if the line was skipped */
1937
- skipped: boolean;
1881
+ /** The Voice Channel Id */
1882
+ voiceChannelId: string;
1883
+ /** The Text Channel Id of the Player */
1884
+ textChannelId?: string;
1885
+ /** instantly change volume with the one play request */
1886
+ volume?: number;
1887
+ /** VC Region for node selections */
1888
+ vcRegion?: string;
1889
+ /** if it should join deafened */
1890
+ selfDeaf?: boolean;
1891
+ /** If it should join muted */
1892
+ selfMute?: boolean;
1893
+ /** If it should use a specific lavalink node */
1894
+ node?: LavalinkNode | string;
1895
+ /** If when applying filters, it should use the insta apply filters fix */
1896
+ instaUpdateFiltersFix?: boolean;
1897
+ /** If a volume should be applied via filters instead of lavalink-volume */
1898
+ applyVolumeAsFilter?: boolean;
1899
+ /** Custom Data for the player get/set datastorage */
1900
+ customData?: anyObject;
1938
1901
  }
1939
- type LoadTypes = "track" | "playlist" | "search" | "error" | "empty";
1940
- type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING" | "DESTROYING";
1941
- type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType | LyricsEventType;
1942
- type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
1943
- interface InvalidLavalinkRestRequest {
1944
- /** Rest Request Data for when it was made */
1945
- timestamp: number;
1946
- /** Status of the request */
1947
- status: number;
1948
- /** Specific Errro which was sent */
1949
- error: string;
1950
- /** Specific Message which was created */
1951
- message?: string;
1952
- /** The specific error trace from the request */
1953
- trace?: unknown;
1954
- /** Path of where it's from */
1955
- path: string;
1902
+ type anyObject = {
1903
+ [key: string | number]: string | number | null | anyObject;
1904
+ };
1905
+ interface BasePlayOptions {
1906
+ /** The position to start the track. */
1907
+ position?: number;
1908
+ /** The position to end the track. */
1909
+ endTime?: number;
1910
+ /** If to start "paused" */
1911
+ paused?: boolean;
1912
+ /** The Volume to start with */
1913
+ volume?: number;
1914
+ /** The Lavalink Filters to use | only with the new REST API */
1915
+ filters?: Partial<LavalinkFilterData>;
1916
+ /** Voice Update for Lavalink */
1917
+ voice?: LavalinkPlayerVoiceOptions;
1956
1918
  }
1957
- interface LavalinkPlayerVoice {
1958
- /** The Voice Token */
1959
- token: string;
1960
- /** The Voice Server Endpoint */
1961
- endpoint: string;
1962
- /** The Voice SessionId */
1963
- sessionId: string;
1964
- /** Wether or not the player is connected */
1965
- connected?: boolean;
1966
- /** The Ping to the voice server */
1967
- ping?: number;
1919
+ interface LavalinkPlayOptions extends BasePlayOptions {
1920
+ /** Which Track to play | don't provide, if it should pick from the Queue */
1921
+ track?: {
1922
+ /** The track encoded base64 string to use instead of the one from the queue system */
1923
+ encoded?: Base64 | null;
1924
+ /** The identifier of the track to use */
1925
+ identifier?: string;
1926
+ /** Custom User Data for the track to provide, will then be on the userData object from the track */
1927
+ userData?: anyObject;
1928
+ /** The Track requester for when u provide encodedTrack / identifer */
1929
+ requester?: unknown;
1930
+ };
1968
1931
  }
1969
- type LavalinkPlayerVoiceOptions = Omit<LavalinkPlayerVoice, 'connected' | 'ping'>;
1970
- interface FailingAddress {
1971
- /** The failing address */
1972
- failingAddress: string;
1973
- /** The timestamp when the address failed */
1974
- failingTimestamp: number;
1975
- /** The timestamp when the address failed as a pretty string */
1976
- failingTime: string;
1932
+ interface PlayOptions extends LavalinkPlayOptions {
1933
+ /** Whether to not replace the track if a play payload is sent. */
1934
+ noReplace?: boolean;
1935
+ /** Adds track on queue and skips to it */
1936
+ clientTrack?: Track | UnresolvedTrack;
1977
1937
  }
1978
- type RoutePlannerTypes = "RotatingIpRoutePlanner" | "NanoIpRoutePlanner" | "RotatingNanoIpRoutePlanner" | "BalancingIpRoutePlanner";
1979
- interface RoutePlanner {
1980
- class?: RoutePlannerTypes;
1981
- details?: {
1982
- /** The ip block being used */
1983
- ipBlock: {
1984
- /** The type of the ip block */
1985
- type: "Inet4Address" | "Inet6Address";
1986
- /** The size of the ip block */
1987
- size: string;
1988
- };
1989
- /** The failing addresses */
1990
- failingAddresses: FailingAddress[];
1991
- /** The number of rotations */
1992
- rotateIndex?: string;
1993
- /** The current offset in the block */
1994
- ipIndex?: string;
1995
- /** The current address being used */
1996
- currentAddress?: string;
1997
- /** The current offset in the ip block */
1998
- currentAddressIndex?: string;
1999
- /** The information in which /64 block ips are chosen. This number increases on each ban. */
2000
- blockIndex?: string;
2001
- };
1938
+
1939
+ /** Ability to manipulate fetch requests */
1940
+ type ModifyRequest = (options: RequestInit & {
1941
+ path: string;
1942
+ extraQueryUrlParams?: URLSearchParams;
1943
+ }) => void;
1944
+ type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
1945
+ /**
1946
+ * Node Options for creating a lavalink node
1947
+ */
1948
+ interface LavalinkNodeOptions {
1949
+ /** The Lavalink Server-Ip / Domain-URL */
1950
+ host: string;
1951
+ /** The Lavalink Connection Port */
1952
+ port: number;
1953
+ /** The Lavalink Password / Authorization-Key */
1954
+ authorization: string;
1955
+ /** Does the Server use ssl (https) */
1956
+ secure?: boolean;
1957
+ /** RESUME THE PLAYER? by providing a sessionid on the node-creation */
1958
+ sessionId?: string;
1959
+ /** Add a Custom ID to the node, for later use */
1960
+ id?: string;
1961
+ /** Voice Regions of this Node */
1962
+ regions?: string[];
1963
+ /** The max amount of retries for this node. */
1964
+ retryAmount?: number;
1965
+ /** The delay of how often to retry a reconnection. */
1966
+ retryDelay?: number;
1967
+ /** How long a retry is a valid retry, it should be at least retryAmount*retryDelay. if <= 0 (default) then this won't be accounted. */
1968
+ retryTimespan?: number;
1969
+ /** signal for cancelling requests - default: AbortSignal.timeout(options.requestSignalTimeoutMS || 10000) - put <= 0 to disable */
1970
+ requestSignalTimeoutMS?: number;
1971
+ /** Close on error */
1972
+ closeOnError?: boolean;
1973
+ /** Heartbeat interval , set to <= 0 to disable heartbeat system */
1974
+ heartBeatInterval?: number;
1975
+ /** Recommended, to check wether the client is still connected or not on the stats endpoint */
1976
+ enablePingOnStatsCheck?: boolean;
2002
1977
  }
2003
- interface Session {
2004
- /** Wether or not session is resuming or not */
2005
- resuming: boolean;
2006
- /** For how long a session is lasting while not connected */
2007
- timeout: number;
1978
+ /**
1979
+ * Memory Stats object from lavalink
1980
+ */
1981
+ interface MemoryStats {
1982
+ /** The free memory of the allocated amount. */
1983
+ free: number;
1984
+ /** The used memory of the allocated amount. */
1985
+ used: number;
1986
+ /** The total allocated memory. */
1987
+ allocated: number;
1988
+ /** The reservable memory. */
1989
+ reservable: number;
2008
1990
  }
2009
- interface GuildShardPayload {
2010
- /** The OP code */
2011
- op: number;
2012
- /** Data to send */
2013
- d: {
2014
- /** Guild id to apply voice settings */
2015
- guild_id: string;
2016
- /** channel to move/connect to, or null to leave it */
2017
- channel_id: string | null;
2018
- /** wether or not mute yourself */
2019
- self_mute: boolean;
2020
- /** wether or not deafen yourself */
2021
- self_deaf: boolean;
2022
- };
1991
+ /**
1992
+ * CPU Stats object from lavalink
1993
+ */
1994
+ interface CPUStats {
1995
+ /** The core amount the host machine has. */
1996
+ cores: number;
1997
+ /** The system load. */
1998
+ systemLoad: number;
1999
+ /** The lavalink load. */
2000
+ lavalinkLoad: number;
2023
2001
  }
2024
- interface PlayerUpdateInfo {
2025
- /** guild id of the player */
2026
- guildId: string;
2027
- /** Player options to provide to lavalink */
2028
- playerOptions: LavalinkPlayOptions;
2029
- /** Whether or not replace the current track with the new one (true is recommended) */
2030
- noReplace?: boolean;
2002
+ /**
2003
+ * FrameStats Object from lavalink
2004
+ */
2005
+ interface FrameStats {
2006
+ /** The amount of sent frames. */
2007
+ sent?: number;
2008
+ /** The amount of nulled frames. */
2009
+ nulled?: number;
2010
+ /** The amount of deficit frames. */
2011
+ deficit?: number;
2031
2012
  }
2032
- interface LavalinkPlayer {
2033
- /** Guild Id of the player */
2034
- guildId: string;
2035
- /** IF playing a track, all of the track information */
2036
- track?: LavalinkTrack;
2037
- /** Lavalink volume (mind volumedecrementer) */
2038
- volume: number;
2039
- /** Wether it's paused or not */
2040
- paused: boolean;
2041
- /** Voice Endpoint data */
2042
- voice: LavalinkPlayerVoice;
2043
- /** All Audio Filters */
2044
- filters: Partial<LavalinkFilterData>;
2045
- /** Lavalink-Voice-State Variables */
2046
- state: {
2047
- /** Time since connection established */
2048
- time: number;
2049
- /** Position of the track */
2050
- position: number;
2051
- /** COnnected or not */
2052
- connected: boolean;
2053
- /** Ping to voice server */
2054
- ping: number;
2055
- };
2013
+ /**
2014
+ * BaseNodeStats object from Lavalink
2015
+ */
2016
+ interface BaseNodeStats {
2017
+ /** The amount of players on the node. */
2018
+ players: number;
2019
+ /** The amount of playing players on the node. */
2020
+ playingPlayers: number;
2021
+ /** The uptime for the node. */
2022
+ uptime: number;
2023
+ /** The memory stats for the node. */
2024
+ memory: MemoryStats;
2025
+ /** The cpu stats for the node. */
2026
+ cpu: CPUStats;
2027
+ /** The frame stats for the node. */
2028
+ frameStats: FrameStats;
2056
2029
  }
2057
- interface ChannelDeletePacket {
2058
- /** Packet key for channel delete */
2059
- t: "CHANNEL_DELETE";
2060
- /** data which is sent and relevant */
2061
- d: {
2062
- /** guild id */
2063
- guild_id: string;
2064
- /** Channel id */
2065
- id: string;
2066
- };
2030
+ /**
2031
+ * Interface for nodeStats from lavalink
2032
+ */
2033
+ interface NodeStats extends BaseNodeStats {
2034
+ /** The frame stats for the node. */
2035
+ frameStats: FrameStats;
2067
2036
  }
2068
- interface VoiceState {
2069
- /** OP key from lavalink */
2070
- op: "voiceUpdate";
2071
- /** GuildId provided by lavalink */
2072
- guildId: string;
2073
- /** Event data */
2074
- event: VoiceServer;
2075
- /** Session Id of the voice connection */
2076
- sessionId?: string;
2077
- /** guild id of the voice channel */
2078
- guild_id: string;
2079
- /** user id from the voice connection */
2080
- user_id: string;
2081
- /** Session Id of the voice connection */
2082
- session_id: string;
2083
- /** Voice Channel Id */
2084
- channel_id: string;
2085
- /** Server Mute status */
2086
- mute: boolean;
2087
- /** Server Deaf status */
2088
- deaf: boolean;
2089
- /** Self Deaf status */
2090
- self_deaf: boolean;
2091
- /** Self Mute status */
2092
- self_mute: boolean;
2093
- /** Self Video (Camera) status */
2094
- self_video: boolean;
2095
- /** Self Stream status */
2096
- self_stream: boolean;
2097
- /** Wether the user requests to speak (stage channel) */
2098
- request_to_speak_timestamp: boolean;
2099
- /** Self suppressed status (stage channel) */
2100
- suppress: boolean;
2037
+ /**
2038
+ * Entire lavalink information object from lavalink
2039
+ */
2040
+ interface LavalinkInfo {
2041
+ /** The version of this Lavalink server */
2042
+ version: VersionObject;
2043
+ /** The millisecond unix timestamp when this Lavalink jar was built */
2044
+ buildTime: number;
2045
+ /** The git information of this Lavalink server */
2046
+ git: GitObject;
2047
+ /** The JVM version this Lavalink server runs on */
2048
+ jvm: string;
2049
+ /** The Lavaplayer version being used by this server */
2050
+ lavaplayer: string;
2051
+ /** The enabled source managers for this server */
2052
+ sourceManagers: string[];
2053
+ /** The enabled filters for this server */
2054
+ filters: string[];
2055
+ /** The enabled plugins for this server */
2056
+ plugins: PluginObject[];
2101
2057
  }
2102
- /** The Base64 decodes tring by lavalink */
2103
- type Base64 = string;
2104
- interface VoiceServer {
2105
- /** Voice Token */
2106
- token: string;
2107
- /** Guild Id of the voice server connection */
2108
- guild_id: string;
2109
- /** Server Endpoint */
2110
- endpoint: string;
2058
+ /**
2059
+ * Lavalink's version object from lavalink
2060
+ */
2061
+ interface VersionObject {
2062
+ /** The full version string of this Lavalink server */
2063
+ semver: string;
2064
+ /** The major version of this Lavalink server */
2065
+ major: number;
2066
+ /** The minor version of this Lavalink server */
2067
+ minor: number;
2068
+ /** The patch version of this Lavalink server */
2069
+ patch: number;
2070
+ /** The pre-release version according to semver as a . separated list of identifiers */
2071
+ preRelease?: string;
2072
+ /** The build metadata according to semver as a . separated list of identifiers */
2073
+ build?: string;
2111
2074
  }
2112
- interface VoicePacket {
2113
- /** Voice Packet Keys to send */
2114
- t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE";
2115
- /** Voice Packets to send */
2116
- d: VoiceState | VoiceServer;
2075
+ /**
2076
+ * Git information object from lavalink
2077
+ */
2078
+ interface GitObject {
2079
+ /** The branch this Lavalink server was built on */
2080
+ branch: string;
2081
+ /** The commit this Lavalink server was built on */
2082
+ commit: string;
2083
+ /** The millisecond unix timestamp for when the commit was created */
2084
+ commitTime: string;
2117
2085
  }
2118
- interface NodeMessage extends NodeStats {
2119
- /** The type of the event */
2120
- type: PlayerEventType;
2121
- /** what ops are applying to that event */
2122
- op: "stats" | "playerUpdate" | "event";
2123
- /** The specific guild id for that message */
2124
- guildId: string;
2086
+ /**
2087
+ * Lavalink's plugins object from lavalink's plugin
2088
+ */
2089
+ interface PluginObject {
2090
+ /** The name of the plugin */
2091
+ name: string;
2092
+ /** The version of the plugin */
2093
+ version: string;
2125
2094
  }
2126
- /** Specific types to filter for lavasearch, will be filtered to correct types */
2127
- type LavaSearchType = "track" | "album" | "artist" | "playlist" | "text" | "tracks" | "albums" | "artists" | "playlists" | "texts";
2128
- interface LavaSearchFilteredResponse {
2129
- /** The Information of a playlist provided by lavasearch */
2130
- info: PlaylistInfo;
2131
- /** additional plugin information */
2132
- pluginInfo: PluginInfo;
2133
- /** List of tracks */
2134
- tracks: Track[];
2095
+ interface LyricsResult {
2096
+ /**The name of the source */
2097
+ sourceName: string;
2098
+ /**The name of the provider */
2099
+ provider: string;
2100
+ /**The result text */
2101
+ text: string | null;
2102
+ /**The lyrics lines */
2103
+ lines: LyricsLine[];
2104
+ /**Information about the plugin */
2105
+ plugin: PluginInfo;
2135
2106
  }
2136
- interface LavaSearchResponse {
2137
- /** An array of tracks, only present if track is in types */
2138
- tracks: Track[];
2139
- /** An array of albums, only present if album is in types */
2140
- albums: LavaSearchFilteredResponse[];
2141
- /** An array of artists, only present if artist is in types */
2142
- artists: LavaSearchFilteredResponse[];
2143
- /** An array of playlists, only present if playlist is in types */
2144
- playlists: LavaSearchFilteredResponse[];
2145
- /** An array of text results, only present if text is in types */
2146
- texts: {
2147
- text: string;
2148
- pluginInfo: PluginInfo;
2149
- }[];
2150
- /** Addition result data provided by plugins */
2151
- pluginInfo: PluginInfo;
2107
+ interface LyricsLine {
2108
+ /**The millisecond timestamp */
2109
+ timestamp: number;
2110
+ /**The line duration in milliseconds */
2111
+ duration: number | null;
2112
+ /**The line text */
2113
+ line: string;
2114
+ /**Information about the plugin */
2115
+ plugin: PluginInfo;
2116
+ }
2117
+ type LavalinkNodeIdentifier = string;
2118
+ interface NodeManagerEvents {
2119
+ /**
2120
+ * Emitted when a Node is created.
2121
+ * @event Manager.nodeManager#create
2122
+ */
2123
+ "create": (node: LavalinkNode) => void;
2124
+ /**
2125
+ * Emitted when a Node is destroyed.
2126
+ * @event Manager.nodeManager#destroy
2127
+ */
2128
+ "destroy": (node: LavalinkNode, destroyReason?: DestroyReasonsType) => void;
2129
+ /**
2130
+ * Emitted when a Node is connected.
2131
+ * @event Manager.nodeManager#connect
2132
+ */
2133
+ "connect": (node: LavalinkNode) => void;
2134
+ /**
2135
+ * Emitted when a Node is reconnecting.
2136
+ * @event Manager.nodeManager#reconnecting
2137
+ */
2138
+ "reconnecting": (node: LavalinkNode) => void;
2139
+ /**
2140
+ * Emitted When a node starts to reconnect (if you have a reconnection delay, the reconnecting event will be emitted after the retryDelay.)
2141
+ * Useful to check wether the internal node reconnect system works or not
2142
+ * @event Manager.nodeManager#reconnectinprogress
2143
+ */
2144
+ "reconnectinprogress": (node: LavalinkNode) => void;
2145
+ /**
2146
+ * Emitted when a Node is disconnects.
2147
+ * @event Manager.nodeManager#disconnect
2148
+ */
2149
+ "disconnect": (node: LavalinkNode, reason: {
2150
+ code?: number;
2151
+ reason?: string;
2152
+ }) => void;
2153
+ /**
2154
+ * Emitted when a Node is error.
2155
+ * @event Manager.nodeManager#error
2156
+ */
2157
+ "error": (node: LavalinkNode, error: Error, payload?: unknown) => void;
2158
+ /**
2159
+ * Emits every single Node event.
2160
+ * @event Manager.nodeManager#raw
2161
+ */
2162
+ "raw": (node: LavalinkNode, payload: unknown) => void;
2163
+ /**
2164
+ * Emits when the node connects resumed. You then need to create all players within this event for your usecase.
2165
+ * Aka for that you need to be able to save player data like vc channel + text channel in a db and then sync it again
2166
+ * @event Manager.nodeManager#nodeResumed
2167
+ */
2168
+ "resumed": (node: LavalinkNode, payload: {
2169
+ resumed: true;
2170
+ sessionId: string;
2171
+ op: "ready";
2172
+ }, players: LavalinkPlayer[] | InvalidLavalinkRestRequest) => void;
2173
+ }
2174
+ declare enum ReconnectionState {
2175
+ IDLE = "IDLE",
2176
+ RECONNECTING = "RECONNECTING",
2177
+ PENDING = "PENDING",
2178
+ DESTROYING = "DESTROYING"
2152
2179
  }
2153
- /** SearchQuery Object for raw lavalink requests */
2154
- type SearchQuery = {
2155
- /** lavalink search Query / identifier string */
2156
- query: string;
2157
- /** Extra url query params to use, e.g. for flowertts */
2158
- extraQueryUrlParams?: URLSearchParams;
2159
- /** Source to append to the search query string */
2160
- source?: SearchPlatform;
2161
- } | /** Our just the search query / identifier string */ string;
2162
- /** SearchQuery Object for Lavalink LavaSearch Plugin requests */
2163
- type LavaSearchQuery = {
2164
- /** lavalink search Query / identifier string */
2165
- query: string;
2166
- /** Source to append to the search query string */
2167
- source: LavaSrcSearchPlatformBase;
2168
- /** The Types to filter the search to */
2169
- types?: LavaSearchType[];
2170
- };
2171
- type Awaitable<T> = Promise<T> | T;
2172
2180
 
2173
2181
  /**
2174
2182
  * Lavalink Node creator class
@@ -2195,11 +2203,13 @@ declare class LavalinkNode {
2195
2203
  };
2196
2204
  /** Actual Lavalink Information of the Node */
2197
2205
  info: LavalinkInfo | null;
2206
+ /** current state of the Reconnections */
2207
+ reconnectionState: ReconnectionState;
2198
2208
  /** The Node Manager of this Node */
2199
2209
  private NodeManager;
2200
2210
  /** The Reconnection Timeout */
2201
2211
  private reconnectTimeout?;
2202
- /** The Reconnection Attempt counter */
2212
+ /** The Reconnection Attempt counter (array of datetimes when it tried it.) */
2203
2213
  private reconnectAttempts;
2204
2214
  /** The Socket of the Lavalink */
2205
2215
  private socket;
@@ -2584,17 +2594,38 @@ declare class LavalinkNode {
2584
2594
  * Get the rest Adress for making requests
2585
2595
  */
2586
2596
  private get restAddress();
2597
+ /**
2598
+ * If already trying to reconnect or pending, return
2599
+ */
2600
+ get isNodeReconnecting(): boolean;
2587
2601
  /**
2588
2602
  * Reconnect to the lavalink node
2589
- * @param instaReconnect @default false wether to instantly try to reconnect
2603
+ * @param force @default false Wether to instantly try to reconnect (force it)
2590
2604
  * @returns void
2591
2605
  *
2592
2606
  * @example
2593
2607
  * ```ts
2594
- * await player.node.reconnect();
2608
+ * await player.node.reconnect(true); //true forcefully trys the reconnect
2595
2609
  * ```
2596
2610
  */
2597
2611
  private reconnect;
2612
+ get reconnectionAttemptCount(): number;
2613
+ /**
2614
+ * Private Utility function to execute the reconnection
2615
+ */
2616
+ private executeReconnect;
2617
+ /**
2618
+ * Private function to reset the reconnection attempts
2619
+ * @returns
2620
+ */
2621
+ private resetReconnectionAttempts;
2622
+ /**
2623
+ * Private function to reset timeouts/intervals for heartbeating/pinging
2624
+ * @param heartbeat
2625
+ * @param ping
2626
+ * @returns
2627
+ */
2628
+ private resetAckTimeouts;
2598
2629
  /** @private util function for handling opening events from websocket */
2599
2630
  private open;
2600
2631
  /** @private util function for handling closing events from websocket */
@@ -3299,4 +3330,4 @@ declare const LavalinkPlugins: {
3299
3330
  /** Lavalink Sources regexes for url validations */
3300
3331
  declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
3301
3332
 
3302
- export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };
3333
+ export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, ReconnectionState, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };