lavalink-client 1.0.0 → 1.0.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.
Files changed (76) hide show
  1. package/README.md +103 -152
  2. package/dist/cjs/index.d.ts +9 -0
  3. package/dist/cjs/index.js +12 -0
  4. package/dist/cjs/structures/Filters.d.ts +231 -0
  5. package/dist/cjs/structures/Filters.js +481 -0
  6. package/dist/cjs/structures/LavalinkManager.d.ts +124 -0
  7. package/dist/cjs/structures/LavalinkManager.js +168 -0
  8. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +3 -0
  9. package/dist/cjs/structures/LavalinkManagerStatics.js +84 -0
  10. package/dist/cjs/structures/Node.d.ts +245 -0
  11. package/dist/cjs/structures/Node.js +602 -0
  12. package/dist/cjs/structures/NodeManager.d.ts +61 -0
  13. package/dist/cjs/structures/NodeManager.js +35 -0
  14. package/dist/cjs/structures/Player.d.ts +191 -0
  15. package/dist/cjs/structures/Player.js +395 -0
  16. package/dist/cjs/structures/Queue.d.ts +107 -0
  17. package/dist/cjs/structures/Queue.js +215 -0
  18. package/dist/cjs/structures/Track.d.ts +47 -0
  19. package/dist/cjs/structures/Track.js +2 -0
  20. package/dist/cjs/structures/Utils.d.ts +258 -0
  21. package/dist/cjs/structures/Utils.js +179 -0
  22. package/dist/esm/index.d.ts +9 -0
  23. package/dist/esm/index.js +9 -0
  24. package/dist/esm/structures/Filters.d.ts +231 -0
  25. package/dist/esm/structures/Filters.js +477 -0
  26. package/dist/esm/structures/LavalinkManager.d.ts +124 -0
  27. package/dist/esm/structures/LavalinkManager.js +164 -0
  28. package/dist/esm/structures/LavalinkManagerStatics.d.ts +3 -0
  29. package/dist/esm/structures/LavalinkManagerStatics.js +81 -0
  30. package/dist/esm/structures/Node.d.ts +245 -0
  31. package/dist/esm/structures/Node.js +597 -0
  32. package/dist/esm/structures/NodeManager.d.ts +61 -0
  33. package/dist/esm/structures/NodeManager.js +31 -0
  34. package/dist/esm/structures/Player.d.ts +191 -0
  35. package/dist/esm/structures/Player.js +391 -0
  36. package/dist/esm/structures/Queue.d.ts +107 -0
  37. package/dist/esm/structures/Queue.js +208 -0
  38. package/dist/esm/structures/Track.d.ts +47 -0
  39. package/dist/esm/structures/Track.js +1 -0
  40. package/dist/esm/structures/Utils.d.ts +258 -0
  41. package/dist/esm/structures/Utils.js +173 -0
  42. package/dist/index.d.ts +10 -0
  43. package/dist/index.js +13 -0
  44. package/dist/structures/Filters.d.ts +230 -0
  45. package/dist/structures/Filters.js +472 -0
  46. package/dist/structures/LavalinkManager.d.ts +47 -0
  47. package/dist/structures/LavalinkManager.js +36 -0
  48. package/dist/structures/LavalinkManagerStatics.d.ts +3 -0
  49. package/dist/structures/LavalinkManagerStatics.js +76 -0
  50. package/dist/structures/Node.d.ts +171 -0
  51. package/dist/structures/Node.js +462 -0
  52. package/dist/structures/NodeManager.d.ts +58 -0
  53. package/dist/structures/NodeManager.js +25 -0
  54. package/dist/structures/Player.d.ts +101 -0
  55. package/dist/structures/Player.js +232 -0
  56. package/dist/structures/PlayerManager.d.ts +62 -0
  57. package/dist/structures/PlayerManager.js +26 -0
  58. package/dist/structures/Queue.d.ts +93 -0
  59. package/dist/structures/Queue.js +160 -0
  60. package/dist/structures/QueueManager.d.ts +77 -0
  61. package/dist/structures/QueueManager.js +74 -0
  62. package/dist/structures/Track.d.ts +27 -0
  63. package/dist/structures/Track.js +2 -0
  64. package/dist/structures/Utils.d.ts +183 -0
  65. package/dist/structures/Utils.js +43 -0
  66. package/dist/types/index.d.ts +9 -0
  67. package/dist/types/structures/Filters.d.ts +231 -0
  68. package/dist/types/structures/LavalinkManager.d.ts +124 -0
  69. package/dist/types/structures/LavalinkManagerStatics.d.ts +3 -0
  70. package/dist/types/structures/Node.d.ts +245 -0
  71. package/dist/types/structures/NodeManager.d.ts +61 -0
  72. package/dist/types/structures/Player.d.ts +191 -0
  73. package/dist/types/structures/Queue.d.ts +107 -0
  74. package/dist/types/structures/Track.d.ts +47 -0
  75. package/dist/types/structures/Utils.d.ts +258 -0
  76. package/package.json +63 -26
