lavalink-client 2.2.2 → 2.3.1

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 (111) hide show
  1. package/README.md +95 -1
  2. package/dist/cjs/index.d.ts +8 -1
  3. package/dist/cjs/index.js +8 -1
  4. package/dist/cjs/structures/Constants.d.ts +40 -0
  5. package/dist/cjs/structures/Constants.js +244 -0
  6. package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  7. package/dist/cjs/structures/Filters.d.ts +2 -217
  8. package/dist/cjs/structures/Filters.js +8 -232
  9. package/dist/cjs/structures/LavalinkManager.d.ts +31 -166
  10. package/dist/cjs/structures/LavalinkManager.js +59 -7
  11. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
  12. package/dist/cjs/structures/Node.d.ts +15 -156
  13. package/dist/cjs/structures/Node.js +131 -49
  14. package/dist/cjs/structures/NodeManager.d.ts +54 -52
  15. package/dist/cjs/structures/NodeManager.js +74 -4
  16. package/dist/cjs/structures/Player.d.ts +31 -124
  17. package/dist/cjs/structures/Player.js +77 -43
  18. package/dist/cjs/structures/Queue.d.ts +66 -42
  19. package/dist/cjs/structures/Queue.js +69 -11
  20. package/dist/cjs/structures/Types/Filters.d.ts +190 -0
  21. package/dist/cjs/structures/Types/Manager.d.ts +184 -0
  22. package/dist/cjs/structures/Types/Manager.js +2 -0
  23. package/dist/cjs/structures/Types/Node.d.ts +216 -0
  24. package/dist/cjs/structures/Types/Node.js +2 -0
  25. package/dist/cjs/structures/Types/Player.d.ts +108 -0
  26. package/dist/cjs/structures/Types/Player.js +2 -0
  27. package/dist/cjs/structures/Types/Queue.d.ts +34 -0
  28. package/dist/cjs/structures/Types/Queue.js +2 -0
  29. package/dist/cjs/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  30. package/dist/{structures → cjs/structures/Types}/Track.js +2 -2
  31. package/dist/cjs/structures/Types/Utils.d.ts +367 -0
  32. package/dist/cjs/structures/Types/Utils.js +2 -0
  33. package/dist/cjs/structures/Utils.d.ts +13 -369
  34. package/dist/cjs/structures/Utils.js +35 -14
  35. package/dist/esm/index.d.ts +8 -1
  36. package/dist/esm/index.js +8 -1
  37. package/dist/esm/structures/Constants.d.ts +40 -0
  38. package/dist/esm/structures/Constants.js +241 -0
  39. package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  40. package/dist/esm/structures/Filters.d.ts +2 -217
  41. package/dist/esm/structures/Filters.js +3 -227
  42. package/dist/esm/structures/LavalinkManager.d.ts +31 -166
  43. package/dist/esm/structures/LavalinkManager.js +57 -5
  44. package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
  45. package/dist/esm/structures/Node.d.ts +15 -156
  46. package/dist/esm/structures/Node.js +122 -40
  47. package/dist/esm/structures/NodeManager.d.ts +54 -52
  48. package/dist/esm/structures/NodeManager.js +71 -1
  49. package/dist/esm/structures/Player.d.ts +31 -124
  50. package/dist/esm/structures/Player.js +76 -42
  51. package/dist/esm/structures/Queue.d.ts +66 -42
  52. package/dist/esm/structures/Queue.js +69 -11
  53. package/dist/esm/structures/Types/Filters.d.ts +190 -0
  54. package/dist/esm/structures/Types/Manager.d.ts +184 -0
  55. package/dist/esm/structures/Types/Manager.js +1 -0
  56. package/dist/esm/structures/Types/Node.d.ts +216 -0
  57. package/dist/esm/structures/Types/Node.js +1 -0
  58. package/dist/esm/structures/Types/Player.d.ts +108 -0
  59. package/dist/esm/structures/Types/Player.js +1 -0
  60. package/dist/esm/structures/Types/Queue.d.ts +34 -0
  61. package/dist/esm/structures/Types/Queue.js +1 -0
  62. package/dist/esm/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  63. package/dist/esm/structures/Types/Track.js +1 -0
  64. package/dist/esm/structures/Types/Utils.d.ts +367 -0
  65. package/dist/esm/structures/Types/Utils.js +1 -0
  66. package/dist/esm/structures/Utils.d.ts +13 -369
  67. package/dist/esm/structures/Utils.js +35 -14
  68. package/dist/types/index.d.ts +8 -1
  69. package/dist/types/structures/Constants.d.ts +40 -0
  70. package/dist/types/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  71. package/dist/types/structures/Filters.d.ts +2 -217
  72. package/dist/types/structures/LavalinkManager.d.ts +31 -166
  73. package/dist/types/structures/LavalinkManagerStatics.d.ts +1 -1
  74. package/dist/types/structures/Node.d.ts +15 -156
  75. package/dist/types/structures/NodeManager.d.ts +54 -52
  76. package/dist/types/structures/Player.d.ts +31 -124
  77. package/dist/types/structures/Queue.d.ts +66 -42
  78. package/dist/types/structures/Types/Filters.d.ts +190 -0
  79. package/dist/types/structures/Types/Manager.d.ts +184 -0
  80. package/dist/types/structures/Types/Node.d.ts +216 -0
  81. package/dist/types/structures/Types/Player.d.ts +108 -0
  82. package/dist/types/structures/Types/Queue.d.ts +34 -0
  83. package/dist/types/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  84. package/dist/types/structures/Types/Utils.d.ts +367 -0
  85. package/dist/types/structures/Utils.d.ts +13 -369
  86. package/package.json +1 -1
  87. package/dist/index.d.ts +0 -10
  88. package/dist/index.js +0 -13
  89. package/dist/structures/Filters.d.ts +0 -230
  90. package/dist/structures/Filters.js +0 -472
  91. package/dist/structures/LavalinkManager.d.ts +0 -47
  92. package/dist/structures/LavalinkManager.js +0 -36
  93. package/dist/structures/LavalinkManagerStatics.d.ts +0 -3
  94. package/dist/structures/LavalinkManagerStatics.js +0 -76
  95. package/dist/structures/Node.d.ts +0 -171
  96. package/dist/structures/Node.js +0 -462
  97. package/dist/structures/NodeManager.d.ts +0 -58
  98. package/dist/structures/NodeManager.js +0 -25
  99. package/dist/structures/Player.d.ts +0 -101
  100. package/dist/structures/Player.js +0 -232
  101. package/dist/structures/PlayerManager.d.ts +0 -62
  102. package/dist/structures/PlayerManager.js +0 -26
  103. package/dist/structures/Queue.d.ts +0 -93
  104. package/dist/structures/Queue.js +0 -160
  105. package/dist/structures/QueueManager.d.ts +0 -77
  106. package/dist/structures/QueueManager.js +0 -74
  107. package/dist/structures/Track.d.ts +0 -27
  108. package/dist/structures/Utils.d.ts +0 -183
  109. package/dist/structures/Utils.js +0 -43
  110. /package/dist/cjs/structures/{Track.js → Types/Filters.js} +0 -0
  111. /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
