magmastream 2.9.0-dev.45 → 2.9.0-dev.47

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.ts CHANGED
@@ -2,7 +2,7 @@ import { Collection } from '@discordjs/collection';
2
2
  import { GatewayVoiceStateUpdate } from 'discord-api-types/v10';
3
3
  import { EventEmitter } from 'events';
4
4
  import { User, ClientUser, Message, Client } from 'discord.js';
5
- import WebSocket, { WebSocket as WebSocket$1 } from 'ws';
5
+ import WebSocket$1, { WebSocket } from 'ws';
6
6
  import { Redis } from 'ioredis';
7
7
  import { Client as Client$1 } from 'eris';
8
8
  import { ClusterClient, ShardClient } from 'detritus-client';
@@ -98,7 +98,8 @@ declare enum PlayerStateEventTypes {
98
98
  VolumeChange = "volumeChange",
99
99
  ChannelChange = "channelChange",
100
100
  PlayerCreate = "playerCreate",
101
- PlayerDestroy = "playerDestroy"
101
+ PlayerDestroy = "playerDestroy",
102
+ FilterChange = "filterChange"
102
103
  }
103
104
  /**
104
105
  * Track Source Types Enum
@@ -266,6 +267,9 @@ declare enum AvailableFilters {
266
267
  declare class JsonQueue implements IQueue {
267
268
  readonly guildId: string;
268
269
  readonly manager: Manager;
270
+ /**
271
+ * The base path for the queue files.
272
+ */
269
273
  private basePath;
270
274
  /**
271
275
  * @param guildId The guild ID.
@@ -273,76 +277,74 @@ declare class JsonQueue implements IQueue {
273
277
  */
274
278
  constructor(guildId: string, manager: Manager);
275
279
  /**
276
- * @returns The queue path.
280
+ * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
281
+ * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
277
282
  */
278
- private get queuePath();
283
+ add(track: Track | Track[], offset?: number): Promise<void>;
279
284
  /**
280
- * @returns The current path.
285
+ * @param track The track to add.
281
286
  */
282
- private get currentPath();
287
+ addPrevious(track: Track | Track[]): Promise<void>;
283
288
  /**
284
- * @returns The previous path.
289
+ * Clears the queue.
285
290
  */
286
- private get previousPath();
291
+ clear(): Promise<void>;
287
292
  /**
288
- * Ensures the directory exists.
293
+ * Clears the previous tracks.
289
294
  */
290
- private ensureDir;
295
+ clearPrevious(): Promise<void>;
291
296
  /**
292
- * @returns The queue.
297
+ * Removes the first track from the queue.
293
298
  */
294
- private getQueue;
299
+ dequeue(): Promise<Track | undefined>;
295
300
  /**
296
- * @param queue The queue.
301
+ * @returns The total duration of the queue.
297
302
  */
298
- private setQueue;
303
+ duration(): Promise<number>;
299
304
  /**
300
- * @param filePath The file path.
301
- * @returns The JSON data.
305
+ * Adds a track to the front of the queue.
302
306
  */
303
- private readJSON;
307
+ enqueueFront(track: Track | Track[]): Promise<void>;
304
308
  /**
305
- * @param filePath The file path.
306
- * @param data The data to write.
309
+ * Tests whether all elements in the queue pass the test implemented by the provided function.
307
310
  */
308
- private writeJSON;
311
+ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
309
312
  /**
310
- * @param filePath The file path.
313
+ * Filters the queue.
311
314
  */
312
- private deleteFile;
315
+ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
313
316
  /**
314
- * @returns The current track.
317
+ * Finds the first track in the queue that satisfies the provided testing function.
315
318
  */
316
- getCurrent(): Promise<Track | null>;
319
+ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
317
320
  /**
318
- * @param track The track to set.
321
+ * @returns The current track.
319
322
  */
320
- setCurrent(track: Track | null): Promise<void>;
323
+ getCurrent(): Promise<Track | null>;
321
324
  /**
322
325
  * @returns The previous tracks.
323
326
  */
324
327
  getPrevious(): Promise<Track[]>;
325
328
  /**
326
- * @param track The track to add.
329
+ * @returns The tracks in the queue from start to end.
327
330
  */
328
- addPrevious(track: Track | Track[]): Promise<void>;
331
+ getSlice(start?: number, end?: number): Promise<Track[]>;
329
332
  /**
330
- * @param track The track to set.
333
+ * @returns The tracks in the queue.
331
334
  */
332
- setPrevious(track: Track | Track[]): Promise<void>;
335
+ getTracks(): Promise<Track[]>;
333
336
  /**
334
- * @returns The newest track.
337
+ * Maps the queue to a new array.
335
338
  */
336
- popPrevious(): Promise<Track | null>;
339
+ mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
337
340
  /**
338
- * Clears the previous tracks.
341
+ * Modifies the queue at the specified index.
339
342
  */
340
- clearPrevious(): Promise<void>;
343
+ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
341
344
  /**
342
- * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
343
- * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
345
+ * @returns The newest track.
344
346
  */
345
- add(track: Track | Track[], offset?: number): Promise<void>;
347
+ popPrevious(): Promise<Track | null>;
346
348
  /**
347
349
  * Removes a track from the queue.
348
350
  * @param position The position to remove the track at.
@@ -351,73 +353,75 @@ declare class JsonQueue implements IQueue {
351
353
  remove(position?: number): Promise<Track[]>;
352
354
  remove(start: number, end: number): Promise<Track[]>;
353
355
  /**
354
- * Clears the queue.
355
- */
356
- clear(): Promise<void>;
357
- /**
358
- * @returns The size of the queue.
356
+ * Shuffles the queue by round-robin.
359
357
  */
360
- size(): Promise<number>;
358
+ roundRobinShuffle(): Promise<void>;
361
359
  /**
362
- * @returns The total size of the queue.
360
+ * @param track The track to set.
363
361
  */
364
- totalSize(): Promise<number>;
362
+ setCurrent(track: Track | null): Promise<void>;
365
363
  /**
366
- * @returns The total duration of the queue.
364
+ * @param track The track to set.
367
365
  */
368
- duration(): Promise<number>;
366
+ setPrevious(track: Track | Track[]): Promise<void>;
369
367
  /**
370
368
  * Shuffles the queue.
371
369
  */
372
370
  shuffle(): Promise<void>;
373
371
  /**
374
- * Shuffles the queue by user.
372
+ * @returns The size of the queue.
375
373
  */
376
- userBlockShuffle(): Promise<void>;
374
+ size(): Promise<number>;
377
375
  /**
378
- * Shuffles the queue by round-robin.
376
+ * Tests whether at least one element in the queue passes the test implemented by the provided function.
379
377
  */
380
- roundRobinShuffle(): Promise<void>;
378
+ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
381
379
  /**
382
- * Removes the first track from the queue.
380
+ * @returns The total size of the queue.
383
381
  */
384
- dequeue(): Promise<Track | undefined>;
382
+ totalSize(): Promise<number>;
385
383
  /**
386
- * Adds a track to the front of the queue.
384
+ * Shuffles the queue by user.
387
385
  */
388
- enqueueFront(track: Track | Track[]): Promise<void>;
386
+ userBlockShuffle(): Promise<void>;
389
387
  /**
390
- * @returns The tracks in the queue.
388
+ * @returns The current path.
391
389
  */
392
- getTracks(): Promise<Track[]>;
390
+ private get currentPath();
393
391
  /**
394
- * @returns The tracks in the queue from start to end.
392
+ * @param filePath The file path.
395
393
  */
396
- getSlice(start?: number, end?: number): Promise<Track[]>;
394
+ private deleteFile;
397
395
  /**
398
- * Modifies the queue at the specified index.
396
+ * Ensures the directory exists.
399
397
  */
400
- modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
398
+ private ensureDir;
401
399
  /**
402
- * Maps the queue to a new array.
400
+ * @returns The queue.
403
401
  */
404
- mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
402
+ private getQueue;
405
403
  /**
406
- * Filters the queue.
404
+ * @returns The previous path.
407
405
  */
408
- filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
406
+ private get previousPath();
409
407
  /**
410
- * Finds the first track in the queue that satisfies the provided testing function.
408
+ * @returns The queue path.
411
409
  */
412
- findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
410
+ private get queuePath();
413
411
  /**
414
- * Tests whether at least one element in the queue passes the test implemented by the provided function.
412
+ * @param filePath The file path.
413
+ * @returns The JSON data.
415
414
  */
416
- someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
415
+ private readJSON;
417
416
  /**
418
- * Tests whether all elements in the queue pass the test implemented by the provided function.
417
+ * @param queue The queue.
419
418
  */
420
- everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
419
+ private setQueue;
420
+ /**
421
+ * @param filePath The file path.
422
+ * @param data The data to write.
423
+ */
424
+ private writeJSON;
421
425
  }
422
426
 
423
427
  /**
@@ -439,97 +443,71 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
439
443
  */
440
444
  constructor(guildId: string, manager: Manager);
441
445
  /**
442
- * @returns The current track.
443
- */
444
- getCurrent(): Promise<Track | null>;
445
- /**
446
- * @param track The track to set.
446
+ * Adds a track to the queue.
447
+ * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
448
+ * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
447
449
  */
448
- setCurrent(track: Track | null): Promise<void>;
450
+ add(track: Track | Track[], offset?: number): Promise<void>;
449
451
  /**
450
- * @returns The previous tracks.
452
+ * Adds a track to the previous tracks.
453
+ * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
451
454
  */
452
- getPrevious(): Promise<Track[]>;
453
455
  addPrevious(track: Track | Track[]): Promise<void>;
454
456
  /**
455
- * @param tracks The tracks to set.
456
- */
457
- setPrevious(tracks: Track[]): Promise<void>;
458
- /**
459
- * @returns The newest track.
457
+ * Clears the queue.
458
+ * This will remove all tracks from the queue and emit a state update event.
460
459
  */
461
- popPrevious(): Promise<Track | null>;
460
+ clear(): Promise<void>;
462
461
  /**
463
462
  * Clears the previous tracks.
464
463
  */
465
464
  clearPrevious(): Promise<void>;
465
+ /**
466
+ * Removes the first element from the queue.
467
+ */
468
+ dequeue(): Promise<Track | undefined>;
466
469
  /**
467
470
  * The total duration of the queue in milliseconds.
468
471
  * This includes the duration of the currently playing track.
469
472
  */
470
473
  duration(): Promise<number>;
471
474
  /**
472
- * The total size of tracks in the queue including the current track.
473
- * This includes the current track if it is not null.
474
- * @returns The total size of tracks in the queue including the current track.
475
- */
476
- totalSize(): Promise<number>;
477
- /**
478
- * The size of tracks in the queue.
479
- * This does not include the currently playing track.
480
- * @returns The size of tracks in the queue.
481
- */
482
- size(): Promise<number>;
483
- /**
484
- * Adds a track to the queue.
485
- * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
486
- * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
487
- */
488
- add(track: Track | Track[], offset?: number): Promise<void>;
489
- /**
490
- * Removes track(s) from the queue.
491
- * @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
492
- * If two numbers are provided, they will be used as the start and end of a range of tracks to remove.
493
- * @param end Optional, end of the range of tracks to remove.
494
- * @returns The removed track(s).
475
+ * Adds the specified track or tracks to the front of the queue.
476
+ * @param track The track or tracks to add.
495
477
  */
496
- remove(position?: number): Promise<Track[]>;
497
- remove(start: number, end: number): Promise<Track[]>;
478
+ enqueueFront(track: Track | Track[]): Promise<void>;
498
479
  /**
499
- * Clears the queue.
500
- * This will remove all tracks from the queue and emit a state update event.
480
+ * @returns Whether all elements in the queue satisfy the provided testing function.
501
481
  */
502
- clear(): Promise<void>;
482
+ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
503
483
  /**
504
- * Shuffles the queue.
505
- * This will randomize the order of the tracks in the queue and emit a state update event.
484
+ * @returns A new array with all elements that pass the test implemented by the provided function.
506
485
  */
507
- shuffle(): Promise<void>;
486
+ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
508
487
  /**
509
- * Shuffles the queue to play tracks requested by each user one block at a time.
488
+ * @returns The first element in the queue that satisfies the provided testing function.
510
489
  */
511
- userBlockShuffle(): Promise<void>;
490
+ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
512
491
  /**
513
- * Shuffles the queue to play tracks requested by each user one by one.
492
+ * @returns The current track.
514
493
  */
515
- roundRobinShuffle(): Promise<void>;
494
+ getCurrent(): Promise<Track | null>;
516
495
  /**
517
- * Removes the first element from the queue.
496
+ * @returns The previous tracks.
518
497
  */
519
- dequeue(): Promise<Track | undefined>;
498
+ getPrevious(): Promise<Track[]>;
520
499
  /**
521
- * Adds the specified track or tracks to the front of the queue.
522
- * @param track The track or tracks to add.
500
+ * @returns The tracks in the queue from start to end.
523
501
  */
524
- enqueueFront(track: Track | Track[]): Promise<void>;
502
+ getSlice(start?: number, end?: number): Promise<Track[]>;
525
503
  /**
526
- * @returns A shallow copy of the queue.
504
+ * @returns The tracks in the queue.
527
505
  */
528
506
  getTracks(): Promise<Track[]>;
529
507
  /**
530
- * @returns A shallow copy of the queue.
508
+ * @returns A new array with the results of calling a provided function on every element in the queue.
531
509
  */
532
- getSlice(start?: number, end?: number): Promise<Track[]>;
510
+ mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
533
511
  /**
534
512
  * Modifies the queue at the specified index.
535
513
  * @param start The index at which to start modifying the queue.
@@ -539,41 +517,71 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
539
517
  */
540
518
  modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
541
519
  /**
542
- * @returns A new array with the results of calling a provided function on every element in the queue.
520
+ * @returns The newest track.
543
521
  */
544
- mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
522
+ popPrevious(): Promise<Track | null>;
545
523
  /**
546
- * @returns A new array with all elements that pass the test implemented by the provided function.
524
+ * Removes track(s) from the queue.
525
+ * @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
526
+ * If two numbers are provided, they will be used as the start and end of a range of tracks to remove.
527
+ * @param end Optional, end of the range of tracks to remove.
528
+ * @returns The removed track(s).
547
529
  */
548
- filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
530
+ remove(position?: number): Promise<Track[]>;
531
+ remove(start: number, end: number): Promise<Track[]>;
549
532
  /**
550
- * @returns The first element in the queue that satisfies the provided testing function.
533
+ * Shuffles the queue to play tracks requested by each user one by one.
551
534
  */
552
- findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
535
+ roundRobinShuffle(): Promise<void>;
553
536
  /**
554
- * @returns Whether at least one element in the queue satisfies the provided testing function.
537
+ * @param track The track to set.
555
538
  */