@@ -0,0 +1,477 @@
1
+ export class FilterManager {
2
+ equalizerBands = [];
3
+ filterUpdatedState = 0;
4
+ filters = {
5
+ volume: false,
6
+ vaporwave: false,
7
+ custom: false,
8
+ nightcore: false,
9
+ echo: false,
10
+ reverb: false,
11
+ rotation: false,
12
+ karaoke: false,
13
+ tremolo: false,
14
+ vibrato: false,
15
+ lowPass: false,
16
+ audioOutput: "stereo",
17
+ };
18
+ data = {
19
+ lowPass: {
20
+ smoothing: 0
21
+ },
22
+ karaoke: {
23
+ level: 0,
24
+ monoLevel: 0,
25
+ filterBand: 0,
26
+ filterWidth: 0
27
+ },
28
+ timescale: {
29
+ speed: 1,
30
+ pitch: 1,
31
+ rate: 1 // 0 = x
32
+ },
33
+ echo: {
34
+ delay: 0,
35
+ decay: 0
36
+ },
37
+ reverb: {
38
+ delay: 0,
39
+ decay: 0
40
+ },
41
+ rotation: {
42
+ rotationHz: 0
43
+ },
44
+ tremolo: {
45
+ frequency: 0,
46
+ depth: 0 // 0 < x = 1
47
+ },
48
+ vibrato: {
49
+ frequency: 0,
50
+ depth: 0 // 0 < x = 1
51
+ },
52
+ channelMix: audioOutputsData.stereo,
53
+ /*distortion: {
54
+ sinOffset: 0,
55
+ sinScale: 1,
56
+ cosOffset: 0,
57
+ cosScale: 1,
58
+ tanOffset: 0,
59
+ tanScale: 1,
60
+ offset: 0,
61
+ scale: 1
62
+ }*/
63
+ };
64
+ constructor(player) {
65
+ this.player = player;
66
+ }
67
+ // function to update all filters at ONCE (and eqs)
68
+ async applyPlayerFilters() {
69
+ const sendData = { ...this.data };
70
+ if (!this.filters.volume)
71
+ delete sendData.volume;
72
+ if (!this.filters.tremolo)
73
+ delete sendData.tremolo;
74
+ if (!this.filters.vibrato)
75
+ delete sendData.vibrato;
76
+ //if(!this.filters.karaoke) delete sendData.karaoke;
77
+ if (!this.filters.echo)
78
+ delete sendData.echo;
79
+ if (!this.filters.reverb)
80
+ delete sendData.reverb;
81
+ if (!this.filters.lowPass)
82
+ delete sendData.lowPass;
83
+ if (!this.filters.karaoke)
84
+ delete sendData.karaoke;
85
+ //if(!this.filters.rotating) delete sendData.rotating;
86
+ if (this.filters.audioOutput === "stereo")
87
+ delete sendData.channelMix;
88
+ if (!this.player.node.sessionId)
89
+ throw new Error("The Lavalink-Node is either not ready or not up to date");
90
+ sendData.equalizer = [...this.equalizerBands];
91
+ for (const key of [...Object.keys(sendData)]) {
92
+ // delete disabled filters
93
+ if (this.player.node.info && !this.player.node.info?.filters?.includes?.(key))
94
+ delete sendData[key];
95
+ }
96
+ const now = performance.now();
97
+ await this.player.node.updatePlayer({
98
+ guildId: this.player.guildId,
99
+ playerOptions: {
100
+ filters: sendData,
101
+ }
102
+ });
103
+ this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
104
+ if (this.player.options.instaUpdateFiltersFix === true)
105
+ this.filterUpdatedState = 1;
106
+ return;
107
+ }
108
+ /**
109
+ * Checks if the filters are correctly stated (active / not-active)
110
+ * @param oldFilterTimescale
111
+ * @returns
112
+ */
113
+ checkFiltersState(oldFilterTimescale) {
114
+ this.filters.rotation = this.data.rotation.rotationHz !== 0;
115
+ this.filters.vibrato = this.data.vibrato.frequency !== 0 || this.data.vibrato.depth !== 0;
116
+ this.filters.tremolo = this.data.tremolo.frequency !== 0 || this.data.tremolo.depth !== 0;
117
+ this.filters.echo = this.data.echo.decay !== 0 || this.data.echo.delay !== 0;
118
+ this.filters.reverb = this.data.reverb.decay !== 0 || this.data.reverb.delay !== 0;
119
+ this.filters.lowPass = this.data.lowPass.smoothing !== 0;
120
+ this.filters.karaoke = Object.values(this.data.karaoke).some(v => v !== 0);
121
+ if ((this.filters.nightcore || this.filters.vaporwave) && oldFilterTimescale) {
122
+ if (oldFilterTimescale.pitch !== this.data.timescale.pitch || oldFilterTimescale.rate !== this.data.timescale.rate || oldFilterTimescale.speed !== this.data.timescale.speed) {
123
+ this.filters.custom = Object.values(this.data.timescale).some(v => v !== 1);
124
+ this.filters.nightcore = false;
125
+ this.filters.vaporwave = false;
126
+ }
127
+ }
128
+ return true;
129
+ }
130
+ /**
131
+ * Reset all Filters
132
+ */
133
+ async resetFilters() {
134
+ this.filters.echo = false;
135
+ this.filters.reverb = false;
136
+ this.filters.nightcore = false;
137
+ this.filters.lowPass = false;
138
+ this.filters.rotation = false;
139
+ this.filters.tremolo = false;
140
+ this.filters.vibrato = false;
141
+ this.filters.karaoke = false;
142
+ this.filters.karaoke = false;
143
+ this.filters.volume = false;
144
+ this.filters.audioOutput = "stereo";
145
+ // disable all filters
146
+ for (const [key, value] of Object.entries({
147
+ volume: 1,
148
+ lowPass: {
149
+ smoothing: 0
150
+ },
151
+ karaoke: {
152
+ level: 0,
153
+ monoLevel: 0,
154
+ filterBand: 0,
155
+ filterWidth: 0
156
+ },
157
+ timescale: {
158
+ speed: 1,
159
+ pitch: 1,
160
+ rate: 1 // 0 = x
161
+ },
162
+ echo: {
163
+ delay: 0,
164
+ decay: 0
165
+ },
166
+ reverb: {
167
+ delay: 0,
168
+ decay: 0
169
+ },
170
+ rotation: {
171
+ rotationHz: 0
172
+ },
173
+ tremolo: {
174
+ frequency: 2,
175
+ depth: 0.1 // 0 < x = 1
176
+ },
177
+ vibrato: {
178
+ frequency: 2,
179
+ depth: 0.1 // 0 < x = 1
180
+ },
181
+ channelMix: audioOutputsData.stereo,
182
+ })) {
183
+ this.data[key] = value;
184
+ }
185
+ await this.applyPlayerFilters();
186
+ return this.filters;
187
+ }
188
+ async setVolume(volume) {
189
+ if (volume < 0 || volume > 5)
190
+ throw new SyntaxError("Volume-Filter must be between 0 and 5");
191
+ this.data.volume = volume;
192
+ await this.applyPlayerFilters();
193
+ return this.filters.volume;
194
+ }
195
+ /**
196
+ * Set the AudioOutput Filter
197
+ * @param type
198
+ */
199
+ async setAudioOutput(type) {
200
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix"))
201
+ throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
202
+ if (!type || !audioOutputsData[type])
203
+ throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
204
+ this.data.channelMix = audioOutputsData[type];
205
+ this.filters.audioOutput = type;
206
+ await this.applyPlayerFilters();
207
+ return this.filters.audioOutput;
208
+ }
209
+ /**
210
+ * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
211
+ * @param speed
212
+ * @returns
213
+ */
214
+ async setSpeed(speed = 1) {
215
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
216
+ throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
217
+ // reset nightcore / vaporwave filter if enabled
218
+ if (this.filters.nightcore || this.filters.vaporwave) {
219
+ this.data.timescale.pitch = 1;
220
+ this.data.timescale.speed = 1;
221
+ this.data.timescale.rate = 1;
222
+ this.filters.nightcore = false;
223
+ this.filters.vaporwave = false;
224
+ }
225
+ this.data.timescale.speed = speed;
226
+ // check if custom filter is active / not
227
+ this.isCustomFilterActive();
228
+ await this.applyPlayerFilters();
229
+ return this.filters.custom;
230
+ }
231
+ /**
232
+ * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
233
+ * @param speed
234
+ * @returns
235
+ */
236
+ async setPitch(pitch = 1) {
237
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
238
+ throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
239
+ // reset nightcore / vaporwave filter if enabled
240
+ if (this.filters.nightcore || this.filters.vaporwave) {
241
+ this.data.timescale.pitch = 1;
242
+ this.data.timescale.speed = 1;
243
+ this.data.timescale.rate = 1;
244
+ this.filters.nightcore = false;
245
+ this.filters.vaporwave = false;
246
+ }
247
+ this.data.timescale.pitch = pitch;
248
+ // check if custom filter is active / not
249
+ this.isCustomFilterActive();
250
+ await this.applyPlayerFilters();
251
+ return this.filters.custom;
252
+ }
253
+ /**
254
+ * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
255
+ * @param speed
256
+ * @returns
257
+ */
258
+ async setRate(rate = 1) {
259
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
260
+ throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
261
+ // reset nightcore / vaporwave filter if enabled
262
+ if (this.filters.nightcore || this.filters.vaporwave) {
263
+ this.data.timescale.pitch = 1;
264
+ this.data.timescale.speed = 1;
265
+ this.data.timescale.rate = 1;
266
+ this.filters.nightcore = false;
267
+ this.filters.vaporwave = false;
268
+ }
269
+ this.data.timescale.rate = rate;
270
+ // check if custom filter is active / not
271
+ this.isCustomFilterActive();
272
+ await this.applyPlayerFilters();
273
+ return this.filters.custom;
274
+ }
275
+ /**
276
+ * Enabels / Disables the rotation effect, (Optional: provide your Own Data)
277
+ * @param rotationHz
278
+ * @returns
279
+ */
280
+ async toggleRotation(rotationHz = 0.2) {
281
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation"))
282
+ throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
283
+ this.data.rotation.rotationHz = this.filters.rotation ? 0 : rotationHz;
284
+ this.filters.rotation = !this.filters.rotation;
285
+ return await this.applyPlayerFilters(), this.filters.rotation;
286
+ }
287
+ /**
288
+ * Enabels / Disables the Vibrato effect, (Optional: provide your Own Data)
289
+ * @param frequency
290
+ * @param depth
291
+ * @returns
292
+ */
293
+ async toggleVibrato(frequency = 10, depth = 1) {
294
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato"))
295
+ throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
296
+ this.data.vibrato.frequency = this.filters.vibrato ? 0 : frequency;
297
+ this.data.vibrato.depth = this.filters.vibrato ? 0 : depth;
298
+ this.filters.vibrato = !this.filters.vibrato;
299
+ await this.applyPlayerFilters();
300
+ return this.filters.vibrato;
301
+ }
302
+ /**
303
+ * Enabels / Disables the Tremolo effect, (Optional: provide your Own Data)
304
+ * @param frequency
305
+ * @param depth
306
+ * @returns
307
+ */
308
+ async toggleTremolo(frequency = 4, depth = 0.8) {
309
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo"))
310
+ throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
311
+ this.data.tremolo.frequency = this.filters.tremolo ? 0 : frequency;
312
+ this.data.tremolo.depth = this.filters.tremolo ? 0 : depth;
313
+ this.filters.tremolo = !this.filters.tremolo;
314
+ await this.applyPlayerFilters();
315
+ return this.filters.tremolo;
316
+ }
317
+ /**
318
+ * Enabels / Disables the LowPass effect, (Optional: provide your Own Data)
319
+ * @param smoothing
320
+ * @returns
321
+ */
322
+ async toggleLowPass(smoothing = 20) {
323
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass"))
324
+ throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
325
+ this.data.lowPass.smoothing = this.filters.lowPass ? 0 : smoothing;
326
+ this.filters.lowPass = !this.filters.lowPass;
327
+ await this.applyPlayerFilters();
328
+ return this.filters.lowPass;
329
+ }
330
+ /**
331
+ * Enabels / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
332
+ * @param delay
333
+ * @param decay
334
+ * @returns
335
+ */
336
+ async toggleEcho(delay = 1, decay = 0.5) {
337
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("echo"))
338
+ throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
339
+ this.data.echo.delay = this.filters.echo ? 0 : delay;
340
+ this.data.echo.decay = this.filters.echo ? 0 : decay;
341
+ this.filters.echo = !this.filters.echo;
342
+ await this.applyPlayerFilters();
343
+ return this.filters.echo;
344
+ }
345
+ /**
346
+ * Enabels / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
347
+ * @param delay
348
+ * @param decay
349
+ * @returns
350
+ */
351
+ async toggleReverb(delay = 1, decay = 0.5) {
352
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb"))
353
+ throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
354
+ this.data.reverb.delay = this.filters.reverb ? 0 : delay;
355
+ this.data.reverb.decay = this.filters.reverb ? 0 : decay;
356
+ this.filters.reverb = !this.filters.reverb;
357
+ await this.applyPlayerFilters();
358
+ return this.filters.reverb;
359
+ }
360
+ /**
361
+ * Enables / Disabels a Nightcore-like filter Effect. Disables/Overwrides both: custom and Vaporwave Filter
362
+ * @param speed
363
+ * @param pitch
364
+ * @param rate
365
+ * @returns
366
+ */
367
+ async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
368
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
369
+ throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
370
+ this.data.timescale.speed = this.filters.nightcore ? 1 : speed;
371
+ this.data.timescale.pitch = this.filters.nightcore ? 1 : pitch;
372
+ this.data.timescale.rate = this.filters.nightcore ? 1 : rate;
373
+ this.filters.nightcore = !this.filters.nightcore;
374
+ this.filters.vaporwave = false;
375
+ this.filters.custom = false;
376
+ await this.applyPlayerFilters();
377
+ return this.filters.nightcore;
378
+ }
379
+ /**
380
+ * Enables / Disabels a Vaporwave-like filter Effect. Disables/Overwrides both: custom and nightcore Filter
381
+ * @param speed
382
+ * @param pitch
383
+ * @param rate
384
+ * @returns
385
+ */
386
+ async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
387
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
388
+ throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
389
+ this.data.timescale.speed = this.filters.vaporwave ? 1 : speed;
390
+ this.data.timescale.pitch = this.filters.vaporwave ? 1 : pitch;
391
+ this.data.timescale.rate = this.filters.vaporwave ? 1 : rate;
392
+ this.filters.vaporwave = !this.filters.vaporwave;
393
+ this.filters.nightcore = false;
394
+ this.filters.custom = false;
395
+ await this.applyPlayerFilters();
396
+ return this.filters.vaporwave;
397
+ }
398
+ /**
399
+ * Enable / Disables a Karaoke like Filter Effect
400
+ * @param level
401
+ * @param monoLevel
402
+ * @param filterBand
403
+ * @param filterWidth
404
+ * @returns
405
+ */
406
+ async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
407
+ if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke"))
408
+ throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
409
+ this.data.karaoke.level = this.filters.karaoke ? 0 : level;
410
+ this.data.karaoke.monoLevel = this.filters.karaoke ? 0 : monoLevel;
411
+ this.data.karaoke.filterBand = this.filters.karaoke ? 0 : filterBand;
412
+ this.data.karaoke.filterWidth = this.filters.karaoke ? 0 : filterWidth;
413
+ this.filters.karaoke = !this.filters.karaoke;
414
+ await this.applyPlayerFilters();
415
+ return this.filters.karaoke;
416
+ }
417
+ /** Function to find out if currently there is a custom timescamle etc. filter applied */
418
+ isCustomFilterActive() {
419
+ this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some(d => d !== 1);
420
+ return this.filters.custom;
421
+ }
422
+ /**
423
+ * Sets the players equalizer band on-top of the existing ones.
424
+ * @param bands
425
+ */
426
+ async setEQ(bands) {
427
+ if (!Array.isArray(bands))
428
+ bands = [bands];
429
+ if (!bands.length || !bands.every((band) => JSON.stringify(Object.keys(band).sort()) === '["band","gain"]'))
430
+ throw new TypeError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
431
+ for (const { band, gain } of bands)
432
+ this.equalizerBands[band] = { band, gain };
433
+ if (!this.player.node.sessionId)
434
+ throw new Error("The Lavalink-Node is either not ready or not up to date");
435
+ const now = performance.now();
436
+ await this.player.node.updatePlayer({
437
+ guildId: this.player.guildId,
438
+ playerOptions: {
439
+ filters: { equalizer: this.equalizerBands }
440
+ }
441
+ });
442
+ this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
443
+ if (this.player.options.instaUpdateFiltersFix === true)
444
+ this.filterUpdatedState = 1;
445
+ return this;
446
+ }
447
+ /** Clears the equalizer bands. */
448
+ async clearEQ() {
449
+ return this.setEQ(new Array(15).fill(0.0).map((gain, band) => ({ band, gain })));
450
+ }
451
+ }
452
+ export const audioOutputsData = {
453
+ mono: {
454
+ leftToLeft: 0.5,
455
+ leftToRight: 0.5,
456
+ rightToLeft: 0.5,
457
+ rightToRight: 0.5,
458
+ },
459
+ stereo: {
460
+ leftToLeft: 1,
461
+ leftToRight: 0,
462
+ rightToLeft: 0,
463
+ rightToRight: 1,
464
+ },
465
+ left: {
466
+ leftToLeft: 1,
467
+ leftToRight: 0,
468
+ rightToLeft: 1,
469
+ rightToRight: 0,
470
+ },
471
+ right: {
472
+ leftToLeft: 0,
473
+ leftToRight: 1,
474
+ rightToLeft: 0,
475
+ rightToRight: 1,
476
+ },
477
+ };
@@ -0,0 +1,124 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "events";
3
+ import { NodeManager } from "./NodeManager";
4
+ import { QueueChangesWatcher, QueueSaverOptions, StoreManager } from "./Queue";
5
+ import { GuildShardPayload, LavalinkSearchPlatform, ManagerUitls, MiniMap, SearchPlatform, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent } from "./Utils";
6
+ import { LavalinkNodeOptions } from "./Node";
7
+ import { DestroyReasonsType, Player, PlayerOptions } from "./Player";
8
+ import { Track } from "./Track";
9
+ export interface LavalinkManager {
10
+ nodeManager: NodeManager;
11
+ utils: ManagerUitls;
12
+ }
13
+ export interface BotClientOptions {
14
+ shards?: number | number[] | "auto";
15
+ id: string;
16
+ username?: string;
17
+ /** So users can pass entire objects / classes */
18
+ [x: string | number | symbol | undefined]: any;
19
+ }
20
+ export interface LavalinkPlayerOptions {
21
+ volumeDecrementer?: number;
22
+ clientBasedUpdateInterval?: number;
23
+ defaultSearchPlatform?: SearchPlatform;
24
+ applyVolumeAsFilter?: boolean;
25
+ onDisconnect?: {
26
+ autoReconnect?: boolean;
27
+ destroyPlayer?: boolean;
28
+ };
29
+ onEmptyQueue?: {
30
+ destroyAfterMs?: number;
31
+ };
32
+ }
33
+ export interface ManagerOptions {
34
+ nodes: LavalinkNodeOptions[];
35
+ queueOptions?: QueueSaverOptions;
36
+ queueStore?: StoreManager;
37
+ queueChangesWatcher?: QueueChangesWatcher;
38
+ client?: BotClientOptions;
39
+ playerOptions?: LavalinkPlayerOptions;
40
+ autoSkip?: boolean;
41
+ /** @async */
42
+ sendToShard: (guildId: string, payload: GuildShardPayload) => void;
43
+ }
44
+ interface LavalinkManagerEvents {
45
+ /**
46
+ * Emitted when a Track started playing.
47
+ * @event Manager.playerManager#trackStart
48
+ */
49
+ "trackStart": (player: Player, track: Track, payload: TrackStartEvent) => void;
50
+ /**
51
+ * Emitted when a Track finished.
52
+ * @event Manager.playerManager#trackEnd
53
+ */
54
+ "trackEnd": (player: Player, track: Track, payload: TrackEndEvent) => void;
55
+ /**
56
+ * Emitted when a Track got stuck while playing.
57
+ * @event Manager.playerManager#trackStuck
58
+ */
59
+ "trackStuck": (player: Player, track: Track, payload: TrackStuckEvent) => void;
60
+ /**
61
+ * Emitted when a Track errored.
62
+ * @event Manager.playerManager#trackError
63
+ */
64
+ "trackError": (player: Player, track: Track, payload: TrackExceptionEvent) => void;
65
+ /**
66
+ * Emitted when the Playing finished and no more tracks in the queue.
67
+ * @event Manager.playerManager#queueEnd
68
+ */
69
+ "queueEnd": (player: Player, track: Track, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
70
+ /**
71
+ * Emitted when a Player is created.
72
+ * @event Manager.playerManager#create
73
+ */
74
+ "playerCreate": (player: Player) => void;
75
+ /**
76
+ * Emitted when a Player is moved within the channel.
77
+ * @event Manager.playerManager#move
78
+ */
79
+ "playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
80
+ /**
81
+ * Emitted when a Player is disconnected from a channel.
82
+ * @event Manager.playerManager#disconnect
83
+ */
84
+ "playerDisconnect": (player: Player, voiceChannelId: string) => void;
85
+ /**
86
+ * Emitted when a Node-Socket got closed for a specific Player.
87
+ * @event Manager.playerManager#socketClosed
88
+ */
89
+ "playerSocketClosed": (player: Player, payload: WebSocketClosedEvent) => void;
90
+ /**
91
+ * Emitted when a Player get's destroyed
92
+ * @event Manager.playerManager#destroy
93
+ */
94
+ "playerDestroy": (player: Player, destroyReason?: DestroyReasonsType) => void;
95
+ }
96
+ export interface LavalinkManager {
97
+ options: ManagerOptions;
98
+ on<U extends keyof LavalinkManagerEvents>(event: U, listener: LavalinkManagerEvents[U]): this;
99
+ emit<U extends keyof LavalinkManagerEvents>(event: U, ...args: Parameters<LavalinkManagerEvents[U]>): boolean;
100
+ }
101
+ export declare class LavalinkManager extends EventEmitter {
102
+ static DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform>;
103
+ static SourceLinksRegexes: Record<import("./Utils").SourcesRegex, RegExp>;
104
+ initiated: boolean;
105
+ readonly players: MiniMap<string, Player>;
106
+ private applyDefaultOptions;
107
+ private validateAndApply;
108
+ constructor(options: ManagerOptions);
109
+ createPlayer(options: PlayerOptions): Player;
110
+ getPlayer(guildId: string): Player;
111
+ deletePlayer(guildId: string): boolean;
112
+ get useable(): boolean;
113
+ /**
114
+ * Initiates the Manager.
115
+ * @param clientData
116
+ */
117
+ init(clientData: BotClientOptions): Promise<this>;
118
+ /**
119
+ * Sends voice data to the Lavalink server.
120
+ * @param data
121
+ */
122
+ sendRawData(data: VoicePacket | VoiceServer | VoiceState | any): Promise<void>;
123
+ }
124
+ export {};