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