556
- someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
539
+ setCurrent(track: Track | null): Promise<void>;
557
540
  /**
558
- * @returns Whether all elements in the queue satisfy the provided testing function.
541
+ * @param tracks The tracks to set.
559
542
  */
560
- everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
561
- }
562
-
563
- /**
564
- * The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
565
- */
566
- declare class RedisQueue implements IQueue {
567
- readonly guildId: string;
568
- readonly manager: Manager;
543
+ setPrevious(tracks: Track[]): Promise<void>;
569
544
  /**
570
- * The Redis instance.
545
+ * Shuffles the queue.
546
+ * This will randomize the order of the tracks in the queue and emit a state update event.
571
547
  */
572
- private redis;
548
+ shuffle(): Promise<void>;
549
+ /**
550
+ * The size of tracks in the queue.
551
+ * This does not include the currently playing track.
552
+ * @returns The size of tracks in the queue.
553
+ */
554
+ size(): Promise<number>;
555
+ /**
556
+ * @returns Whether at least one element in the queue satisfies the provided testing function.
557
+ */
558
+ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
559
+ /**
560
+ * The total size of tracks in the queue including the current track.
561
+ * This includes the current track if it is not null.
562
+ * @returns The total size of tracks in the queue including the current track.
563
+ */
564
+ totalSize(): Promise<number>;
565
+ /**
566
+ * Shuffles the queue to play tracks requested by each user one block at a time.
567
+ */
568
+ userBlockShuffle(): Promise<void>;
569
+ }
570
+
571
+ /**
572
+ * The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
573
+ */
574
+ declare class RedisQueue implements IQueue {
575
+ readonly guildId: string;
576
+ readonly manager: Manager;
573
577
  /**
574
578
  * The prefix for the Redis keys.
575
579
  */
576
580
  redisPrefix: string;
581
+ /**
582
+ * The Redis instance.
583
+ */
584
+ private redis;
577
585
  /**
578
586
  * Constructs a new RedisQueue.
579
587
  * @param guildId The guild ID.
@@ -581,133 +589,151 @@ declare class RedisQueue implements IQueue {
581
589
  */
582
590
  constructor(guildId: string, manager: Manager);
583
591
  /**
584
- * @returns The queue key.
592
+ * Adds a track or tracks to the queue.
593
+ * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
594
+ * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
585
595
  */
586
- private get queueKey();
596
+ add(track: Track | Track[], offset?: number): Promise<void>;
587
597
  /**
588
- * @returns The current key.
598
+ * Adds a track or tracks to the previous tracks.
599
+ * @param track The track or tracks to add.
589
600
  */
590
- private get currentKey();
601
+ addPrevious(track: Track | Track[]): Promise<void>;
591
602
  /**
592
- * @returns The previous key.
603
+ * Clears the queue.
593
604
  */
594
- private get previousKey();
605
+ clear(): Promise<void>;
595
606
  /**
596
- * Helper to serialize/deserialize Track
607
+ * Clears the previous tracks.
597
608
  */
598
- private serialize;
609
+ clearPrevious(): Promise<void>;
599
610
  /**
600
- * Helper to serialize/deserialize Track
611
+ * Removes the first track from the queue.
601
612
  */
602
- private deserialize;
613
+ dequeue(): Promise<Track | undefined>;
603
614
  /**
604
- * @returns The current track.
615
+ * @returns The total duration of the queue in milliseconds.
616
+ * This includes the duration of the currently playing track.
605
617
  */
606
- getCurrent(): Promise<Track | null>;
618
+ duration(): Promise<number>;
607
619
  /**
608
- * @param track The track to set.
620
+ * Adds a track to the front of the queue.
621
+ * @param track The track or tracks to add.
609
622
  */
610
- setCurrent(track: Track | null): Promise<void>;
623
+ enqueueFront(track: Track | Track[]): Promise<void>;
611
624
  /**
612
- * @returns The previous tracks.
625
+ * Whether all tracks in the queue match the specified condition.
626
+ * @param callback The condition to match.
627
+ * @returns Whether all tracks in the queue match the specified condition.
613
628
  */
614
- getPrevious(): Promise<Track[]>;
629
+ everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
615
630
  /**
616
- * @param track The track to add.
631
+ * Filters the tracks in the queue.
632
+ * @param callback The condition to match.
633
+ * @returns The tracks that match the condition.
617
634
  */
618
- addPrevious(track: Track | Track[]): Promise<void>;
635
+ filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
619
636
  /**
620
- * @param track The track to set.
637
+ * Finds the first track in the queue that matches the specified condition.
638
+ * @param callback The condition to match.
639
+ * @returns The first track that matches the condition.
621
640
  */
622
- setPrevious(track: Track | Track[]): Promise<void>;
641
+ findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
623
642
  /**
624
- * @returns The newest track.
643
+ * @returns The current track.
625
644
  */
626
- popPrevious(): Promise<Track | null>;
645
+ getCurrent(): Promise<Track | null>;
627
646
  /**
628
- * Clears the previous tracks.
647
+ * @returns The previous tracks.
629
648
  */
630
- clearPrevious(): Promise<void>;
649
+ getPrevious(): Promise<Track[]>;
631
650
  /**
632
- * @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
633
- * @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
651
+ * @returns The tracks in the queue from the start to the end.
634
652
  */
635
- add(track: Track | Track[], offset?: number): Promise<void>;
653
+ getSlice(start?: number, end?: number): Promise<Track[]>;
636
654
  /**
637
- * @param position The position to remove the track at.
638
- * @param end The end position to remove the track at.
655
+ * @returns The tracks in the queue.
639
656
  */
640
- remove(position?: number): Promise<Track[]>;
641
- remove(start: number, end: number): Promise<Track[]>;
657
+ getTracks(): Promise<Track[]>;
642
658
  /**
643
- * Clears the queue.
659
+ * Maps the tracks in the queue.
660
+ * @returns The tracks in the queue after the specified index.
644
661
  */
645
- clear(): Promise<void>;
662
+ mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
646
663
  /**
647
- * @returns The size of the queue.
664
+ * Modifies the queue at the specified index.
665
+ * @param start The start index.
666
+ * @param deleteCount The number of tracks to delete.
667
+ * @param items The tracks to insert.
668
+ * @returns The removed tracks.
648
669
  */
649
- size(): Promise<number>;
670
+ modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
650
671
  /**
651
- * @returns The total size of tracks in the queue including the current track.
672
+ * Removes the newest track.
673
+ * @returns The newest track.
652
674
  */
653
- totalSize(): Promise<number>;
675
+ popPrevious(): Promise<Track | null>;
654
676
  /**
655
- * @returns The total duration of the queue in milliseconds.
656
- * This includes the duration of the currently playing track.
677
+ * Removes the track at the specified index.
678
+ * @param position The position to remove the track at.
679
+ * @param end The end position to remove the track at.
657
680
  */
658
- duration(): Promise<number>;
681
+ remove(position?: number): Promise<Track[]>;
682
+ remove(start: number, end: number): Promise<Track[]>;
659
683
  /**
660
- * Shuffles the queue.
684
+ * Shuffles the queue round-robin style.
661
685
  */
662
- shuffle(): Promise<void>;
686
+ roundRobinShuffle(): Promise<void>;
663
687
  /**
664
- * Shuffles the queue, but keeps the tracks of the same user together.
688
+ * Sets the current track.
689
+ * @param track The track to set.
665
690
  */
666
- userBlockShuffle(): Promise<void>;
691
+ setCurrent(track: Track | null): Promise<void>;
667
692
  /**
668
- * Shuffles the queue round-robin style.
693
+ * Sets the previous track(s).
694
+ * @param track The track to set.
669
695
  */
670
- roundRobinShuffle(): Promise<void>;
696
+ setPrevious(track: Track | Track[]): Promise<void>;
671
697
  /**
672
- * Removes the first track from the queue.
698
+ * Shuffles the queue.
673
699
  */
674
- dequeue(): Promise<Track | undefined>;
700
+ shuffle(): Promise<void>;
675
701
  /**
676
- * Adds a track to the front of the queue.
702
+ * @returns The size of the queue.
677
703
  */
678
- enqueueFront(track: Track | Track[]): Promise<void>;
704
+ size(): Promise<number>;
679
705
  /**
680
- * @returns The tracks in the queue.
706
+ * @returns Whether any tracks in the queue match the specified condition.
681
707
  */
682
- getTracks(): Promise<Track[]>;
708
+ someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
683
709
  /**
684
- * @returns The tracks in the queue from the start to the end.
710
+ * @returns The total size of tracks in the queue including the current track.
685
711
  */
686
- getSlice(start?: number, end?: number): Promise<Track[]>;
712
+ totalSize(): Promise<number>;
687
713
  /**
688
- * Modifies the queue at the specified index.
714
+ * Shuffles the queue, but keeps the tracks of the same user together.
689
715
  */
690
- modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
716
+ userBlockShuffle(): Promise<void>;
691
717
  /**
692
- * @returns The tracks in the queue after the specified index.
718
+ * @returns The current key.
693
719
  */
694
- mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
720
+ private get currentKey();
695
721
  /**
696
- * @returns The tracks in the queue that match the specified condition.
722
+ * Deserializes a track from a string.
697
723
  */
698
- filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
724
+ private deserialize;
699
725
  /**
700
- * @returns The first track in the queue that matches the specified condition.
726
+ * @returns The previous key.
701
727
  */
702
- findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
728
+ private get previousKey();
703
729
  /**
704
- * @returns Whether any tracks in the queue match the specified condition.
730
+ * @returns The queue key.
705
731
  */
706
- someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
732
+ private get queueKey();
707
733
  /**
708
- * @returns Whether all tracks in the queue match the specified condition.
734
+ * Helper to serialize/deserialize Track
709
735
  */
710
- everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
736
+ private serialize;
711
737
  }
712
738
 
713
739
  /**
@@ -960,6 +986,9 @@ type PlayerStateUpdateEvent = {
960
986
  } | {
961
987
  changeType: PlayerStateEventTypes.RepeatChange;
962
988
  details: RepeatChangeEvent;
989
+ } | {
990
+ changeType: PlayerStateEventTypes.FilterChange;
991
+ details: FilterChangeEvent;
963
992
  };
964
993
  /**
965
994
  * Autoplay Change Event
@@ -979,6 +1008,10 @@ interface ConnectionChangeEvent {
979
1008
  previousConnection: boolean | null;
980
1009
  currentConnection: boolean | null;
981
1010
  }
1011
+ interface FilterChangeEvent {
1012
+ type: "filter";
1013
+ action: "change";
1014
+ }
982
1015
  /**
983
1016
  * Repeat Change Event
984
1017
  */
@@ -1914,1058 +1947,1059 @@ type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent;
1914
1947
  */
1915
1948
  type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
1916
1949
 