@@ -1,472 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validAudioOutputs = 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.validAudioOutputs.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 = 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.validAudioOutputs.stereo,
185
- })) {
186
- this.data[key] = value;
187
- }
188
- await this.applyPlayerFilters();
189
- return this.filters;
190
- }
191
- /**
192
- * Set the AudioOutput Filter
193
- * @param type
194
- */
195
- async setAudioOutput(type) {
196
- if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix"))
197
- throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
198
- if (!type || !exports.validAudioOutputs[type])
199
- throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
200
- this.data.channelMix = exports.validAudioOutputs[type];
201
- this.filters.audioOutput = type;
202
- await this.applyPlayerFilters();
203
- return this.filters.audioOutput;
204
- }
205
- /**
206
- * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
207
- * @param speed
208
- * @returns
209
- */
210
- async setSpeed(speed = 1) {
211
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
212
- throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
213
- // reset nightcore / vaporwave filter if enabled
214
- if (this.filters.nightcore || this.filters.vaporwave) {
215
- this.data.timescale.pitch = 1;
216
- this.data.timescale.speed = 1;
217
- this.data.timescale.rate = 1;
218
- this.filters.nightcore = false;
219
- this.filters.vaporwave = false;
220
- }
221
- this.data.timescale.speed = speed;
222
- // check if custom filter is active / not
223
- this.isCustomFilterActive();
224
- await this.applyPlayerFilters();
225
- return this.filters.custom;
226
- }
227
- /**
228
- * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
229
- * @param speed
230
- * @returns
231
- */
232
- async setPitch(pitch = 1) {
233
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
234
- throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
235
- // reset nightcore / vaporwave filter if enabled
236
- if (this.filters.nightcore || this.filters.vaporwave) {
237
- this.data.timescale.pitch = 1;
238
- this.data.timescale.speed = 1;
239
- this.data.timescale.rate = 1;
240
- this.filters.nightcore = false;
241
- this.filters.vaporwave = false;
242
- }
243
- this.data.timescale.pitch = pitch;
244
- // check if custom filter is active / not
245
- this.isCustomFilterActive();
246
- await this.applyPlayerFilters();
247
- return this.filters.custom;
248
- }
249
- /**
250
- * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
251
- * @param speed
252
- * @returns
253
- */
254
- async setRate(rate = 1) {
255
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
256
- throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
257
- // reset nightcore / vaporwave filter if enabled
258
- if (this.filters.nightcore || this.filters.vaporwave) {
259
- this.data.timescale.pitch = 1;
260
- this.data.timescale.speed = 1;
261
- this.data.timescale.rate = 1;
262
- this.filters.nightcore = false;
263
- this.filters.vaporwave = false;
264
- }
265
- this.data.timescale.rate = rate;
266
- // check if custom filter is active / not
267
- this.isCustomFilterActive();
268
- await this.applyPlayerFilters();
269
- return this.filters.custom;
270
- }
271
- /**
272
- * Enabels / Disables the rotation effect, (Optional: provide your Own Data)
273
- * @param rotationHz
274
- * @returns
275
- */
276
- async toggleRotation(rotationHz = 0.2) {
277
- if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation"))
278
- throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
279
- this.data.rotation.rotationHz = this.filters.rotation ? 0 : rotationHz;
280
- this.filters.rotation = !this.filters.rotation;
281
- return await this.applyPlayerFilters(), this.filters.rotation;
282
- }
283
- /**
284
- * Enabels / Disables the Vibrato effect, (Optional: provide your Own Data)
285
- * @param frequency
286
- * @param depth
287
- * @returns
288
- */
289
- async toggleVibrato(frequency = 10, depth = 1) {
290
- if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato"))
291
- throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
292
- this.data.vibrato.frequency = this.filters.vibrato ? 0 : frequency;
293
- this.data.vibrato.depth = this.filters.vibrato ? 0 : depth;
294
- this.filters.vibrato = !this.filters.vibrato;
295
- await this.applyPlayerFilters();
296
- return this.filters.vibrato;
297
- }
298
- /**
299
- * Enabels / Disables the Tremolo effect, (Optional: provide your Own Data)
300
- * @param frequency
301
- * @param depth
302
- * @returns
303
- */
304
- async toggleTremolo(frequency = 4, depth = 0.8) {
305
- if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo"))
306
- throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
307
- this.data.tremolo.frequency = this.filters.tremolo ? 0 : frequency;
308
- this.data.tremolo.depth = this.filters.tremolo ? 0 : depth;
309
- this.filters.tremolo = !this.filters.tremolo;
310
- await this.applyPlayerFilters();
311
- return this.filters.tremolo;
312
- }
313
- /**
314
- * Enabels / Disables the LowPass effect, (Optional: provide your Own Data)
315
- * @param smoothing
316
- * @returns
317
- */
318
- async toggleLowPass(smoothing = 20) {
319
- if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass"))
320
- throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
321
- this.data.lowPass.smoothing = this.filters.lowPass ? 0 : smoothing;
322
- this.filters.lowPass = !this.filters.lowPass;
323
- await this.applyPlayerFilters();
324
- return this.filters.lowPass;
325
- }
326
- /**
327
- * Enabels / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
328
- * @param delay
329
- * @param decay
330
- * @returns
331
- */
332
- async toggleEcho(delay = 1, decay = 0.5) {
333
- if (this.player.node.info && !this.player.node.info?.filters?.includes("echo"))
334
- throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
335
- this.data.echo.delay = this.filters.echo ? 0 : delay;
336
- this.data.echo.decay = this.filters.echo ? 0 : decay;
337
- this.filters.echo = !this.filters.echo;
338
- await this.applyPlayerFilters();
339
- return this.filters.echo;
340
- }
341
- /**
342
- * Enabels / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
343
- * @param delay
344
- * @param decay
345
- * @returns
346
- */
347
- async toggleReverb(delay = 1, decay = 0.5) {
348
- if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb"))
349
- throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
350
- this.data.reverb.delay = this.filters.reverb ? 0 : delay;
351
- this.data.reverb.decay = this.filters.reverb ? 0 : decay;
352
- this.filters.reverb = !this.filters.reverb;
353
- await this.applyPlayerFilters();
354
- return this.filters.reverb;
355
- }
356
- /**
357
- * Enables / Disabels a Nightcore-like filter Effect. Disables/Overwrides both: custom and Vaporwave Filter
358
- * @param speed
359
- * @param pitch
360
- * @param rate
361
- * @returns
362
- */
363
- async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
364
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
365
- throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
366
- this.data.timescale.speed = this.filters.nightcore ? 1 : speed;
367
- this.data.timescale.pitch = this.filters.nightcore ? 1 : pitch;
368
- this.data.timescale.rate = this.filters.nightcore ? 1 : rate;
369
- this.filters.nightcore = !this.filters.nightcore;
370
- this.filters.vaporwave = false;
371
- this.filters.custom = false;
372
- await this.applyPlayerFilters();
373
- return this.filters.nightcore;
374
- }
375
- /**
376
- * Enables / Disabels a Vaporwave-like filter Effect. Disables/Overwrides both: custom and nightcore Filter
377
- * @param speed
378
- * @param pitch
379
- * @param rate
380
- * @returns
381
- */
382
- async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
383
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
384
- throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
385
- this.data.timescale.speed = this.filters.vaporwave ? 1 : speed;
386
- this.data.timescale.pitch = this.filters.vaporwave ? 1 : pitch;
387
- this.data.timescale.rate = this.filters.vaporwave ? 1 : rate;
388
- this.filters.vaporwave = !this.filters.vaporwave;
389
- this.filters.nightcore = false;
390
- this.filters.custom = false;
391
- await this.applyPlayerFilters();
392
- return this.filters.vaporwave;
393
- }
394
- /**
395
- * Enable / Disables a Karaoke like Filter Effect
396
- * @param level
397
- * @param monoLevel
398
- * @param filterBand
399
- * @param filterWidth
400
- * @returns
401
- */
402
- async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
403
- if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke"))
404
- throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
405
- this.data.karaoke.level = this.filters.karaoke ? 0 : level;
406
- this.data.karaoke.monoLevel = this.filters.karaoke ? 0 : monoLevel;
407
- this.data.karaoke.filterBand = this.filters.karaoke ? 0 : filterBand;
408
- this.data.karaoke.filterWidth = this.filters.karaoke ? 0 : filterWidth;
409
- this.filters.karaoke = !this.filters.karaoke;
410
- await this.applyPlayerFilters();
411
- return this.filters.karaoke;
412
- }
413
- /** Function to find out if currently there is a custom timescamle etc. filter applied */
414
- isCustomFilterActive() {
415
- this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some(d => d !== 1);
416
- return this.filters.custom;
417
- }
418
- /**
419
- * Sets the players equalizer band on-top of the existing ones.
420
- * @param bands
421
- */
422
- async setEQ(bands) {
423
- if (!Array.isArray(bands))
424
- bands = [bands];
425
- if (!bands.length || !bands.every((band) => JSON.stringify(Object.keys(band).sort()) === '["band","gain"]'))
426
- throw new TypeError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
427
- for (const { band, gain } of bands)
428
- this.equalizerBands[band] = { band, gain };
429
- if (!this.player.node.sessionId)
430
- throw new Error("The Lavalink-Node is either not ready or not up to date");
431
- const now = performance.now();
432
- await this.player.node.updatePlayer({
433
- guildId: this.player.guildId,
434
- playerOptions: {
435
- filters: { equalizer: this.equalizerBands }
436
- }
437
- });
438
- this.player.ping = Math.round((performance.now() - now) / 10) / 100;
439
- return this;
440
- }
441
- /** Clears the equalizer bands. */
442
- async clearEQ() {
443
- return this.setEQ(new Array(15).fill(0.0).map((gain, band) => ({ band, gain })));
444
- }
445
- }
446
- exports.FilterManager = FilterManager;
447
- exports.validAudioOutputs = {
448
- mono: {
449
- leftToLeft: 0.5,
450
- leftToRight: 0.5,
451
- rightToLeft: 0.5,
452
- rightToRight: 0.5,
453
- },
454
- stereo: {
455
- leftToLeft: 1,
456
- leftToRight: 0,
457
- rightToLeft: 0,
458
- rightToRight: 1,
459
- },
460
- left: {
461
- leftToLeft: 0.5,
462
- leftToRight: 0,
463
- rightToLeft: 0.5,
464
- rightToRight: 0,
465
- },
466
- right: {
467
- leftToLeft: 0,
468
- leftToRight: 0.5,
469
- rightToLeft: 0,
470
- rightToRight: 0.5,
471
- },
472
- };
@@ -1,47 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from "node:events";
3
- import { NodeManager } from "./NodeManager";
4
- import { ManagerQueueOptions, QueueStoreManager } from "./Queue";
5
- import { PlayerManager } from "./PlayerManager";
6
- import { GuildShardPayload, ManagerUtils, SearchPlatform } from "./Utils";
7
- import { LavalinkNodeOptions } from "./Node";
8
- export interface LavalinkManager {
9
- playerManager: PlayerManager;
10
- nodeManager: NodeManager;
11
- utilManager: ManagerUtils;
12
- }
13
- export interface BotClientOptions {
14
- shards?: number | "auto";
15
- id: string;
16
- username: string;
17
- }
18
- export interface ManagerPlayerOptions {
19
- volumeDecrementer?: number;
20
- clientBasedPositionUpdateInterval?: number;
21
- defaultSearchPlatform?: SearchPlatform;
22
- applyVolumeAsFilter?: boolean;
23
- }
24
- export interface ManagerOptions {
25
- nodes: LavalinkNodeOptions[];
26
- queueStore?: QueueStoreManager;
27
- queueOptions?: ManagerQueueOptions;
28
- client?: BotClientOptions;
29
- playerOptions?: ManagerPlayerOptions;
30
- autoSkip?: boolean;
31
- /** @async */
32
- sendToShard: (guildId: string, payload: GuildShardPayload) => void;
33
- }
34
- interface LavalinkManagerEvents {
35
- "create": (manager: LavalinkManager) => void;
36
- }
37
- export interface LavalinkManager {
38
- options: ManagerOptions;
39
- on<U extends keyof LavalinkManagerEvents>(event: U, listener: LavalinkManagerEvents[U]): this;
40
- emit<U extends keyof LavalinkManagerEvents>(event: U, ...args: Parameters<LavalinkManagerEvents[U]>): boolean;
41
- }
42
- export declare class LavalinkManager extends EventEmitter {
43
- static DEFAULT_SOURCES: Record<SearchPlatform, import("./Utils").LavalinkSearchPlatform>;
44
- static REGEXES: Record<import("./Utils").SourcesRegex, RegExp>;
45
- constructor(options: ManagerOptions);
46
- }
47
- export {};
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LavalinkManager = void 0;
4
- const node_events_1 = require("node:events");
5
- const NodeManager_1 = require("./NodeManager");
6
- const Queue_1 = require("./Queue");
7
- const PlayerManager_1 = require("./PlayerManager");
8
- const Utils_1 = require("./Utils");
9
- const LavalinkManagerStatics_1 = require("./LavalinkManagerStatics");
10
- class LavalinkManager extends node_events_1.EventEmitter {
11
- static DEFAULT_SOURCES = LavalinkManagerStatics_1.DEFAULT_SOURCES;
12
- static REGEXES = LavalinkManagerStatics_1.REGEXES;
13
- constructor(options) {
14
- super();
15
- this.options = {
16
- autoSkip: true,
17
- ...options
18
- };
19
- if (!this.options.playerOptions.defaultSearchPlatform)
20
- this.options.playerOptions.defaultSearchPlatform = "ytsearch";
21
- if (!this.options.queueOptions.maxPreviousTracks || this.options.queueOptions.maxPreviousTracks <= 0)
22
- this.options.queueOptions.maxPreviousTracks = 25;
23
- if (options.queueStore) {
24
- const keys = Object.keys(options.queueStore);
25
- const requiredKeys = ["get", "set", "stringify", "parse", "delete"];
26
- if (!requiredKeys.every(v => keys.includes(v)) || !requiredKeys.every(v => typeof options.queueStore[v] === "function"))
27
- throw new SyntaxError(`The provided QueueStore, does not have all required functions: ${requiredKeys.join(", ")}`);
28
- }
29
- else
30
- this.options.queueStore = new Queue_1.DefaultQueueStore();
31
- this.playerManager = new PlayerManager_1.PlayerManager(this);
32
- this.nodeManager = new NodeManager_1.NodeManager(this);
33
- this.utilManager = new Utils_1.ManagerUitls(this);
34
- }
35
- }
36
- exports.LavalinkManager = LavalinkManager;
@@ -1,3 +0,0 @@
1
- import { LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
2
- export declare const DEFAULT_SOURCES: Record<SearchPlatform, LavalinkSearchPlatform>;
3
- export declare const REGEXES: Record<SourcesRegex, RegExp>;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REGEXES = exports.DEFAULT_SOURCES = void 0;
4
- exports.DEFAULT_SOURCES = {
5
- // youtubemusic
6
- "youtube music": "ytmsearch",
7
- "ytmsearch": "ytmsearch",
8
- "ytm": "ytmsearch",
9
- // youtube
10
- "youtube": "ytsearch",
11
- "yt": "ytsearch",
12
- "ytsearch": "ytsearch",
13
- // soundcloud
14
- "soundcloud": "scsearch",
15
- "scsearch": "scsearch",
16
- "sc": "scsearch",
17
- // apple music
18
- "amsearch": "amsearch",
19
- "am": "amsearch",
20
- // spotify
21
- "spsearch": "spsearch",
22
- "sp": "spsearch",
23
- "sprec": "sprec",
24
- "spsuggestion": "sprec",
25
- // deezer
26
- "dz": "dzsearch",
27
- "deezer": "dzsearch",
28
- "ds": "dzsearch",
29
- "dzsearch": "dzsearch",
30
- "dzisrc": "dzisrc",
31
- // yandexmusic
32
- "yandexmusic": "ymsearch",
33
- "yandex": "ymsearch",
34
- "ymsearch": "ymsearch",
35
- // speak
36
- "speak": "speak",
37
- "tts": "tts",
38
- };
39
- exports.REGEXES = {
40
- YoutubeRegex: /https?:\/\/?(?:www\.)?(?:(m|www)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|shorts|playlist\?|watch\?v=|watch\?.+(?:&|&#38;);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&#38;)index=((?:\d){1,3}))?(?:(?:\?|&|&#38;)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?/,
41
- YoutubeMusicRegex: /https?:\/\/?(?:www\.)?(?:(music|m|www)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|shorts|playlist\?|watch\?v=|watch\?.+(?:&|&#38;);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&#38;)index=((?:\d){1,3}))?(?:(?:\?|&|&#38;)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?/,
42
- SoundCloudRegex: /https:\/\/(?:on\.)?soundcloud\.com\//,
43
- SoundCloudMobileRegex: /https?:\/\/(soundcloud\.app\.goo\.gl)\/(\S+)/,
44
- DeezerTrackRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?track\/(\d+)/,
45
- DeezerPageLinkRegex: /(https?:\/\/|)?(?:www\.)?deezer\.page\.link\/(\S+)/,
46
- DeezerPlaylistRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?playlist\/(\d+)/,
47
- DeezerAlbumRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?album\/(\d+)/,
48
- DeezerArtistRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?artist\/(\d+)/,
49
- DeezerMixesRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?mixes\/genre\/(\d+)/,
50
- DeezerEpisodeRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?episode\/(\d+)/,
51
- // DeezerPodcastRegex: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?podcast\/(\d+)/,
52
- AllDeezerRegexWithoutPageLink: /(https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?(track|playlist|album|artist|mixes\/genre|episode)\/(\d+)/,
53
- AllDeezerRegex: /((https?:\/\/|)?(?:www\.)?deezer\.com\/(?:\w{2}\/)?(track|playlist|album|artist|mixes\/genre|episode)\/(\d+)|(https?:\/\/|)?(?:www\.)?deezer\.page\.link\/(\S+))/,
54
- SpotifySongRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?track\/(?<identifier>[a-zA-Z0-9-_]+)/,
55
- SpotifyPlaylistRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?playlist\/(?<identifier>[a-zA-Z0-9-_]+)/,
56
- SpotifyArtistRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?artist\/(?<identifier>[a-zA-Z0-9-_]+)/,
57
- SpotifyEpisodeRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?episode\/(?<identifier>[a-zA-Z0-9-_]+)/,
58
- SpotifyShowRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?show\/(?<identifier>[a-zA-Z0-9-_]+)/,
59
- SpotifyAlbumRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?album\/(?<identifier>[a-zA-Z0-9-_]+)/,
60
- AllSpotifyRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?(?<type>track|album|playlist|artist|episode|show)\/(?<identifier>[a-zA-Z0-9-_]+)/,
61
- mp3Url: /(https?|ftp|file):\/\/(www.)?(.*?)\.(mp3)$/,
62
- m3uUrl: /(https?|ftp|file):\/\/(www.)?(.*?)\.(m3u)$/,
63
- m3u8Url: /(https?|ftp|file):\/\/(www.)?(.*?)\.(m3u8)$/,
64
- mp4Url: /(https?|ftp|file):\/\/(www.)?(.*?)\.(mp4)$/,
65
- m4aUrl: /(https?|ftp|file):\/\/(www.)?(.*?)\.(m4a)$/,
66
- wavUrl: /(https?|ftp|file):\/\/(www.)?(.*?)\.(wav)$/,
67
- aacpUrl: /(https?|ftp|file):\/\/(www.)?(.*?)\.(aacp)$/,
68
- tiktok: /https:\/\/www\.tiktok\.com\//,
69
- mixcloud: /https:\/\/www\.mixcloud\.com\//,
70
- musicYandex: /https:\/\/music\.yandex\.ru\//,
71
- radiohost: /https?:\/\/[^.\s]+\.radiohost\.de\/(\S+)/,
72
- bandcamp: /https?:\/\/?(?:www\.)?([\d|\w]+)\.bandcamp\.com\/(\S+)/,
73
- appleMusic: /https?:\/\/?(?:www\.)?music\.apple\.com\/(\S+)/,
74
- TwitchTv: /https?:\/\/?(?:www\.)?twitch\.tv\/\w+/,
75
- vimeo: /https?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:|\/\?)/,
76
- };