1917
- /** Handles the requests sent to the Lavalink REST API. */
1918
- declare class Rest {
1919
- /** The Node that this Rest instance is connected to. */
1920
- private node;
1921
- /** The ID of the current session. */
1922
- private sessionId;
1923
- /** The password for the Node. */
1924
- private readonly password;
1925
- /** The URL of the Node. */
1926
- private readonly url;
1927
- /** The Manager instance. */
1950
+ declare class Player {
1951
+ options: PlayerOptions;
1952
+ /** The Queue for the Player. */
1953
+ queue: IQueue;
1954
+ /** The filters applied to the audio. */
1955
+ filters: Filters;
1956
+ /** Whether the queue repeats the track. */
1957
+ trackRepeat: boolean;
1958
+ /** Whether the queue repeats the queue. */
1959
+ queueRepeat: boolean;
1960
+ /**Whether the queue repeats and shuffles after each song. */
1961
+ dynamicRepeat: boolean;
1962
+ /** The time the player is in the track. */
1963
+ position: number;
1964
+ /** Whether the player is playing. */
1965
+ playing: boolean;
1966
+ /** Whether the player is paused. */
1967
+ paused: boolean;
1968
+ /** The volume for the player */
1969
+ volume: number;
1970
+ /** The Node for the Player. */
1971
+ node: Node;
1972
+ /** The guild ID for the player. */
1973
+ guildId: string;
1974
+ /** The voice channel for the player. */
1975
+ voiceChannelId: string | null;
1976
+ /** The text channel for the player. */
1977
+ textChannelId: string | null;
1978
+ /**The now playing message. */
1979
+ nowPlayingMessage?: Message;
1980
+ /** The current state of the player. */
1981
+ state: StateTypes;
1982
+ /** The equalizer bands array. */
1983
+ bands: number[];
1984
+ /** The voice state object from Discord. */
1985
+ voiceState: VoiceState;
1986
+ /** The Manager. */
1928
1987
  manager: Manager;
1929
- /** Whether the node is a NodeLink. */
1930
- isNodeLink: boolean;
1931
- constructor(node: Node, manager: Manager);
1988
+ /** The autoplay state of the player. */
1989
+ isAutoplay: boolean;
1990
+ /** The number of times to try autoplay before emitting queueEnd. */
1991
+ autoplayTries: number;
1992
+ /** The cluster ID for the player. */
1993
+ clusterId: number;
1994
+ private readonly data;
1995
+ private dynamicLoopInterval;
1996
+ dynamicRepeatIntervalMs: number | null;
1997
+ private static _manager;
1998
+ /** Should only be used when the node is a NodeLink */
1999
+ protected voiceReceiverWsClient: WebSocket | null;
2000
+ protected isConnectToVoiceReceiver: boolean;
2001
+ protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null;
2002
+ protected voiceReceiverAttempt: number;
2003
+ protected voiceReceiverReconnectTries: number;
1932
2004
  /**
1933
- * Sets the session ID.
1934
- * This method is used to set the session ID after a resume operation is done.
1935
- * @param {string} sessionId The session ID to set.
1936
- * @returns {string} Returns the set session ID.
2005
+ * Creates a new player, returns one if it already exists.
2006
+ * @param options The player options.
2007
+ * @see https://docs.magmastream.com/main/introduction/getting-started
1937
2008
  */
1938
- setSessionId(sessionId: string): string;
2009
+ constructor(options: PlayerOptions);
1939
2010
  /**
1940
- * Retrieves all the players that are currently running on the node.
1941
- * @returns {Promise<unknown>} Returns the result of the GET request.
2011
+ * Initializes the static properties of the Player class.
2012
+ * @hidden
2013
+ * @param manager The Manager to use.
1942
2014
  */
1943
- getAllPlayers(): Promise<unknown>;
2015
+ static init(manager: Manager): void;
1944
2016
  /**
1945
- * Sends a PATCH request to update player related data.
1946
- * @param {RestPlayOptions} options The options to update the player with.
1947
- * @returns {Promise<unknown>} Returns the result of the PATCH request.
1948
- */
1949
- updatePlayer(options: RestPlayOptions): Promise<unknown>;
1950
- /**
1951
- * Sends a DELETE request to the server to destroy the player.
1952
- * @param {string} guildId The guild ID of the player to destroy.
1953
- * @returns {Promise<unknown>} Returns the result of the DELETE request.
1954
- */
1955
- destroyPlayer(guildId: string): Promise<unknown>;
1956
- /**
1957
- * Updates the session status for resuming.
1958
- * This method sends a PATCH request to update the session's resuming status and timeout.
1959
- *
1960
- * @param {boolean} resuming - Indicates whether the session should be set to resuming.
1961
- * @param {number} timeout - The timeout duration for the session resume.
1962
- * @returns {Promise<unknown>} The result of the PATCH request.
1963
- */
1964
- updateSession(resuming: boolean, timeout: number): Promise<unknown>;
1965
- /**
1966
- * Sends a request to the specified endpoint and returns the response data.
1967
- * @param {string} method The HTTP method to use for the request.
1968
- * @param {string} endpoint The endpoint to send the request to.
1969
- * @param {unknown} [body] The data to send in the request body.
1970
- * @returns {Promise<unknown>} The response data of the request.
1971
- */
1972
- private request;
1973
- /**
1974
- * Sends a GET request to the specified endpoint and returns the response data.
1975
- * @param {string} endpoint The endpoint to send the GET request to.
1976
- * @returns {Promise<unknown>} The response data of the GET request.
1977
- */
1978
- get(endpoint: string): Promise<unknown>;
1979
- /**
1980
- * Sends a PATCH request to the specified endpoint and returns the response data.
1981
- * @param {string} endpoint The endpoint to send the PATCH request to.
1982
- * @param {unknown} body The data to send in the request body.
1983
- * @returns {Promise<unknown>} The response data of the PATCH request.
1984
- */
1985
- patch(endpoint: string, body: unknown): Promise<unknown>;
1986
- /**
1987
- * Sends a POST request to the specified endpoint and returns the response data.
1988
- * @param {string} endpoint The endpoint to send the POST request to.
1989
- * @param {unknown} body The data to send in the request body.
1990
- * @returns {Promise<unknown>} The response data of the POST request.
2017
+ * Set custom data.
2018
+ * @param key - The key to set the data for.
2019
+ * @param value - The value to set the data to.
1991
2020
  */
1992
- post(endpoint: string, body: unknown): Promise<unknown>;
2021
+ set(key: string, value: unknown): void;
1993
2022
  /**
1994
- * Sends a PUT request to the specified endpoint and returns the response data.
1995
- * @param {string} endpoint The endpoint to send the PUT request to.
1996
- * @param {unknown} body The data to send in the request body.
1997
- * @returns {Promise<unknown>} The response data of the PUT request.
2023
+ * Retrieves custom data associated with a given key.
2024
+ * @template T - The expected type of the data.
2025
+ * @param {string} key - The key to retrieve the data for.
2026
+ * @returns {T} - The data associated with the key, cast to the specified type.
1998
2027
  */
1999
- put(endpoint: string, body: unknown): Promise<unknown>;
2028
+ get<T>(key: string): T;
2000
2029
  /**
2001
- * Sends a DELETE request to the specified endpoint.
2002
- * @param {string} endpoint - The endpoint to send the DELETE request to.
2003
- * @returns {Promise<unknown>} The response data of the DELETE request.
2030
+ * Same as Manager#search() but a shortcut on the player itself.
2031
+ * @param query
2032
+ * @param requester
2004
2033
  */
2005
- delete(endpoint: string): Promise<unknown>;
2006
- }
2007
-
2008
- declare class Node {
2009
- manager: Manager;
2010
- options: NodeOptions;
2011
- /** The socket for the node. */
2012
- socket: WebSocket | null;
2013
- /** The stats for the node. */
2014
- stats: NodeStats;
2015
- /** The manager for the node */
2016
- /** The node's session ID. */
2017
- sessionId: string | null;
2018
- /** The REST instance. */
2019
- readonly rest: Rest;
2020
- /** Actual Lavalink information of the node. */
2021
- info: LavalinkInfo | null;
2022
- /** Whether the node is a NodeLink. */
2023
- isNodeLink: boolean;
2024
- private reconnectTimeout?;
2025
- private reconnectAttempts;
2026
- private redisPrefix?;
2027
- private sessionIdsFilePath?;
2028
- private sessionIdsMap;
2034
+ search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
2029
2035
  /**
2030
- * Creates an instance of Node.
2031
- * @param manager - The manager for the node.
2032
- * @param options - The options for the node.
2036
+ * Connects the player to the voice channel.
2037
+ * @throws {RangeError} If no voice channel has been set.
2038
+ * @returns {void}
2033
2039
  */
2034
- constructor(manager: Manager, options: NodeOptions);
2040
+ connect(): void;
2035
2041
  /**
2036
- * Checks if the Node is currently connected.
2037
- * This method returns true if the Node has an active WebSocket connection, indicating it is ready to receive and process commands.
2042
+ * Disconnects the player from the voice channel.
2043
+ * @returns {this} The player instance.
2038
2044
  */
2039
- get connected(): boolean;
2040
- /** Returns the full address for this node, including the host and port. */
2041
- get address(): string;
2045
+ disconnect(): Promise<this>;
2042
2046
  /**
2043
- * Creates the sessionIds.json file if it doesn't exist. This file is used to
2044
- * store the session IDs for each node. The session IDs are used to identify
2045
- * the node when resuming a session.
2047
+ * Destroys the player and clears the queue.
2048
+ * @param {boolean} disconnect - Whether to disconnect the player from the voice channel.
2049
+ * @returns {Promise<boolean>} - Whether the player was successfully destroyed.
2050
+ * @emits {PlayerDestroy} - Emitted when the player is destroyed.
2051
+ * @emits {PlayerStateUpdate} - Emitted when the player state is updated.
2046
2052
  */
2047
- createSessionIdsFile(): void;
2053
+ destroy(disconnect?: boolean): Promise<boolean>;
2048
2054
  /**
2049
- * Loads session IDs from the sessionIds.json file if it exists.
2050
- * The session IDs are used to resume sessions for each node.
2051
- *
2052
- * The session IDs are stored in the sessionIds.json file as a composite key
2053
- * of the node identifier and cluster ID. This allows multiple clusters to
2054
- * be used with the same node identifier.
2055
+ * Sets the player voice channel.
2056
+ * @param {string} channel - The new voice channel ID.
2057
+ * @returns {this} - The player instance.
2058
+ * @throws {TypeError} If the channel parameter is not a string.
2055
2059
  */
2056
- loadSessionIds(): Promise<void>;
2060
+ setVoiceChannelId(channel: string): this;
2057
2061
  /**
2058
- * Updates the session ID in the sessionIds.json file.
2062
+ * Sets the player text channel.
2059
2063
  *
2060
- * This method is called after the session ID has been updated, and it
2061
- * writes the new session ID to the sessionIds.json file.
2064
+ * This method updates the text channel associated with the player. It also
2065
+ * emits a player state update event indicating the change in the channel.
2062
2066
  *
2063
- * @remarks
2064
- * The session ID is stored in the sessionIds.json file as a composite key
2065
- * of the node identifier and cluster ID. This allows multiple clusters to
2066
- * be used with the same node identifier.
2067
+ * @param {string} channel - The new text channel ID.
2068
+ * @returns {this} - The player instance for method chaining.
2069
+ * @throws {TypeError} If the channel parameter is not a string.
2067
2070
  */
2068
- updateSessionId(): Promise<void>;
2071
+ setTextChannelId(channel: string): this;
2069
2072
  /**
2070
- * Connects to the Node.
2073
+ * Sets the now playing message.
2071
2074
  *
2072
- * @remarks
2073
- * If the node is already connected, this method will do nothing.
2074
- * If the node has a session ID, it will be sent in the headers of the WebSocket connection.
2075
- * If the node has no session ID but the `enableSessionResumeOption` option is true, it will use the session ID
2076
- * stored in the sessionIds.json file if it exists.
2075
+ * @param message - The message of the now playing message.
2076
+ * @returns The now playing message.
2077
2077
  */
2078
- connect(): Promise<void>;
2078
+ setNowPlayingMessage<T = Message>(message: T): Message;
2079
2079
  /**
2080
- * Destroys the node and cleans up associated resources.
2080
+ * Plays the next track.
2081
2081
  *
2082
- * This method emits a debug event indicating that the node is being destroyed and attempts
2083
- * to automatically move all players connected to the node to a usable one. It then closes
2084
- * the WebSocket connection, removes all event listeners, and clears the reconnect timeout.
2085
- * Finally, it emits a "nodeDestroy" event and removes the node from the manager.
2082
+ * If a track is provided, it will be played. Otherwise, the next track in the queue will be played.
2083
+ * If the queue is not empty, but the current track has not finished yet, it will be replaced with the provided track.
2086
2084
  *
2087
- * @returns {Promise<void>} A promise that resolves when the node and its resources have been destroyed.
2085
+ * @param {object} [optionsOrTrack] - The track to play or the options to play with.
2086
+ * @param {object} [playOptions] - The options to play with.
2087
+ *
2088
+ * @returns {Promise<void>}
2088
2089
  */
2089
- destroy(): Promise<void>;
2090
+ play(): Promise<Player>;
2091
+ play(track: Track): Promise<Player>;
2092
+ play(options: PlayOptions): Promise<Player>;
2093
+ play(track: Track, options: PlayOptions): Promise<Player>;
2090
2094
  /**
2091
- * Attempts to reconnect to the node if the connection is lost.
2095
+ * Sets the autoplay-state of the player.
2092
2096
  *
2093
- * This method is called when the WebSocket connection is closed
2094
- * unexpectedly. It will attempt to reconnect to the node after a
2095
- * specified delay, and will continue to do so until the maximum
2096
- * number of retry attempts is reached or the node is manually destroyed.
2097
- * If the maximum number of retry attempts is reached, an error event
2098
- * will be emitted and the node will be destroyed.
2097
+ * Autoplay is a feature that makes the player play a recommended
2098
+ * track when the current track ends.
2099
2099
  *
2100
- * @returns {Promise<void>} - Resolves when the reconnection attempt is scheduled.
2101
- * @emits {debug} - Emits a debug event indicating the node is attempting to reconnect.
2102
- * @emits {nodeReconnect} - Emits a nodeReconnect event when the node is attempting to reconnect.
2103
- * @emits {nodeError} - Emits an error event if the maximum number of retry attempts is reached.
2104
- * @emits {nodeDestroy} - Emits a nodeDestroy event if the maximum number of retry attempts is reached.
2100
+ * @param {boolean} autoplayState - Whether or not autoplay should be enabled.
2101
+ * @param {object} botUser - The user-object that should be used as the bot-user.
2102
+ * @param {number} [tries=3] - The number of times the player should try to find a
2103
+ * recommended track if the first one doesn't work.
2104
+ * @returns {this} - The player instance.
2105
2105
  */
2106
- private reconnect;
2106
+ setAutoplay<T = unknown>(autoplayState: boolean, botUser?: T, tries?: number): this;
2107
2107
  /**
2108
- * Upgrades the node to a NodeLink.
2109
- *
2110
- * @param request - The incoming message.
2108
+ * Gets recommended tracks and returns an array of tracks.
2109
+ * @param {Track} track - The track to find recommendations for.
2110
+ * @returns {Promise<Track[]>} - Array of recommended tracks.
2111
2111
  */
2112
- private upgrade;
2112
+ getRecommendedTracks(track: Track): Promise<Track[]>;
2113
2113
  /**
2114
- * Handles the "open" event emitted by the WebSocket connection.
2115
- *
2116
- * This method is called when the WebSocket connection is established.
2117
- * It clears any existing reconnect timeouts, emits a debug event
2118
- * indicating the node is connected, and emits a "nodeConnect" event
2119
- * with the node as the argument.
2114
+ * Sets the volume of the player.
2115
+ * @param {number} volume - The new volume. Must be between 0 and 1000.
2116
+ * @returns {Promise<Player>} - The updated player.
2117
+ * @throws {TypeError} If the volume is not a number.
2118
+ * @throws {RangeError} If the volume is not between 0 and 1000.
2119
+ * @emits {PlayerStateUpdate} - Emitted when the volume is changed.
2120
+ * @example
2121
+ * player.setVolume(50);
2122
+ * player.setVolume(50, { gradual: true, interval: 50, step: 5 });
2120
2123
  */
2121
- protected open(): void;
2124
+ setVolume(volume: number): Promise<this>;
2122
2125
  /**
2123
- * Handles the "close" event emitted by the WebSocket connection.
2124
- *
2125
- * This method is called when the WebSocket connection is closed.
2126
- * It emits a "nodeDisconnect" event with the node and the close event as arguments,
2127
- * and a debug event indicating the node is disconnected.
2128
- * It then attempts to move all players connected to that node to a useable one.
2129
- * If the close event was not initiated by the user, it will also attempt to reconnect.
2130
- *
2131
- * @param {number} code The close code of the WebSocket connection.
2132
- * @param {string} reason The reason for the close event.
2133
- * @returns {Promise<void>} A promise that resolves when the disconnection is handled.
2126
+ * Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments.
2127
+ * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
2128
+ * @returns {Promise<void>} The promise is resolved when the operation is complete.
2134
2129
  */
2135
- protected close(code: number, reason: string): Promise<void>;
2130
+ setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
2136
2131
  /**
2137
- * Handles the "error" event emitted by the WebSocket connection.
2138
- *
2139
- * This method is called when an error occurs on the WebSocket connection.
2140
- * It emits a "nodeError" event with the node and the error as arguments and
2141
- * a debug event indicating the error on the node.
2142
- * @param {Error} error The error that occurred.
2132
+ * Gets the sponsorblock for the player.
2133
+ * @returns {Promise<SponsorBlockSegment[]>} The sponsorblock segments.
2143
2134
  */
2144
- protected error(error: Error): void;
2135
+ getSponsorBlock(): Promise<SponsorBlockSegment[]>;
2145
2136
  /**
2146
- * Handles incoming messages from the Lavalink WebSocket connection.
2147
- * @param {Buffer | string} d The message received from the WebSocket connection.
2148
- * @returns {Promise<void>} A promise that resolves when the message is handled.
2149
- * @emits {debug} - Emits a debug event with the message received from the WebSocket connection.
2150
- * @emits {nodeError} - Emits a nodeError event if an unexpected op is received.
2151
- * @emits {nodeRaw} - Emits a nodeRaw event with the raw message received from the WebSocket connection.
2152
- * @private
2137
+ * Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player.
2138
+ * @returns {Promise<void>}
2153
2139
  */
2154
- protected message(d: Buffer | string): Promise<void>;
2140
+ deleteSponsorBlock(): Promise<void>;
2155
2141
  /**
2156
- * Handles an event emitted from the Lavalink node.
2157
- * @param {PlayerEvent & PlayerEvents} payload The event emitted from the node.
2158
- * @returns {Promise<void>} A promise that resolves when the event has been handled.
2159
- * @private
2160
- */
2161
- protected handleEvent(payload: PlayerEvent & PlayerEvents): Promise<void>;
2162
- /**
2163
- * Emitted when a new track starts playing.
2164
- * @param {Player} player The player that started playing the track.
2165
- * @param {Track} track The track that started playing.
2166
- * @param {TrackStartEvent} payload The payload of the event emitted by the node.
2167
- * @private
2142
+ * Sets the track repeat mode.
2143
+ * When track repeat is enabled, the current track will replay after it ends.
2144
+ * Disables queueRepeat and dynamicRepeat modes if enabled.
2145
+ *
2146
+ * @param repeat - A boolean indicating whether to enable track repeat.
2147
+ * @returns {this} - The player instance.
2148
+ * @throws {TypeError} If the repeat parameter is not a boolean.
2168
2149
  */
2169
- protected trackStart(player: Player, track: Track, payload: TrackStartEvent): void;
2150
+ setTrackRepeat(repeat: boolean): this;
2170
2151
  /**
2171
- * Emitted when a track ends playing.
2172
- * @param {Player} player - The player that the track ended on.
2173
- * @param {Track} track - The track that ended.
2174
- * @param {TrackEndEvent} payload - The payload of the event emitted by the node.
2175
- * @private
2152
+ * Sets the queue repeat.
2153
+ * @param repeat Whether to repeat the queue or not
2154
+ * @returns {this} - The player instance.
2155
+ * @throws {TypeError} If the repeat parameter is not a boolean
2176
2156
  */
2177
- trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
2157
+ setQueueRepeat(repeat: boolean): this;
2178
2158
  /**
2179
- * Handles autoplay logic for a player.
2180
- * This method is responsible for selecting an appropriate method of autoplay
2181
- * and executing it. If autoplay is not enabled or all attempts have failed,
2182
- * it will return false.
2183
- * @param {Player} player - The player to handle autoplay for.
2184
- * @param {number} attempt - The current attempt number of the autoplay.
2185
- * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if autoplay was successful.
2186
- * @private
2159
+ * Sets the queue to repeat and shuffles the queue after each song.
2160
+ * @param repeat "true" or "false".
2161
+ * @param ms After how many milliseconds to trigger dynamic repeat.
2162
+ * @returns {this} - The player instance.
2163
+ * @throws {TypeError} If the repeat parameter is not a boolean.
2164
+ * @throws {RangeError} If the queue size is less than or equal to 1.
2187
2165
  */
2188
- private handleAutoplay;
2166
+ setDynamicRepeat(repeat: boolean, ms: number): Promise<this>;
2189
2167
  /**
2190
- * Handles the scenario when a track fails to play or load.
2191
- * Shifts the queue to the next track and emits a track end event.
2192
- * If there is no next track, handles the queue end scenario.
2193
- * If autoplay is enabled, plays the next track.
2194
- *
2195
- * @param {Player} player - The player instance associated with the track.
2196
- * @param {Track} track - The track that failed.
2197
- * @param {TrackEndEvent} payload - The event payload containing details about the track end.
2198
- * @returns {Promise<void>} A promise that resolves when the track failure has been processed.
2199
- * @private
2168
+ * Restarts the currently playing track from the beginning.
2169
+ * If there is no track playing, it will play the next track in the queue.
2170
+ * @returns {Promise<Player>} The current instance of the Player class for method chaining.
2200
2171
  */
2201
- private handleFailedTrack;
2172
+ restart(): Promise<Player>;
2202
2173
  /**
2203
- * Handles the scenario when a track is repeated.
2204
- * Shifts the queue to the next track and emits a track end event.
2205
- * If there is no next track, handles the queue end scenario.
2206
- * If autoplay is enabled, plays the next track.
2207
- *
2208
- * @param {Player} player - The player instance associated with the track.
2209
- * @param {Track} track - The track that is repeated.
2210
- * @param {TrackEndEvent} payload - The event payload containing details about the track end.
2211
- * @returns {Promise<void>} A promise that resolves when the repeated track has been processed.
2212
- * @private
2174
+ * Stops the player and optionally removes tracks from the queue.
2175
+ * @param {number} [amount] The amount of tracks to remove from the queue. If not provided, removes the current track if it exists.
2176
+ * @returns {Promise<this>} - The player instance.
2177
+ * @throws {RangeError} If the amount is greater than the queue length.
2213
2178
  */
2214
- private handleRepeatedTrack;
2179
+ stop(amount?: number): Promise<this>;
2215
2180
  /**
2216
- * Plays the next track in the queue.
2217
- * Updates the queue by shifting the current track to the previous track
2218
- * and plays the next track if autoplay is enabled.
2219
- *
2220
- * @param {Player} player - The player associated with the track.
2221
- * @param {Track} track - The track that has ended.
2222
- * @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
2223
- * @returns {void}
2224
- * @private
2181
+ * Skips the current track.
2182
+ * @returns {this} - The player instance.
2183
+ * @throws {Error} If there are no tracks in the queue.
2184
+ * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
2225
2185
  */
2226
- private playNextTrack;
2186
+ pause(pause: boolean): Promise<this>;
2227
2187
  /**
2228
- * Handles the event when a queue ends.
2229
- * If autoplay is enabled, attempts to play the next track in the queue using the autoplay logic.
2230
- * If all attempts fail, resets the player state and emits the `queueEnd` event.
2231
- * @param {Player} player - The player associated with the track.
2232
- * @param {Track} track - The track that has ended.
2233
- * @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
2234
- * @returns {Promise<void>} A promise that resolves when the queue end processing is complete.
2188
+ * Skips to the previous track in the queue.
2189
+ * @returns {this} - The player instance.
2190
+ * @throws {Error} If there are no previous tracks in the queue.
2191
+ * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
2235
2192
  */
2236
- queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
2193
+ previous(): Promise<this>;
2237
2194
  /**
2238
- * Fetches the lyrics of a track from the Lavalink node.
2239
- *
2240
- * If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
2241
- *
2242
- * Requires the `lavalyrics-plugin` to be present in the Lavalink node.
2243
- * Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node.
2244
- *
2245
- * @param {Track} track - The track to fetch the lyrics for.
2246
- * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
2247
- * @param {string} [language="en"] - The language of the lyrics.
2248
- * @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
2195
+ * Seeks to a given position in the currently playing track.
2196
+ * @param position - The position in milliseconds to seek to.
2197
+ * @returns {this} - The player instance.
2198
+ * @throws {Error} If the position is invalid.
2199
+ * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
2249
2200
  */
2250
- getLyrics(track: Track, skipTrackSource?: boolean, language?: string): Promise<Lyrics | NodeLinkGetLyrics>;
2201
+ seek(position: number): Promise<this>;
2251
2202
  /**
2252
- * Subscribes to lyrics for a player.
2253
- * @param {string} guildId - The ID of the guild to subscribe to lyrics for.
2254
- * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
2255
- * @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
2256
- * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
2203
+ * Returns the current repeat state of the player.
2204
+ * @param player The player to get the repeat state from.
2205
+ * @returns The repeat state of the player, or null if it is not repeating.
2257
2206
  */
2258
- lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise<unknown>;
2207
+ private getRepeatState;
2259
2208
  /**
2260
- * Unsubscribes from lyrics for a player.
2261
- * @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
2262
- * @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
2263
- * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
2209
+ * Automatically moves the player to a usable node.
2210
+ * @returns {Promise<Player | void>} - The player instance or void if not moved.
2264
2211
  */
2265
- lyricsUnsubscribe(guildId: string): Promise<unknown>;
2212
+ autoMoveNode(): Promise<Player | void>;
2266
2213
  /**
2267
- * Handles the event when a track becomes stuck during playback.
2268
- * Stops the current track and emits a `trackStuck` event.
2269
- *
2270
- * @param {Player} player - The player associated with the track that became stuck.
2271
- * @param {Track} track - The track that became stuck.
2272
- * @param {TrackStuckEvent} payload - The event payload containing additional data about the track stuck event.
2273
- * @returns {void}
2274
- * @protected
2214
+ * Moves the player to another node.
2215
+ * @param {string} identifier - The identifier of the node to move to.
2216
+ * @returns {Promise<Player>} - The player instance after being moved.
2275
2217
  */
2276
- protected trackStuck(player: Player, track: Track, payload: TrackStuckEvent): Promise<void>;
2218
+ moveNode(identifier: string): Promise<Player>;
2277
2219
  /**
2278
- * Handles the event when a track has an error during playback.
2279
- * Stops the current track and emits a `trackError` event.
2280
- *
2281
- * @param {Player} player - The player associated with the track that had an error.
2282
- * @param {Track} track - The track that had an error.
2283
- * @param {TrackExceptionEvent} payload - The event payload containing additional data about the track error event.
2284
- * @returns {void}
2285
- * @protected
2220
+ * Transfers the player to a new server. If the player already exists on the new server
2221
+ * and force is false, this method will return the existing player. Otherwise, a new player
2222
+ * will be created and the current player will be destroyed.
2223
+ * @param {PlayerOptions} newOptions - The new options for the player.
2224
+ * @param {boolean} force - Whether to force the creation of a new player.
2225
+ * @returns {Promise<Player>} - The new player instance.
2286
2226
  */
2287
- protected trackError(player: Player, track: Track, payload: TrackExceptionEvent): Promise<void>;
2227
+ switchGuild(newOptions: PlayerOptions, force?: boolean): Promise<Player>;
2288
2228
  /**
2289
- * Emitted when the WebSocket connection for a player closes.
2290
- * The payload of the event will contain the close code and reason if provided.
2291
- * @param {Player} player - The player associated with the WebSocket connection.
2292
- * @param {WebSocketClosedEvent} payload - The event payload containing additional data about the WebSocket close event.
2229
+ * Retrieves the current lyrics for the playing track.
2230
+ * @param skipTrackSource - Indicates whether to skip the track source when fetching lyrics.
2231
+ * @returns {Promise<Lyrics>} - The lyrics of the current track.
2232
+ * @throws {RangeError} - If the 'lavalyrics-plugin' is not available on the Lavalink node.
2293
2233
  */
2294
- protected socketClosed(player: Player, payload: WebSocketClosedEvent): void;
2234
+ getCurrentLyrics(skipTrackSource?: boolean): Promise<Lyrics>;
2295
2235
  /**
2296
- * Emitted when the segments for a track are loaded.
2297
- * The payload of the event will contain the segments.
2298
- * @param {Player} player - The player associated with the segments.
2299
- * @param {Track} track - The track associated with the segments.
2300
- * @param {SponsorBlockSegmentsLoaded} payload - The event payload containing additional data about the segments loaded event.
2236
+ * Sets up the voice receiver for the player.
2237
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver is set up.
2238
+ * @throws {Error} - If the node is not a NodeLink.
2301
2239
  */
2302
- private sponsorBlockSegmentLoaded;
2240
+ setupVoiceReceiver(): Promise<void>;
2303
2241
  /**
2304
- * Emitted when a segment of a track is skipped using the sponsorblock plugin.
2305
- * The payload of the event will contain the skipped segment.
2306
- * @param {Player} player - The player associated with the skipped segment.
2307
- * @param {Track} track - The track associated with the skipped segment.
2308
- * @param {SponsorBlockSegmentSkipped} payload - The event payload containing additional data about the segment skipped event.
2242
+ * Removes the voice receiver for the player.
2243
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver is removed.
2244
+ * @throws {Error} - If the node is not a NodeLink.
2309
2245
  */
2310
- private sponsorBlockSegmentSkipped;
2246
+ removeVoiceReceiver(): Promise<void>;
2311
2247
  /**
2312
- * Emitted when chapters for a track are loaded using the sponsorblock plugin.
2313
- * The payload of the event will contain the chapters.
2314
- * @param {Player} player - The player associated with the chapters.
2315
- * @param {Track} track - The track associated with the chapters.
2316
- * @param {SponsorBlockChaptersLoaded} payload - The event payload containing additional data about the chapters loaded event.
2248
+ * Closes the voice receiver for the player.
2249
+ * @param {number} code - The code to close the voice receiver with.
2250
+ * @param {string} reason - The reason to close the voice receiver with.
2251
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver is closed.
2317
2252
  */
2318
- private sponsorBlockChaptersLoaded;
2253
+ private closeVoiceReceiver;
2319
2254
  /**
2320
- * Emitted when a chapter of a track is started using the sponsorblock plugin.
2321
- * The payload of the event will contain the started chapter.
2322
- * @param {Player} player - The player associated with the started chapter.
2323
- * @param {Track} track - The track associated with the started chapter.
2324
- * @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event.
2255
+ * Reconnects the voice receiver for the player.
2256
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver is reconnected.
2325
2257
  */
2326
- private sponsorBlockChapterStarted;
2258
+ private reconnectVoiceReceiver;
2327
2259
  /**
2328
- * Emitted when lyrics for a track are found.
2329
- * The payload of the event will contain the lyrics.
2330
- * @param {Player} player - The player associated with the lyrics.
2331
- * @param {Track} track - The track associated with the lyrics.
2332
- * @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
2260
+ * Disconnects the voice receiver for the player.
2261
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver is disconnected.
2333
2262
  */
2334
- private lyricsFound;
2263
+ private disconnectVoiceReceiver;
2335
2264
  /**
2336
- * Emitted when lyrics for a track are not found.
2337
- * The payload of the event will contain the track.
2338
- * @param {Player} player - The player associated with the lyrics.
2339
- * @param {Track} track - The track associated with the lyrics.
2340
- * @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
2265
+ * Opens the voice receiver for the player.
2266
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver is opened.
2341
2267
  */
2342
- private lyricsNotFound;
2268
+ private openVoiceReceiver;
2343
2269
  /**
2344
- * Emitted when a line of lyrics for a track is received.
2345
- * The payload of the event will contain the lyrics line.
2346
- * @param {Player} player - The player associated with the lyrics line.
2347
- * @param {Track} track - The track associated with the lyrics line.
2348
- * @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
2270
+ * Handles a voice receiver message.
2271
+ * @param {string} payload - The payload to handle.
2272
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver message is handled.
2349
2273
  */
2350
- private lyricsLine;
2274
+ private onVoiceReceiverMessage;
2351
2275
  /**
2352
- * Fetches Lavalink node information.
2353
- * @returns {Promise<LavalinkInfo>} A promise that resolves to the Lavalink node information.
2276
+ * Handles a voice receiver error.
2277
+ * @param {Error} error - The error to handle.
2278
+ * @returns {Promise<void>} - A promise that resolves when the voice receiver error is handled.
2354
2279
  */
2355
- fetchInfo(): Promise<LavalinkInfo>;
2356
- /**
2357
- * Gets the current sponsorblock segments for a player.
2358
- * @param {Player} player - The player to get the sponsorblocks for.
2359
- * @returns {Promise<SponsorBlockSegment[]>} A promise that resolves to the sponsorblock segments.
2360
- * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
2361
- */
2362
- getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>;
2280
+ private onVoiceReceiverError;
2281
+ }
2282
+
2283
+ /** Handles the requests sent to the Lavalink REST API. */
2284
+ declare class Rest {
2285
+ /** The Node that this Rest instance is connected to. */
2286
+ private node;
2287
+ /** The ID of the current session. */
2288
+ private sessionId;
2289
+ /** The password for the Node. */
2290
+ private readonly password;
2291
+ /** The URL of the Node. */
2292
+ private readonly url;
2293
+ /** The Manager instance. */
2294
+ manager: Manager;
2295
+ /** Whether the node is a NodeLink. */
2296
+ isNodeLink: boolean;
2297
+ constructor(node: Node, manager: Manager);
2363
2298
  /**
2364
- * Sets the sponsorblock segments for a player.
2365
- * @param {Player} player - The player to set the sponsor blocks for.
2366
- * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
2367
- * @returns {Promise<void>} The promise is resolved when the operation is complete.
2368
- * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
2369
- * @throws {RangeError} If no segments are provided.
2370
- * @throws {SyntaxError} If an invalid sponsorblock is provided.
2371
- * @example
2372
- * ```ts
2373
- * // use it on the player via player.setSponsorBlock();
2374
- * player.setSponsorBlock([SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]);
2375
- * ```
2299
+ * Sets the session ID.
2300
+ * This method is used to set the session ID after a resume operation is done.
2301
+ * @param {string} sessionId The session ID to set.
2302
+ * @returns {string} Returns the set session ID.
2376
2303
  */
2377
- setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise<void>;
2304
+ setSessionId(sessionId: string): string;
2378
2305
  /**
2379
- * Deletes the sponsorblock segments for a player.
2380
- * @param {Player} player - The player to delete the sponsorblocks for.
2381
- * @returns {Promise<void>} The promise is resolved when the operation is complete.
2382
- * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
2306
+ * Retrieves all the players that are currently running on the node.
2307
+ * @returns {Promise<unknown>} Returns the result of the GET request.
2383
2308
  */
2384
- deleteSponsorBlock(player: Player): Promise<void>;
2309
+ getAllPlayers(): Promise<unknown>;
2385
2310
  /**
2386
- * Creates a README.md or README.txt file in the magmastream directory
2387
- * if it doesn't already exist. This file is used to store player data
2388
- * for autoresume and other features.
2389
- * @private
2311
+ * Sends a PATCH request to update player related data.
2312
+ * @param {RestPlayOptions} options The options to update the player with.
2313
+ * @returns {Promise<unknown>} Returns the result of the PATCH request.
2390
2314
  */
2391
- private createReadmeFile;
2392
- }
2393
-
2394
- /**
2395
- * The main hub for interacting with Lavalink and using Magmastream.
2396
- */
2397
- declare class Manager extends EventEmitter {
2398
- /** The map of players. */
2399
- readonly players: Collection<string, Player>;
2400
- /** The map of nodes. */
2401
- readonly nodes: Collection<string, Node>;
2402
- /** The options that were set. */
2403
- readonly options: ManagerOptions;
2404
- initiated: boolean;
2405
- redis?: Redis;
2406
- private _send;
2407
- private loadedPlugins;
2315
+ updatePlayer(options: RestPlayOptions): Promise<unknown>;
2408
2316
  /**
2409
- * Initiates the Manager class.
2410
- * @param options
2411
- * @param options.enabledPlugins - An array of enabledPlugins to load.
2412
- * @param options.nodes - An array of node options to create nodes from.
2413
- * @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
2414
- * @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
2415
- * @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
2416
- * @param options.clientName - The name of the client to send to Lavalink.
2417
- * @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
2418
- * @param options.useNode - The strategy to use when selecting a node to play on.
2419
- * @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
2420
- * @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
2421
- * @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
2317
+ * Sends a DELETE request to the server to destroy the player.
2318
+ * @param {string} guildId The guild ID of the player to destroy.
2319
+ * @returns {Promise<unknown>} Returns the result of the DELETE request.
2422
2320
  */
2423
- constructor(options: ManagerOptions);
2321
+ destroyPlayer(guildId: string): Promise<unknown>;
2424
2322
  /**
2425
- * Initiates the Manager.
2426
- * @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
2427
- * @param clusterId - The cluster ID which runs the current process (required).
2428
- * @returns The manager instance.
2323
+ * Updates the session status for resuming.
2324
+ * This method sends a PATCH request to update the session's resuming status and timeout.
2325
+ *
2326
+ * @param {boolean} resuming - Indicates whether the session should be set to resuming.
2327
+ * @param {number} timeout - The timeout duration for the session resume.
2328
+ * @returns {Promise<unknown>} The result of the PATCH request.
2429
2329
  */
2430
- init(options?: ManagerInitOptions): Promise<this>;
2330
+ updateSession(resuming: boolean, timeout: number): Promise<unknown>;
2431
2331
  /**
2432
- * Searches the enabled sources based off the URL or the `source` property.
2433
- * @param query
2434
- * @param requester
2435
- * @returns The search result.
2332
+ * Sends a request to the specified endpoint and returns the response data.
2333
+ * @param {string} method The HTTP method to use for the request.
2334
+ * @param {string} endpoint The endpoint to send the request to.
2335
+ * @param {unknown} [body] The data to send in the request body.
2336
+ * @returns {Promise<unknown>} The response data of the request.
2436
2337
  */
2437
- search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
2338
+ private request;
2438
2339
  /**
2439
- * Returns a player or undefined if it does not exist.
2440
- * @param guildId The guild ID of the player to retrieve.
2441
- * @returns The player if it exists, undefined otherwise.
2340
+ * Sends a GET request to the specified endpoint and returns the response data.
2341
+ * @param {string} endpoint The endpoint to send the GET request to.
2342
+ * @returns {Promise<unknown>} The response data of the GET request.
2442
2343
  */
2443
- getPlayer(guildId: string): Player | undefined;
2344
+ get(endpoint: string): Promise<unknown>;
2444
2345
  /**
2445
- * Creates a player or returns one if it already exists.
2446
- * @param options The options to create the player with.
2447
- * @returns The created player.
2346
+ * Sends a PATCH request to the specified endpoint and returns the response data.
2347
+ * @param {string} endpoint The endpoint to send the PATCH request to.
2348
+ * @param {unknown} body The data to send in the request body.
2349
+ * @returns {Promise<unknown>} The response data of the PATCH request.
2448
2350
  */
2449
- create(options: PlayerOptions): Player;
2351
+ patch(endpoint: string, body: unknown): Promise<unknown>;
2450
2352
  /**
2451
- * Destroys a player.
2452
- * @param guildId The guild ID of the player to destroy.
2453
- * @returns A promise that resolves when the player has been destroyed.
2353
+ * Sends a POST request to the specified endpoint and returns the response data.
2354
+ * @param {string} endpoint The endpoint to send the POST request to.
2355
+ * @param {unknown} body The data to send in the request body.
2356
+ * @returns {Promise<unknown>} The response data of the POST request.
2454
2357
  */
2455
- destroy(guildId: string): Promise<void>;
2358
+ post(endpoint: string, body: unknown): Promise<unknown>;
2456
2359
  /**
2457
- * Creates a new node or returns an existing one if it already exists.
2458
- * @param options - The options to create the node with.
2459
- * @returns The created node.
2360
+ * Sends a PUT request to the specified endpoint and returns the response data.
2361
+ * @param {string} endpoint The endpoint to send the PUT request to.
2362
+ * @param {unknown} body The data to send in the request body.
2363
+ * @returns {Promise<unknown>} The response data of the PUT request.
2460
2364
  */
2461
- createNode(options: NodeOptions): Node;
2365
+ put(endpoint: string, body: unknown): Promise<unknown>;
2462
2366
  /**
2463
- * Destroys a node if it exists. Emits a debug event if the node is found and destroyed.
2464
- * @param identifier - The identifier of the node to destroy.
2465
- * @returns {void}
2466
- * @emits {debug} - Emits a debug message indicating the node is being destroyed.
2367
+ * Sends a DELETE request to the specified endpoint.
2368
+ * @param {string} endpoint - The endpoint to send the DELETE request to.
2369
+ * @returns {Promise<unknown>} The response data of the DELETE request.
2467
2370
  */
2468
- destroyNode(identifier: string): Promise<void>;
2371
+ delete(endpoint: string): Promise<unknown>;
2372
+ }
2373
+
2374
+ declare class Node {
2375
+ manager: Manager;
2376
+ options: NodeOptions;
2377
+ /** The socket for the node. */
2378
+ socket: WebSocket$1 | null;
2379
+ /** The stats for the node. */
2380
+ stats: NodeStats;
2381
+ /** The manager for the node */
2382
+ /** The node's session ID. */
2383
+ sessionId: string | null;
2384
+ /** The REST instance. */
2385
+ readonly rest: Rest;
2386
+ /** Actual Lavalink information of the node. */
2387
+ info: LavalinkInfo | null;
2388
+ /** Whether the node is a NodeLink. */
2389
+ isNodeLink: boolean;
2390
+ private reconnectTimeout?;
2391
+ private reconnectAttempts;
2392
+ private redisPrefix?;
2393
+ private sessionIdsFilePath?;
2394
+ private sessionIdsMap;
2469
2395
  /**
2470
- * Attaches an event listener to the manager.
2471
- * @param event The event to listen for.
2472
- * @param listener The function to call when the event is emitted.
2473
- * @returns The manager instance for chaining.
2396
+ * Creates an instance of Node.
2397
+ * @param manager - The manager for the node.
2398
+ * @param options - The options for the node.
2474
2399
  */
2475
- on<T extends keyof ManagerEvents>(event: T, listener: (...args: ManagerEvents[T]) => void): this;
2400
+ constructor(manager: Manager, options: NodeOptions);
2476
2401
  /**
2477
- * Updates the voice state of a player based on the provided data.
2478
- * @param data - The data containing voice state information, which can be a VoicePacket, VoiceServer, or VoiceState.
2479
- * @returns A promise that resolves when the voice state update is handled.
2480
- * @emits {debug} - Emits a debug message indicating the voice state is being updated.
2402
+ * Checks if the Node is currently connected.
2403
+ * This method returns true if the Node has an active WebSocket connection, indicating it is ready to receive and process commands.
2481
2404
  */
2482
- updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
2405
+ get connected(): boolean;
2406
+ /** Returns the full address for this node, including the host and port. */
2407
+ get address(): string;
2483
2408
  /**
2484
- * Decodes an array of base64 encoded tracks and returns an array of TrackData.
2485
- * Emits a debug event with the tracks being decoded.
2486
- * @param tracks - An array of base64 encoded track strings.
2487
- * @returns A promise that resolves to an array of TrackData objects.
2488
- * @throws Will throw an error if no nodes are available or if the API request fails.
2409
+ * Creates the sessionIds.json file if it doesn't exist. This file is used to
2410
+ * store the session IDs for each node. The session IDs are used to identify
2411
+ * the node when resuming a session.
2489
2412
  */
2490
- decodeTracks(tracks: string[]): Promise<TrackData[]>;
2413
+ createSessionIdsFile(): void;
2491
2414
  /**
2492
- * Decodes a base64 encoded track and returns a TrackData.
2493
- * @param track - The base64 encoded track string.
2494
- * @returns A promise that resolves to a TrackData object.
2495
- * @throws Will throw an error if no nodes are available or if the API request fails.
2415
+ * Loads session IDs from the sessionIds.json file if it exists.
2416
+ * The session IDs are used to resume sessions for each node.
2417
+ *
2418
+ * The session IDs are stored in the sessionIds.json file as a composite key
2419
+ * of the node identifier and cluster ID. This allows multiple clusters to
2420
+ * be used with the same node identifier.
2496
2421
  */
2497
- decodeTrack(track: string): Promise<TrackData>;
2422
+ loadSessionIds(): Promise<void>;
2498
2423
  /**
2499
- * Saves player states.
2500
- * @param {string} guildId - The guild ID of the player to save
2424
+ * Updates the session ID in the sessionIds.json file.
2425
+ *
2426
+ * This method is called after the session ID has been updated, and it
2427
+ * writes the new session ID to the sessionIds.json file.
2428
+ *
2429
+ * @remarks
2430
+ * The session ID is stored in the sessionIds.json file as a composite key
2431
+ * of the node identifier and cluster ID. This allows multiple clusters to
2432
+ * be used with the same node identifier.
2501
2433
  */
2502
- savePlayerState(guildId: string): Promise<void>;
2434
+ updateSessionId(): Promise<void>;
2503
2435
  /**
2504
- * Sleeps for a specified amount of time.
2505
- * @param ms The amount of time to sleep in milliseconds.
2506
- * @returns A promise that resolves after the specified amount of time.
2436
+ * Connects to the Node.
2437
+ *
2438
+ * @remarks
2439
+ * If the node is already connected, this method will do nothing.
2440
+ * If the node has a session ID, it will be sent in the headers of the WebSocket connection.
2441
+ * If the node has no session ID but the `enableSessionResumeOption` option is true, it will use the session ID
2442
+ * stored in the sessionIds.json file if it exists.
2507
2443
  */
2508
- private sleep;
2444
+ connect(): Promise<void>;
2509
2445
  /**
2510
- * Loads player states from the JSON file.
2511
- * @param nodeId The ID of the node to load player states from.
2512
- * @returns A promise that resolves when the player states have been loaded.
2446
+ * Destroys the node and cleans up associated resources.
2447
+ *
2448
+ * This method emits a debug event indicating that the node is being destroyed and attempts
2449
+ * to automatically move all players connected to the node to a usable one. It then closes
2450
+ * the WebSocket connection, removes all event listeners, and clears the reconnect timeout.
2451
+ * Finally, it emits a "nodeDestroy" event and removes the node from the manager.
2452
+ *
2453
+ * @returns {Promise<void>} A promise that resolves when the node and its resources have been destroyed.
2513
2454
  */
2514
- loadPlayerStates(nodeId: string): Promise<void>;
2455
+ destroy(): Promise<void>;
2515
2456
  /**
2516
- * Returns the node to use based on the configured `useNode` and `enablePriorityMode` options.
2517
- * If `enablePriorityMode` is true, the node is chosen based on priority, otherwise it is chosen based on the `useNode` option.
2518
- * If `useNode` is "leastLoad", the node with the lowest load is chosen, if it is "leastPlayers", the node with the fewest players is chosen.
2519
- * If `enablePriorityMode` is false and `useNode` is not set, the node with the lowest load is chosen.
2520
- * @returns {Node} The node to use.
2457
+ * Attempts to reconnect to the node if the connection is lost.
2458
+ *
2459
+ * This method is called when the WebSocket connection is closed
2460
+ * unexpectedly. It will attempt to reconnect to the node after a
2461
+ * specified delay, and will continue to do so until the maximum
2462
+ * number of retry attempts is reached or the node is manually destroyed.
2463
+ * If the maximum number of retry attempts is reached, an error event
2464
+ * will be emitted and the node will be destroyed.
2465
+ *
2466
+ * @returns {Promise<void>} - Resolves when the reconnection attempt is scheduled.
2467
+ * @emits {debug} - Emits a debug event indicating the node is attempting to reconnect.
2468
+ * @emits {nodeReconnect} - Emits a nodeReconnect event when the node is attempting to reconnect.
2469
+ * @emits {nodeError} - Emits an error event if the maximum number of retry attempts is reached.
2470
+ * @emits {nodeDestroy} - Emits a nodeDestroy event if the maximum number of retry attempts is reached.
2521
2471
  */
2522
- get useableNode(): Node;
2472
+ private reconnect;
2523
2473
  /**
2524
- * Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.
2525
- * This function is called when the process is about to exit.
2526
- * It iterates through all players and calls {@link savePlayerState} to save their states.
2527
- * Optionally, it also calls {@link cleanupInactivePlayers} to remove any stale player state files.
2528
- * After saving and cleaning up, it exits the process.
2474
+ * Upgrades the node to a NodeLink.
2475
+ *
2476
+ * @param request - The incoming message.
2529
2477
  */
2530
- handleShutdown(): Promise<void>;
2478
+ private upgrade;
2531
2479
  /**
2532
- * Parses a YouTube title into a clean title and author.
2533
- * @param title - The original title of the YouTube video.
2534
- * @param originalAuthor - The original author of the YouTube video.
2535
- * @returns An object with the clean title and author.
2480
+ * Handles the "open" event emitted by the WebSocket connection.
2481
+ *
2482
+ * This method is called when the WebSocket connection is established.
2483
+ * It clears any existing reconnect timeouts, emits a debug event
2484
+ * indicating the node is connected, and emits a "nodeConnect" event
2485
+ * with the node as the argument.
2536
2486
  */
2537
- private parseYouTubeTitle;
2487
+ protected open(): void;
2538
2488
  /**
2539
- * Balances brackets in a given string by ensuring all opened brackets are closed correctly.
2540
- * @param str - The input string that may contain unbalanced brackets.
2541
- * @returns A new string with balanced brackets.
2489
+ * Handles the "close" event emitted by the WebSocket connection.
2490
+ *
2491
+ * This method is called when the WebSocket connection is closed.
2492
+ * It emits a "nodeDisconnect" event with the node and the close event as arguments,
2493
+ * and a debug event indicating the node is disconnected.
2494
+ * It then attempts to move all players connected to that node to a useable one.
2495
+ * If the close event was not initiated by the user, it will also attempt to reconnect.
2496
+ *
2497
+ * @param {number} code The close code of the WebSocket connection.
2498
+ * @param {string} reason The reason for the close event.
2499
+ * @returns {Promise<void>} A promise that resolves when the disconnection is handled.
2542
2500
  */
2543
- private balanceBrackets;
2501
+ protected close(code: number, reason: string): Promise<void>;
2544
2502
  /**
2545
- * Escapes a string by replacing special regex characters with their escaped counterparts.
2546
- * @param string - The string to escape.
2547
- * @returns The escaped string.
2503
+ * Handles the "error" event emitted by the WebSocket connection.
2504
+ *
2505
+ * This method is called when an error occurs on the WebSocket connection.
2506
+ * It emits a "nodeError" event with the node and the error as arguments and
2507
+ * a debug event indicating the error on the node.
2508
+ * @param {Error} error The error that occurred.
2548
2509
  */
2549
- private escapeRegExp;
2510
+ protected error(error: Error): void;
2550
2511
  /**
2551
- * Checks if the given data is a voice update.
2552
- * @param data The data to check.
2553
- * @returns Whether the data is a voice update.
2512
+ * Handles incoming messages from the Lavalink WebSocket connection.
2513
+ * @param {Buffer | string} d The message received from the WebSocket connection.
2514
+ * @returns {Promise<void>} A promise that resolves when the message is handled.
2515
+ * @emits {debug} - Emits a debug event with the message received from the WebSocket connection.
2516
+ * @emits {nodeError} - Emits a nodeError event if an unexpected op is received.
2517
+ * @emits {nodeRaw} - Emits a nodeRaw event with the raw message received from the WebSocket connection.
2518
+ * @private
2554
2519
  */
2555
- private isVoiceUpdate;
2520
+ protected message(d: Buffer | string): Promise<void>;
2556
2521
  /**
2557
- * Determines if the provided update is a valid voice update.
2558
- * A valid update must contain either a token or a session_id.
2522
+ * Handles an event emitted from the Lavalink node.
2523
+ * @param {PlayerEvent & PlayerEvents} payload The event emitted from the node.
2524
+ * @returns {Promise<void>} A promise that resolves when the event has been handled.
2525
+ * @private
2526
+ */
2527
+ protected handleEvent(payload: PlayerEvent & PlayerEvents): Promise<void>;
2528
+ /**
2529
+ * Emitted when a new track starts playing.
2530
+ * @param {Player} player The player that started playing the track.
2531
+ * @param {Track} track The track that started playing.
2532
+ * @param {TrackStartEvent} payload The payload of the event emitted by the node.
2533
+ * @private
2534
+ */
2535
+ protected trackStart(player: Player, track: Track, payload: TrackStartEvent): void;
2536
+ /**
2537
+ * Emitted when a track ends playing.
2538
+ * @param {Player} player - The player that the track ended on.
2539
+ * @param {Track} track - The track that ended.
2540
+ * @param {TrackEndEvent} payload - The payload of the event emitted by the node.
2541
+ * @private
2542
+ */
2543
+ trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
2544
+ /**
2545
+ * Handles autoplay logic for a player.
2546
+ * This method is responsible for selecting an appropriate method of autoplay
2547
+ * and executing it. If autoplay is not enabled or all attempts have failed,
2548
+ * it will return false.
2549
+ * @param {Player} player - The player to handle autoplay for.
2550
+ * @param {number} attempt - The current attempt number of the autoplay.
2551
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if autoplay was successful.
2552
+ * @private
2553
+ */
2554
+ private handleAutoplay;
2555
+ /**
2556
+ * Handles the scenario when a track fails to play or load.
2557
+ * Shifts the queue to the next track and emits a track end event.
2558
+ * If there is no next track, handles the queue end scenario.
2559
+ * If autoplay is enabled, plays the next track.
2559
2560
  *
2560
- * @param update - The voice update data to validate, which can be a VoicePacket, VoiceServer, or VoiceState.
2561
- * @returns {boolean} - True if the update is valid, otherwise false.
2561
+ * @param {Player} player - The player instance associated with the track.
2562
+ * @param {Track} track - The track that failed.
2563
+ * @param {TrackEndEvent} payload - The event payload containing details about the track end.
2564
+ * @returns {Promise<void>} A promise that resolves when the track failure has been processed.
2565
+ * @private
2562
2566
  */
2563
- private isValidUpdate;
2567
+ private handleFailedTrack;
2564
2568
  /**
2565
- * Handles a voice server update by updating the player's voice state and sending the voice state to the Lavalink node.
2566
- * @param player The player for which the voice state is being updated.
2567
- * @param update The voice server data received from Discord.
2568
- * @returns A promise that resolves when the voice state update is handled.
2569
- * @emits {debug} - Emits a debug message indicating the voice state is being updated.
2569
+ * Handles the scenario when a track is repeated.
2570
+ * Shifts the queue to the next track and emits a track end event.
2571
+ * If there is no next track, handles the queue end scenario.
2572
+ * If autoplay is enabled, plays the next track.
2573
+ *
2574
+ * @param {Player} player - The player instance associated with the track.
2575
+ * @param {Track} track - The track that is repeated.
2576
+ * @param {TrackEndEvent} payload - The event payload containing details about the track end.
2577
+ * @returns {Promise<void>} A promise that resolves when the repeated track has been processed.
2578
+ * @private
2570
2579
  */
2571
- private handleVoiceServerUpdate;
2580
+ private handleRepeatedTrack;
2572
2581
  /**
2573
- * Handles a voice state update by updating the player's voice channel and session ID if provided, or by disconnecting and destroying the player if the channel ID is null.
2574
- * @param player The player for which the voice state is being updated.
2575
- * @param update The voice state data received from Discord.
2576
- * @emits {playerMove} - Emits a player move event if the channel ID is provided and the player is currently connected to a different voice channel.
2577
- * @emits {playerDisconnect} - Emits a player disconnect event if the channel ID is null.
2582
+ * Plays the next track in the queue.
2583
+ * Updates the queue by shifting the current track to the previous track
2584
+ * and plays the next track if autoplay is enabled.
2585
+ *
2586
+ * @param {Player} player - The player associated with the track.
2587
+ * @param {Track} track - The track that has ended.
2588
+ * @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
2589
+ * @returns {void}
2590
+ * @private
2578
2591
  */
2579
- private handleVoiceStateUpdate;
2592
+ private playNextTrack;
2580
2593
  /**
2581
- * Cleans up inactive players by removing their state files from the file system.
2582
- * This is done to prevent stale state files from accumulating on the file system.
2594
+ * Handles the event when a queue ends.
2595
+ * If autoplay is enabled, attempts to play the next track in the queue using the autoplay logic.
2596
+ * If all attempts fail, resets the player state and emits the `queueEnd` event.
2597
+ * @param {Player} player - The player associated with the track.
2598
+ * @param {Track} track - The track that has ended.
2599
+ * @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
2600
+ * @returns {Promise<void>} A promise that resolves when the queue end processing is complete.
2583
2601
  */
2584
- cleanupInactivePlayers(): Promise<void>;
2602
+ queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
2585
2603
  /**
2586
- * Cleans up an inactive player by removing its state data.
2587
- * This is done to prevent stale state data from accumulating.
2588
- * @param guildId The guild ID of the player to clean up.
2604
+ * Fetches the lyrics of a track from the Lavalink node.
2605
+ *
2606
+ * If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
2607
+ *
2608
+ * Requires the `lavalyrics-plugin` to be present in the Lavalink node.
2609
+ * Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node.
2610
+ *
2611
+ * @param {Track} track - The track to fetch the lyrics for.
2612
+ * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
2613
+ * @param {string} [language="en"] - The language of the lyrics.
2614
+ * @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
2589
2615
  */
2590
- cleanupInactivePlayer(guildId: string): Promise<void>;
2616
+ getLyrics(track: Track, skipTrackSource?: boolean, language?: string): Promise<Lyrics | NodeLinkGetLyrics>;
2591
2617
  /**
2592
- * Loads the enabled plugins.
2618
+ * Subscribes to lyrics for a player.
2619
+ * @param {string} guildId - The ID of the guild to subscribe to lyrics for.
2620
+ * @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
2621
+ * @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
2622
+ * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
2593
2623
  */
2594
- private loadPlugins;
2624
+ lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise<unknown>;
2595
2625
  /**
2596
- * Unloads the enabled plugins.
2626
+ * Unsubscribes from lyrics for a player.
2627
+ * @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
2628
+ * @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
2629
+ * @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
2597
2630
  */
2598
- private unloadPlugins;
2631
+ lyricsUnsubscribe(guildId: string): Promise<unknown>;
2599
2632
  /**
2600
- * Clears all player states from the file system.
2601
- * This is done to prevent stale state files from accumulating on the file system.
2633
+ * Handles the event when a track becomes stuck during playback.
2634
+ * Stops the current track and emits a `trackStuck` event.
2635
+ *
2636
+ * @param {Player} player - The player associated with the track that became stuck.
2637
+ * @param {Track} track - The track that became stuck.
2638
+ * @param {TrackStuckEvent} payload - The event payload containing additional data about the track stuck event.
2639
+ * @returns {void}
2640
+ * @protected
2602
2641
  */
2603
- private clearAllStoredPlayers;
2642
+ protected trackStuck(player: Player, track: Track, payload: TrackStuckEvent): Promise<void>;
2604
2643
  /**
2605
- * Returns the nodes that has the least load.
2606
- * The load is calculated by dividing the lavalink load by the number of cores.
2607
- * The result is multiplied by 100 to get a percentage.
2608
- * @returns {Collection<string, Node>}
2644
+ * Handles the event when a track has an error during playback.
2645
+ * Stops the current track and emits a `trackError` event.
2646
+ *
2647
+ * @param {Player} player - The player associated with the track that had an error.
2648
+ * @param {Track} track - The track that had an error.
2649
+ * @param {TrackExceptionEvent} payload - The event payload containing additional data about the track error event.
2650
+ * @returns {void}
2651
+ * @protected
2609
2652
  */
2610
- private get leastLoadNode();
2653
+ protected trackError(player: Player, track: Track, payload: TrackExceptionEvent): Promise<void>;
2611
2654
  /**
2612
- * Returns the nodes that have the least amount of players.
2613
- * Filters out disconnected nodes and sorts the remaining nodes
2614
- * by the number of players in ascending order.
2615
- * @returns {Collection<string, Node>} A collection of nodes sorted by player count.
2655
+ * Emitted when the WebSocket connection for a player closes.
2656
+ * The payload of the event will contain the close code and reason if provided.
2657
+ * @param {Player} player - The player associated with the WebSocket connection.
2658
+ * @param {WebSocketClosedEvent} payload - The event payload containing additional data about the WebSocket close event.
2616
2659
  */
2617
- private get leastPlayersNode();
2660
+ protected socketClosed(player: Player, payload: WebSocketClosedEvent): void;
2618
2661
  /**
2619
- * Returns a node based on priority.
2620
- * The nodes are sorted by priority in descending order, and then a random number
2621
- * between 0 and 1 is generated. The node that has a cumulative weight greater than or equal to the
2622
- * random number is returned.
2623
- * If no node has a cumulative weight greater than or equal to the random number, the node with the
2624
- * lowest load is returned.
2625
- * @returns {Node} The node to use.
2662
+ * Emitted when the segments for a track are loaded.
2663
+ * The payload of the event will contain the segments.
2664
+ * @param {Player} player - The player associated with the segments.
2665
+ * @param {Track} track - The track associated with the segments.
2666
+ * @param {SponsorBlockSegmentsLoaded} payload - The event payload containing additional data about the segments loaded event.
2626
2667
  */
2627
- private get priorityNode();
2628
- protected send(packet: GatewayVoiceStateUpdate): unknown;
2629
- sendPacket(packet: GatewayVoiceStateUpdate): unknown;
2630
- }
2631
-
2632
- declare class Player {
2633
- options: PlayerOptions;
2634
- /** The Queue for the Player. */
2635
- queue: IQueue;
2636
- /** The filters applied to the audio. */
2637
- filters: Filters;
2638
- /** Whether the queue repeats the track. */
2639
- trackRepeat: boolean;
2640
- /** Whether the queue repeats the queue. */
2641
- queueRepeat: boolean;
2642
- /**Whether the queue repeats and shuffles after each song. */
2643
- dynamicRepeat: boolean;
2644
- /** The time the player is in the track. */
2645
- position: number;
2646
- /** Whether the player is playing. */
2647
- playing: boolean;
2648
- /** Whether the player is paused. */
2649
- paused: boolean;
2650
- /** The volume for the player */
2651
- volume: number;
2652
- /** The Node for the Player. */
2653
- node: Node;
2654
- /** The guild ID for the player. */
2655
- guildId: string;
2656
- /** The voice channel for the player. */
2657
- voiceChannelId: string | null;
2658
- /** The text channel for the player. */
2659
- textChannelId: string | null;
2660
- /**The now playing message. */
2661
- nowPlayingMessage?: Message;
2662
- /** The current state of the player. */
2663
- state: StateTypes;
2664
- /** The equalizer bands array. */
2665
- bands: number[];
2666
- /** The voice state object from Discord. */
2667
- voiceState: VoiceState;
2668
- /** The Manager. */
2669
- manager: Manager;
2670
- /** The autoplay state of the player. */
2671
- isAutoplay: boolean;
2672
- /** The number of times to try autoplay before emitting queueEnd. */
2673
- autoplayTries: number;
2674
- /** The cluster ID for the player. */
2675
- clusterId: number;
2676
- private readonly data;
2677
- private dynamicLoopInterval;
2678
- dynamicRepeatIntervalMs: number | null;
2679
- private static _manager;
2680
- /** Should only be used when the node is a NodeLink */
2681
- protected voiceReceiverWsClient: WebSocket$1 | null;
2682
- protected isConnectToVoiceReceiver: boolean;
2683
- protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null;
2684
- protected voiceReceiverAttempt: number;
2685
- protected voiceReceiverReconnectTries: number;
2668
+ private sponsorBlockSegmentLoaded;
2686
2669
  /**
2687
- * Creates a new player, returns one if it already exists.
2688
- * @param options The player options.
2689
- * @see https://docs.magmastream.com/main/introduction/getting-started
2670
+ * Emitted when a segment of a track is skipped using the sponsorblock plugin.
2671
+ * The payload of the event will contain the skipped segment.
2672
+ * @param {Player} player - The player associated with the skipped segment.
2673
+ * @param {Track} track - The track associated with the skipped segment.
2674
+ * @param {SponsorBlockSegmentSkipped} payload - The event payload containing additional data about the segment skipped event.
2690
2675
  */
2691
- constructor(options: PlayerOptions);
2676
+ private sponsorBlockSegmentSkipped;
2692
2677
  /**
2693
- * Initializes the static properties of the Player class.
2694
- * @hidden
2695
- * @param manager The Manager to use.
2678
+ * Emitted when chapters for a track are loaded using the sponsorblock plugin.
2679
+ * The payload of the event will contain the chapters.
2680
+ * @param {Player} player - The player associated with the chapters.
2681
+ * @param {Track} track - The track associated with the chapters.
2682
+ * @param {SponsorBlockChaptersLoaded} payload - The event payload containing additional data about the chapters loaded event.
2696
2683
  */
2697
- static init(manager: Manager): void;
2684
+ private sponsorBlockChaptersLoaded;
2698
2685
  /**
2699
- * Set custom data.
2700
- * @param key - The key to set the data for.
2701
- * @param value - The value to set the data to.
2686
+ * Emitted when a chapter of a track is started using the sponsorblock plugin.
2687
+ * The payload of the event will contain the started chapter.
2688
+ * @param {Player} player - The player associated with the started chapter.
2689
+ * @param {Track} track - The track associated with the started chapter.
2690
+ * @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event.
2702
2691
  */
2703
- set(key: string, value: unknown): void;
2692
+ private sponsorBlockChapterStarted;
2704
2693
  /**
2705
- * Retrieves custom data associated with a given key.
2706
- * @template T - The expected type of the data.
2707
- * @param {string} key - The key to retrieve the data for.
2708
- * @returns {T} - The data associated with the key, cast to the specified type.
2694
+ * Emitted when lyrics for a track are found.
2695
+ * The payload of the event will contain the lyrics.
2696
+ * @param {Player} player - The player associated with the lyrics.
2697
+ * @param {Track} track - The track associated with the lyrics.
2698
+ * @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
2709
2699
  */
2710
- get<T>(key: string): T;
2700
+ private lyricsFound;
2711
2701
  /**
2712
- * Same as Manager#search() but a shortcut on the player itself.
2713
- * @param query
2714
- * @param requester
2702
+ * Emitted when lyrics for a track are not found.
2703
+ * The payload of the event will contain the track.
2704
+ * @param {Player} player - The player associated with the lyrics.
2705
+ * @param {Track} track - The track associated with the lyrics.
2706
+ * @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
2715
2707
  */
2716
- search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
2708
+ private lyricsNotFound;
2717
2709
  /**
2718
- * Connects the player to the voice channel.
2719
- * @throws {RangeError} If no voice channel has been set.
2720
- * @returns {void}
2710
+ * Emitted when a line of lyrics for a track is received.
2711
+ * The payload of the event will contain the lyrics line.
2712
+ * @param {Player} player - The player associated with the lyrics line.
2713
+ * @param {Track} track - The track associated with the lyrics line.
2714
+ * @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
2721
2715
  */
2722
- connect(): Promise<void>;
2716
+ private lyricsLine;
2723
2717
  /**
2724
- * Disconnects the player from the voice channel.
2725
- * @returns {this} The player instance.
2718
+ * Fetches Lavalink node information.
2719
+ * @returns {Promise<LavalinkInfo>} A promise that resolves to the Lavalink node information.
2726
2720
  */
2727
- disconnect(): Promise<this>;
2721
+ fetchInfo(): Promise<LavalinkInfo>;
2728
2722
  /**
2729
- * Destroys the player and clears the queue.
2730
- * @param {boolean} disconnect - Whether to disconnect the player from the voice channel.
2731
- * @returns {Promise<boolean>} - Whether the player was successfully destroyed.
2732
- * @emits {PlayerDestroy} - Emitted when the player is destroyed.
2733
- * @emits {PlayerStateUpdate} - Emitted when the player state is updated.
2723
+ * Gets the current sponsorblock segments for a player.
2724
+ * @param {Player} player - The player to get the sponsorblocks for.
2725
+ * @returns {Promise<SponsorBlockSegment[]>} A promise that resolves to the sponsorblock segments.
2726
+ * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
2734
2727
  */
2735
- destroy(disconnect?: boolean): Promise<boolean>;
2728
+ getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>;
2736
2729
  /**
2737
- * Sets the player voice channel.
2738
- * @param {string} channel - The new voice channel ID.
2739
- * @returns {this} - The player instance.
2740
- * @throws {TypeError} If the channel parameter is not a string.
2730
+ * Sets the sponsorblock segments for a player.
2731
+ * @param {Player} player - The player to set the sponsor blocks for.
2732
+ * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
2733
+ * @returns {Promise<void>} The promise is resolved when the operation is complete.
2734
+ * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
2735
+ * @throws {RangeError} If no segments are provided.
2736
+ * @throws {SyntaxError} If an invalid sponsorblock is provided.
2737
+ * @example
2738
+ * ```ts
2739
+ * // use it on the player via player.setSponsorBlock();
2740
+ * player.setSponsorBlock([SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]);
2741
+ * ```
2741
2742
  */
2742
- setVoiceChannelId(channel: string): this;
2743
+ setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise<void>;
2743
2744
  /**
2744
- * Sets the player text channel.
2745
- *
2746
- * This method updates the text channel associated with the player. It also
2747
- * emits a player state update event indicating the change in the channel.
2748
- *
2749
- * @param {string} channel - The new text channel ID.
2750
- * @returns {this} - The player instance for method chaining.
2751
- * @throws {TypeError} If the channel parameter is not a string.
2745
+ * Deletes the sponsorblock segments for a player.
2746
+ * @param {Player} player - The player to delete the sponsorblocks for.
2747
+ * @returns {Promise<void>} The promise is resolved when the operation is complete.
2748
+ * @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
2752
2749
  */
2753
- setTextChannelId(channel: string): this;
2750
+ deleteSponsorBlock(player: Player): Promise<void>;
2754
2751
  /**
2755
- * Sets the now playing message.
2756
- *
2757
- * @param message - The message of the now playing message.
2758
- * @returns The now playing message.
2752
+ * Creates a README.md or README.txt file in the magmastream directory
2753
+ * if it doesn't already exist. This file is used to store player data
2754
+ * for autoresume and other features.
2755
+ * @private
2759
2756
  */
2760
- setNowPlayingMessage<T = Message>(message: T): Message;
2757
+ private createReadmeFile;
2758
+ }
2759
+
2760
+ /**
2761
+ * The main hub for interacting with Lavalink and using Magmastream.
2762
+ */
2763
+ declare class Manager extends EventEmitter {
2764
+ /** The map of players. */
2765
+ readonly players: Collection<string, Player>;
2766
+ /** The map of nodes. */
2767
+ readonly nodes: Collection<string, Node>;
2768
+ /** The options that were set. */
2769
+ readonly options: ManagerOptions;
2770
+ initiated: boolean;
2771
+ redis?: Redis;
2772
+ private _send;
2773
+ private loadedPlugins;
2761
2774
  /**
2762
- * Plays the next track.
2763
- *
2764
- * If a track is provided, it will be played. Otherwise, the next track in the queue will be played.
2765
- * If the queue is not empty, but the current track has not finished yet, it will be replaced with the provided track.
2766
- *
2767
- * @param {object} [optionsOrTrack] - The track to play or the options to play with.
2768
- * @param {object} [playOptions] - The options to play with.
2769
- *
2770
- * @returns {Promise<void>}
2775
+ * Initiates the Manager class.
2776
+ * @param options
2777
+ * @param options.enabledPlugins - An array of enabledPlugins to load.
2778
+ * @param options.nodes - An array of node options to create nodes from.
2779
+ * @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
2780
+ * @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
2781
+ * @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
2782
+ * @param options.clientName - The name of the client to send to Lavalink.
2783
+ * @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
2784
+ * @param options.useNode - The strategy to use when selecting a node to play on.
2785
+ * @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
2786
+ * @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
2787
+ * @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
2771
2788
  */
2772
- play(): Promise<Player>;
2773
- play(track: Track): Promise<Player>;
2774
- play(options: PlayOptions): Promise<Player>;
2775
- play(track: Track, options: PlayOptions): Promise<Player>;
2789
+ constructor(options: ManagerOptions);
2776
2790
  /**
2777
- * Sets the autoplay-state of the player.
2778
- *
2779
- * Autoplay is a feature that makes the player play a recommended
2780
- * track when the current track ends.
2781
- *
2782
- * @param {boolean} autoplayState - Whether or not autoplay should be enabled.
2783
- * @param {object} botUser - The user-object that should be used as the bot-user.
2784
- * @param {number} [tries=3] - The number of times the player should try to find a
2785
- * recommended track if the first one doesn't work.
2786
- * @returns {this} - The player instance.
2791
+ * Initiates the Manager.
2792
+ * @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
2793
+ * @param clusterId - The cluster ID which runs the current process (required).
2794
+ * @returns The manager instance.
2795
+ */
2796
+ init(options?: ManagerInitOptions): Promise<this>;
2797
+ /**
2798
+ * Searches the enabled sources based off the URL or the `source` property.
2799
+ * @param query
2800
+ * @param requester
2801
+ * @returns The search result.
2802
+ */
2803
+ search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
2804
+ /**
2805
+ * Returns a player or undefined if it does not exist.
2806
+ * @param guildId The guild ID of the player to retrieve.
2807
+ * @returns The player if it exists, undefined otherwise.
2808
+ */
2809
+ getPlayer(guildId: string): Player | undefined;
2810
+ /**
2811
+ * Creates a player or returns one if it already exists.
2812
+ * @param options The options to create the player with.
2813
+ * @returns The created player.
2787
2814
  */
2788
- setAutoplay<T = unknown>(autoplayState: boolean, botUser?: T, tries?: number): this;
2815
+ create(options: PlayerOptions): Player;
2789
2816
  /**
2790
- * Gets recommended tracks and returns an array of tracks.
2791
- * @param {Track} track - The track to find recommendations for.
2792
- * @returns {Promise<Track[]>} - Array of recommended tracks.
2817
+ * Destroys a player.
2818
+ * @param guildId The guild ID of the player to destroy.
2819
+ * @returns A promise that resolves when the player has been destroyed.
2793
2820
  */
2794
- getRecommendedTracks(track: Track): Promise<Track[]>;
2821
+ destroy(guildId: string): Promise<void>;
2795
2822
  /**
2796
- * Sets the volume of the player.
2797
- * @param {number} volume - The new volume. Must be between 0 and 1000.
2798
- * @returns {Promise<Player>} - The updated player.
2799
- * @throws {TypeError} If the volume is not a number.
2800
- * @throws {RangeError} If the volume is not between 0 and 1000.
2801
- * @emits {PlayerStateUpdate} - Emitted when the volume is changed.
2802
- * @example
2803
- * player.setVolume(50);
2804
- * player.setVolume(50, { gradual: true, interval: 50, step: 5 });
2823
+ * Creates a new node or returns an existing one if it already exists.
2824
+ * @param options - The options to create the node with.
2825
+ * @returns The created node.
2805
2826
  */
2806
- setVolume(volume: number): Promise<this>;
2827
+ createNode(options: NodeOptions): Node;
2807
2828
  /**
2808
- * Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments.
2809
- * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
2810
- * @returns {Promise<void>} The promise is resolved when the operation is complete.
2829
+ * Destroys a node if it exists. Emits a debug event if the node is found and destroyed.
2830
+ * @param identifier - The identifier of the node to destroy.
2831
+ * @returns {void}
2832
+ * @emits {debug} - Emits a debug message indicating the node is being destroyed.
2811
2833
  */
2812
- setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
2834
+ destroyNode(identifier: string): Promise<void>;
2813
2835
  /**
2814
- * Gets the sponsorblock for the player.
2815
- * @returns {Promise<SponsorBlockSegment[]>} The sponsorblock segments.
2836
+ * Attaches an event listener to the manager.
2837
+ * @param event The event to listen for.
2838
+ * @param listener The function to call when the event is emitted.
2839
+ * @returns The manager instance for chaining.
2816
2840
  */
2817
- getSponsorBlock(): Promise<SponsorBlockSegment[]>;
2841
+ on<T extends keyof ManagerEvents>(event: T, listener: (...args: ManagerEvents[T]) => void): this;
2818
2842
  /**
2819
- * Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player.
2820
- * @returns {Promise<void>}
2843
+ * Updates the voice state of a player based on the provided data.
2844
+ * @param data - The data containing voice state information, which can be a VoicePacket, VoiceServer, or VoiceState.
2845
+ * @returns A promise that resolves when the voice state update is handled.
2846
+ * @emits {debug} - Emits a debug message indicating the voice state is being updated.
2821
2847
  */
2822
- deleteSponsorBlock(): Promise<void>;
2848
+ updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
2823
2849
  /**
2824
- * Sets the track repeat mode.
2825
- * When track repeat is enabled, the current track will replay after it ends.
2826
- * Disables queueRepeat and dynamicRepeat modes if enabled.
2827
- *
2828
- * @param repeat - A boolean indicating whether to enable track repeat.
2829
- * @returns {this} - The player instance.
2830
- * @throws {TypeError} If the repeat parameter is not a boolean.
2850
+ * Decodes an array of base64 encoded tracks and returns an array of TrackData.
2851
+ * Emits a debug event with the tracks being decoded.
2852
+ * @param tracks - An array of base64 encoded track strings.
2853
+ * @returns A promise that resolves to an array of TrackData objects.
2854
+ * @throws Will throw an error if no nodes are available or if the API request fails.
2831
2855
  */
2832
- setTrackRepeat(repeat: boolean): this;
2856
+ decodeTracks(tracks: string[]): Promise<TrackData[]>;
2833
2857
  /**
2834
- * Sets the queue repeat.
2835
- * @param repeat Whether to repeat the queue or not
2836
- * @returns {this} - The player instance.
2837
- * @throws {TypeError} If the repeat parameter is not a boolean
2858
+ * Decodes a base64 encoded track and returns a TrackData.
2859
+ * @param track - The base64 encoded track string.
2860
+ * @returns A promise that resolves to a TrackData object.
2861
+ * @throws Will throw an error if no nodes are available or if the API request fails.
2838
2862
  */
2839
- setQueueRepeat(repeat: boolean): this;
2863
+ decodeTrack(track: string): Promise<TrackData>;
2840
2864
  /**
2841
- * Sets the queue to repeat and shuffles the queue after each song.
2842
- * @param repeat "true" or "false".
2843
- * @param ms After how many milliseconds to trigger dynamic repeat.
2844
- * @returns {this} - The player instance.
2845
- * @throws {TypeError} If the repeat parameter is not a boolean.
2846
- * @throws {RangeError} If the queue size is less than or equal to 1.
2865
+ * Saves player states.
2866
+ * @param {string} guildId - The guild ID of the player to save
2847
2867
  */
2848
- setDynamicRepeat(repeat: boolean, ms: number): Promise<this>;
2868
+ savePlayerState(guildId: string): Promise<void>;
2849
2869
  /**
2850
- * Restarts the currently playing track from the beginning.
2851
- * If there is no track playing, it will play the next track in the queue.
2852
- * @returns {Promise<Player>} The current instance of the Player class for method chaining.
2870
+ * Sleeps for a specified amount of time.
2871
+ * @param ms The amount of time to sleep in milliseconds.
2872
+ * @returns A promise that resolves after the specified amount of time.
2853
2873
  */
2854
- restart(): Promise<Player>;
2874
+ private sleep;
2855
2875
  /**
2856
- * Stops the player and optionally removes tracks from the queue.
2857
- * @param {number} [amount] The amount of tracks to remove from the queue. If not provided, removes the current track if it exists.
2858
- * @returns {Promise<this>} - The player instance.
2859
- * @throws {RangeError} If the amount is greater than the queue length.
2876
+ * Loads player states from the JSON file.
2877
+ * @param nodeId The ID of the node to load player states from.
2878
+ * @returns A promise that resolves when the player states have been loaded.
2860
2879
  */
2861
- stop(amount?: number): Promise<this>;
2880
+ loadPlayerStates(nodeId: string): Promise<void>;
2862
2881
  /**
2863
- * Skips the current track.
2864
- * @returns {this} - The player instance.
2865
- * @throws {Error} If there are no tracks in the queue.
2866
- * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
2882
+ * Returns the node to use based on the configured `useNode` and `enablePriorityMode` options.
2883
+ * If `enablePriorityMode` is true, the node is chosen based on priority, otherwise it is chosen based on the `useNode` option.
2884
+ * If `useNode` is "leastLoad", the node with the lowest load is chosen, if it is "leastPlayers", the node with the fewest players is chosen.
2885
+ * If `enablePriorityMode` is false and `useNode` is not set, the node with the lowest load is chosen.
2886
+ * @returns {Node} The node to use.
2867
2887
  */
2868
- pause(pause: boolean): Promise<this>;
2888
+ get useableNode(): Node;
2869
2889
  /**
2870
- * Skips to the previous track in the queue.
2871
- * @returns {this} - The player instance.
2872
- * @throws {Error} If there are no previous tracks in the queue.
2873
- * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
2890
+ * Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.
2891
+ * This function is called when the process is about to exit.
2892
+ * It iterates through all players and calls {@link savePlayerState} to save their states.
2893
+ * Optionally, it also calls {@link cleanupInactivePlayers} to remove any stale player state files.
2894
+ * After saving and cleaning up, it exits the process.
2874
2895
  */
2875
- previous(): Promise<this>;
2896
+ handleShutdown(): Promise<void>;
2876
2897
  /**
2877
- * Seeks to a given position in the currently playing track.
2878
- * @param position - The position in milliseconds to seek to.
2879
- * @returns {this} - The player instance.
2880
- * @throws {Error} If the position is invalid.
2881
- * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
2898
+ * Parses a YouTube title into a clean title and author.
2899
+ * @param title - The original title of the YouTube video.
2900
+ * @param originalAuthor - The original author of the YouTube video.
2901
+ * @returns An object with the clean title and author.
2882
2902
  */
2883
- seek(position: number): Promise<this>;
2903
+ private parseYouTubeTitle;
2884
2904
  /**
2885
- * Returns the current repeat state of the player.
2886
- * @param player The player to get the repeat state from.
2887
- * @returns The repeat state of the player, or null if it is not repeating.
2905
+ * Balances brackets in a given string by ensuring all opened brackets are closed correctly.
2906
+ * @param str - The input string that may contain unbalanced brackets.
2907
+ * @returns A new string with balanced brackets.
2888
2908
  */
2889
- private getRepeatState;
2909
+ private balanceBrackets;
2890
2910
  /**
2891
- * Automatically moves the player to a usable node.
2892
- * @returns {Promise<Player | void>} - The player instance or void if not moved.
2911
+ * Escapes a string by replacing special regex characters with their escaped counterparts.
2912
+ * @param string - The string to escape.
2913
+ * @returns The escaped string.
2893
2914
  */
2894
- autoMoveNode(): Promise<Player | void>;
2915
+ private escapeRegExp;
2895
2916
  /**
2896
- * Moves the player to another node.
2897
- * @param {string} identifier - The identifier of the node to move to.
2898
- * @returns {Promise<Player>} - The player instance after being moved.
2917
+ * Checks if the given data is a voice update.
2918
+ * @param data The data to check.
2919
+ * @returns Whether the data is a voice update.
2899
2920
  */
2900
- moveNode(identifier: string): Promise<Player>;
2921
+ private isVoiceUpdate;
2901
2922
  /**
2902
- * Transfers the player to a new server. If the player already exists on the new server
2903
- * and force is false, this method will return the existing player. Otherwise, a new player
2904
- * will be created and the current player will be destroyed.
2905
- * @param {PlayerOptions} newOptions - The new options for the player.
2906
- * @param {boolean} force - Whether to force the creation of a new player.
2907
- * @returns {Promise<Player>} - The new player instance.
2923
+ * Determines if the provided update is a valid voice update.
2924
+ * A valid update must contain either a token or a session_id.
2925
+ *
2926
+ * @param update - The voice update data to validate, which can be a VoicePacket, VoiceServer, or VoiceState.
2927
+ * @returns {boolean} - True if the update is valid, otherwise false.
2908
2928
  */
2909
- switchGuild(newOptions: PlayerOptions, force?: boolean): Promise<Player>;
2929
+ private isValidUpdate;
2910
2930
  /**
2911
- * Retrieves the current lyrics for the playing track.
2912
- * @param skipTrackSource - Indicates whether to skip the track source when fetching lyrics.
2913
- * @returns {Promise<Lyrics>} - The lyrics of the current track.
2914
- * @throws {RangeError} - If the 'lavalyrics-plugin' is not available on the Lavalink node.
2931
+ * Handles a voice server update by updating the player's voice state and sending the voice state to the Lavalink node.
2932
+ * @param player The player for which the voice state is being updated.
2933
+ * @param update The voice server data received from Discord.
2934
+ * @returns A promise that resolves when the voice state update is handled.
2935
+ * @emits {debug} - Emits a debug message indicating the voice state is being updated.
2915
2936
  */
2916
- getCurrentLyrics(skipTrackSource?: boolean): Promise<Lyrics>;
2937
+ private handleVoiceServerUpdate;
2917
2938
  /**
2918
- * Sets up the voice receiver for the player.
2919
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is set up.
2920
- * @throws {Error} - If the node is not a NodeLink.
2939
+ * Handles a voice state update by updating the player's voice channel and session ID if provided, or by disconnecting and destroying the player if the channel ID is null.
2940
+ * @param player The player for which the voice state is being updated.
2941
+ * @param update The voice state data received from Discord.
2942
+ * @emits {playerMove} - Emits a player move event if the channel ID is provided and the player is currently connected to a different voice channel.
2943
+ * @emits {playerDisconnect} - Emits a player disconnect event if the channel ID is null.
2921
2944
  */
2922
- setupVoiceReceiver(): Promise<void>;
2945
+ private handleVoiceStateUpdate;
2923
2946
  /**
2924
- * Removes the voice receiver for the player.
2925
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is removed.
2926
- * @throws {Error} - If the node is not a NodeLink.
2947
+ * Cleans up inactive players by removing their state files from the file system.
2948
+ * This is done to prevent stale state files from accumulating on the file system.
2927
2949
  */
2928
- removeVoiceReceiver(): Promise<void>;
2950
+ cleanupInactivePlayers(): Promise<void>;
2929
2951
  /**
2930
- * Closes the voice receiver for the player.
2931
- * @param {number} code - The code to close the voice receiver with.
2932
- * @param {string} reason - The reason to close the voice receiver with.
2933
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is closed.
2952
+ * Cleans up an inactive player by removing its state data.
2953
+ * This is done to prevent stale state data from accumulating.
2954
+ * @param guildId The guild ID of the player to clean up.
2934
2955
  */
2935
- private closeVoiceReceiver;
2956
+ cleanupInactivePlayer(guildId: string): Promise<void>;
2936
2957
  /**
2937
- * Reconnects the voice receiver for the player.
2938
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is reconnected.
2958
+ * Loads the enabled plugins.
2939
2959
  */
2940
- private reconnectVoiceReceiver;
2960
+ private loadPlugins;
2941
2961
  /**
2942
- * Disconnects the voice receiver for the player.
2943
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is disconnected.
2962
+ * Unloads the enabled plugins.
2944
2963
  */
2945
- private disconnectVoiceReceiver;
2964
+ private unloadPlugins;
2946
2965
  /**
2947
- * Opens the voice receiver for the player.
2948
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is opened.
2966
+ * Clears all player states from the file system.
2967
+ * This is done to prevent stale state files from accumulating on the file system.
2949
2968
  */
2950
- private openVoiceReceiver;
2969
+ private clearAllStoredPlayers;
2951
2970
  /**
2952
- * Handles a voice receiver message.
2953
- * @param {string} payload - The payload to handle.
2954
- * @returns {Promise<void>} - A promise that resolves when the voice receiver message is handled.
2971
+ * Returns the nodes that has the least load.
2972
+ * The load is calculated by dividing the lavalink load by the number of cores.
2973
+ * The result is multiplied by 100 to get a percentage.
2974
+ * @returns {Collection<string, Node>}
2955
2975
  */
2956
- private onVoiceReceiverMessage;
2976
+ private get leastLoadNode();
2957
2977
  /**
2958
- * Handles a voice receiver error.
2959
- * @param {Error} error - The error to handle.
2960
- * @returns {Promise<void>} - A promise that resolves when the voice receiver error is handled.
2978
+ * Returns the nodes that have the least amount of players.
2979
+ * Filters out disconnected nodes and sorts the remaining nodes
2980
+ * by the number of players in ascending order.
2981
+ * @returns {Collection<string, Node>} A collection of nodes sorted by player count.
2961
2982
  */
2962
- private onVoiceReceiverError;
2983
+ private get leastPlayersNode();
2984
+ /**
2985
+ * Returns a node based on priority.
2986
+ * The nodes are sorted by priority in descending order, and then a random number
2987
+ * between 0 and 1 is generated. The node that has a cumulative weight greater than or equal to the
2988
+ * random number is returned.
2989
+ * If no node has a cumulative weight greater than or equal to the random number, the node with the
2990
+ * lowest load is returned.
2991
+ * @returns {Node} The node to use.
2992
+ */
2993
+ private get priorityNode();
2994
+ protected send(packet: GatewayVoiceStateUpdate): unknown;
2995
+ sendPacket(packet: GatewayVoiceStateUpdate): unknown;
2963
2996
  }
2964
2997
 
2965
2998
  declare class Filters {
2966
2999
  distortion: DistortionOptions | null;
2967
3000
  equalizer: Band[];
2968
3001
  karaoke: KaraokeOptions | null;
3002
+ manager: Manager;
2969
3003
  player: Player;
2970
3004
  rotation: RotationOptions | null;
2971
3005
  timescale: TimescaleOptions | null;
@@ -2974,7 +3008,7 @@ declare class Filters {
2974
3008
  volume: number;
2975
3009
  bassBoostlevel: number;
2976
3010
  filtersStatus: Record<AvailableFilters, boolean>;
2977
- constructor(player: Player);
3011
+ constructor(player: Player, manager: Manager);
2978
3012
  /**
2979
3013
  * Updates the player's audio filters.
2980
3014
  *
@@ -2999,6 +3033,7 @@ declare class Filters {
2999
3033
  * @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
3000
3034
  */
3001
3035
  private applyFilter;
3036
+ private emitPlayersTasteUpdate;
3002
3037
  /**
3003
3038
  * Sets the status of a specific filter.
3004
3039
  *