lavalink-client 2.2.2 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +95 -1
  2. package/dist/cjs/index.d.ts +8 -1
  3. package/dist/cjs/index.js +8 -1
  4. package/dist/cjs/structures/Constants.d.ts +40 -0
  5. package/dist/cjs/structures/Constants.js +244 -0
  6. package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  7. package/dist/cjs/structures/Filters.d.ts +2 -217
  8. package/dist/cjs/structures/Filters.js +8 -232
  9. package/dist/cjs/structures/LavalinkManager.d.ts +31 -166
  10. package/dist/cjs/structures/LavalinkManager.js +59 -7
  11. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
  12. package/dist/cjs/structures/Node.d.ts +15 -156
  13. package/dist/cjs/structures/Node.js +131 -49
  14. package/dist/cjs/structures/NodeManager.d.ts +54 -52
  15. package/dist/cjs/structures/NodeManager.js +74 -4
  16. package/dist/cjs/structures/Player.d.ts +31 -124
  17. package/dist/cjs/structures/Player.js +77 -43
  18. package/dist/cjs/structures/Queue.d.ts +66 -42
  19. package/dist/cjs/structures/Queue.js +69 -11
  20. package/dist/cjs/structures/Types/Filters.d.ts +190 -0
  21. package/dist/cjs/structures/Types/Manager.d.ts +184 -0
  22. package/dist/cjs/structures/Types/Manager.js +2 -0
  23. package/dist/cjs/structures/Types/Node.d.ts +216 -0
  24. package/dist/cjs/structures/Types/Node.js +2 -0
  25. package/dist/cjs/structures/Types/Player.d.ts +108 -0
  26. package/dist/cjs/structures/Types/Player.js +2 -0
  27. package/dist/cjs/structures/Types/Queue.d.ts +34 -0
  28. package/dist/cjs/structures/Types/Queue.js +2 -0
  29. package/dist/cjs/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  30. package/dist/{structures → cjs/structures/Types}/Track.js +2 -2
  31. package/dist/cjs/structures/Types/Utils.d.ts +367 -0
  32. package/dist/cjs/structures/Types/Utils.js +2 -0
  33. package/dist/cjs/structures/Utils.d.ts +13 -369
  34. package/dist/cjs/structures/Utils.js +35 -14
  35. package/dist/esm/index.d.ts +8 -1
  36. package/dist/esm/index.js +8 -1
  37. package/dist/esm/structures/Constants.d.ts +40 -0
  38. package/dist/esm/structures/Constants.js +241 -0
  39. package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  40. package/dist/esm/structures/Filters.d.ts +2 -217
  41. package/dist/esm/structures/Filters.js +3 -227
  42. package/dist/esm/structures/LavalinkManager.d.ts +31 -166
  43. package/dist/esm/structures/LavalinkManager.js +57 -5
  44. package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
  45. package/dist/esm/structures/Node.d.ts +15 -156
  46. package/dist/esm/structures/Node.js +122 -40
  47. package/dist/esm/structures/NodeManager.d.ts +54 -52
  48. package/dist/esm/structures/NodeManager.js +71 -1
  49. package/dist/esm/structures/Player.d.ts +31 -124
  50. package/dist/esm/structures/Player.js +76 -42
  51. package/dist/esm/structures/Queue.d.ts +66 -42
  52. package/dist/esm/structures/Queue.js +69 -11
  53. package/dist/esm/structures/Types/Filters.d.ts +190 -0
  54. package/dist/esm/structures/Types/Manager.d.ts +184 -0
  55. package/dist/esm/structures/Types/Manager.js +1 -0
  56. package/dist/esm/structures/Types/Node.d.ts +216 -0
  57. package/dist/esm/structures/Types/Node.js +1 -0
  58. package/dist/esm/structures/Types/Player.d.ts +108 -0
  59. package/dist/esm/structures/Types/Player.js +1 -0
  60. package/dist/esm/structures/Types/Queue.d.ts +34 -0
  61. package/dist/esm/structures/Types/Queue.js +1 -0
  62. package/dist/esm/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  63. package/dist/esm/structures/Types/Track.js +1 -0
  64. package/dist/esm/structures/Types/Utils.d.ts +367 -0
  65. package/dist/esm/structures/Types/Utils.js +1 -0
  66. package/dist/esm/structures/Utils.d.ts +13 -369
  67. package/dist/esm/structures/Utils.js +35 -14
  68. package/dist/types/index.d.ts +8 -1
  69. package/dist/types/structures/Constants.d.ts +40 -0
  70. package/dist/types/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  71. package/dist/types/structures/Filters.d.ts +2 -217
  72. package/dist/types/structures/LavalinkManager.d.ts +31 -166
  73. package/dist/types/structures/LavalinkManagerStatics.d.ts +1 -1
  74. package/dist/types/structures/Node.d.ts +15 -156
  75. package/dist/types/structures/NodeManager.d.ts +54 -52
  76. package/dist/types/structures/Player.d.ts +31 -124
  77. package/dist/types/structures/Queue.d.ts +66 -42
  78. package/dist/types/structures/Types/Filters.d.ts +190 -0
  79. package/dist/types/structures/Types/Manager.d.ts +184 -0
  80. package/dist/types/structures/Types/Node.d.ts +216 -0
  81. package/dist/types/structures/Types/Player.d.ts +108 -0
  82. package/dist/types/structures/Types/Queue.d.ts +34 -0
  83. package/dist/types/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  84. package/dist/types/structures/Types/Utils.d.ts +367 -0
  85. package/dist/types/structures/Utils.d.ts +13 -369
  86. package/package.json +1 -1
  87. package/dist/index.d.ts +0 -10
  88. package/dist/index.js +0 -13
  89. package/dist/structures/Filters.d.ts +0 -230
  90. package/dist/structures/Filters.js +0 -472
  91. package/dist/structures/LavalinkManager.d.ts +0 -47
  92. package/dist/structures/LavalinkManager.js +0 -36
  93. package/dist/structures/LavalinkManagerStatics.d.ts +0 -3
  94. package/dist/structures/LavalinkManagerStatics.js +0 -76
  95. package/dist/structures/Node.d.ts +0 -171
  96. package/dist/structures/Node.js +0 -462
  97. package/dist/structures/NodeManager.d.ts +0 -58
  98. package/dist/structures/NodeManager.js +0 -25
  99. package/dist/structures/Player.d.ts +0 -101
  100. package/dist/structures/Player.js +0 -232
  101. package/dist/structures/PlayerManager.d.ts +0 -62
  102. package/dist/structures/PlayerManager.js +0 -26
  103. package/dist/structures/Queue.d.ts +0 -93
  104. package/dist/structures/Queue.js +0 -160
  105. package/dist/structures/QueueManager.d.ts +0 -77
  106. package/dist/structures/QueueManager.js +0 -74
  107. package/dist/structures/Track.d.ts +0 -27
  108. package/dist/structures/Utils.d.ts +0 -183
  109. package/dist/structures/Utils.js +0 -43
  110. /package/dist/cjs/structures/{Track.js → Types/Filters.js} +0 -0
  111. /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
@@ -1,3 +1,4 @@
1
+ import { audioOutputsData } from "./Constants";
1
2
  /**
2
3
  * The FilterManager for each player
3
4
  */
@@ -380,7 +381,8 @@ export class FilterManager {
380
381
  throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
381
382
  this.data.rotation.rotationHz = this.filters.rotation ? 0 : rotationHz;
382
383
  this.filters.rotation = !this.filters.rotation;
383
- return await this.applyPlayerFilters(), this.filters.rotation;
384
+ await this.applyPlayerFilters();
385
+ return this.filters.rotation;
384
386
  }
385
387
  /**
386
388
  * Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
@@ -667,229 +669,3 @@ export class FilterManager {
667
669
  return this.setEQ(new Array(15).fill(0.0).map((gain, band) => ({ band, gain })));
668
670
  }
669
671
  }
670
- /** The audio Outputs Data map declaration */
671
- export const audioOutputsData = {
672
- mono: {
673
- leftToLeft: 0.5,
674
- leftToRight: 0.5,
675
- rightToLeft: 0.5,
676
- rightToRight: 0.5,
677
- },
678
- stereo: {
679
- leftToLeft: 1,
680
- leftToRight: 0,
681
- rightToLeft: 0,
682
- rightToRight: 1,
683
- },
684
- left: {
685
- leftToLeft: 1,
686
- leftToRight: 0,
687
- rightToLeft: 1,
688
- rightToRight: 0,
689
- },
690
- right: {
691
- leftToLeft: 0,
692
- leftToRight: 1,
693
- rightToLeft: 0,
694
- rightToRight: 1,
695
- },
696
- };
697
- export const EQList = {
698
- /** A Bassboost Equalizer, so high it distorts the audio */
699
- BassboostEarrape: [
700
- { band: 0, gain: 0.6 * 0.375 },
701
- { band: 1, gain: 0.67 * 0.375 },
702
- { band: 2, gain: 0.67 * 0.375 },
703
- { band: 3, gain: 0.4 * 0.375 },
704
- { band: 4, gain: -0.5 * 0.375 },
705
- { band: 5, gain: 0.15 * 0.375 },
706
- { band: 6, gain: -0.45 * 0.375 },
707
- { band: 7, gain: 0.23 * 0.375 },
708
- { band: 8, gain: 0.35 * 0.375 },
709
- { band: 9, gain: 0.45 * 0.375 },
710
- { band: 10, gain: 0.55 * 0.375 },
711
- { band: 11, gain: -0.6 * 0.375 },
712
- { band: 12, gain: 0.55 * 0.375 },
713
- { band: 13, gain: -0.5 * 0.375 },
714
- { band: 14, gain: -0.75 * 0.375 },
715
- ],
716
- /** A High and decent Bassboost Equalizer */
717
- BassboostHigh: [
718
- { band: 0, gain: 0.6 * 0.25 },
719
- { band: 1, gain: 0.67 * 0.25 },
720
- { band: 2, gain: 0.67 * 0.25 },
721
- { band: 3, gain: 0.4 * 0.25 },
722
- { band: 4, gain: -0.5 * 0.25 },
723
- { band: 5, gain: 0.15 * 0.25 },
724
- { band: 6, gain: -0.45 * 0.25 },
725
- { band: 7, gain: 0.23 * 0.25 },
726
- { band: 8, gain: 0.35 * 0.25 },
727
- { band: 9, gain: 0.45 * 0.25 },
728
- { band: 10, gain: 0.55 * 0.25 },
729
- { band: 11, gain: -0.6 * 0.25 },
730
- { band: 12, gain: 0.55 * 0.25 },
731
- { band: 13, gain: -0.5 * 0.25 },
732
- { band: 14, gain: -0.75 * 0.25 },
733
- ],
734
- /** A decent Bassboost Equalizer */
735
- BassboostMedium: [
736
- { band: 0, gain: 0.6 * 0.1875 },
737
- { band: 1, gain: 0.67 * 0.1875 },
738
- { band: 2, gain: 0.67 * 0.1875 },
739
- { band: 3, gain: 0.4 * 0.1875 },
740
- { band: 4, gain: -0.5 * 0.1875 },
741
- { band: 5, gain: 0.15 * 0.1875 },
742
- { band: 6, gain: -0.45 * 0.1875 },
743
- { band: 7, gain: 0.23 * 0.1875 },
744
- { band: 8, gain: 0.35 * 0.1875 },
745
- { band: 9, gain: 0.45 * 0.1875 },
746
- { band: 10, gain: 0.55 * 0.1875 },
747
- { band: 11, gain: -0.6 * 0.1875 },
748
- { band: 12, gain: 0.55 * 0.1875 },
749
- { band: 13, gain: -0.5 * 0.1875 },
750
- { band: 14, gain: -0.75 * 0.1875 },
751
- ],
752
- /** A slight Bassboost Equalizer */
753
- BassboostLow: [
754
- { band: 0, gain: 0.6 * 0.125 },
755
- { band: 1, gain: 0.67 * 0.125 },
756
- { band: 2, gain: 0.67 * 0.125 },
757
- { band: 3, gain: 0.4 * 0.125 },
758
- { band: 4, gain: -0.5 * 0.125 },
759
- { band: 5, gain: 0.15 * 0.125 },
760
- { band: 6, gain: -0.45 * 0.125 },
761
- { band: 7, gain: 0.23 * 0.125 },
762
- { band: 8, gain: 0.35 * 0.125 },
763
- { band: 9, gain: 0.45 * 0.125 },
764
- { band: 10, gain: 0.55 * 0.125 },
765
- { band: 11, gain: -0.6 * 0.125 },
766
- { band: 12, gain: 0.55 * 0.125 },
767
- { band: 13, gain: -0.5 * 0.125 },
768
- { band: 14, gain: -0.75 * 0.125 },
769
- ],
770
- /** Makes the Music slightly "better" */
771
- BetterMusic: [
772
- { band: 0, gain: 0.25 },
773
- { band: 1, gain: 0.025 },
774
- { band: 2, gain: 0.0125 },
775
- { band: 3, gain: 0 },
776
- { band: 4, gain: 0 },
777
- { band: 5, gain: -0.0125 },
778
- { band: 6, gain: -0.025 },
779
- { band: 7, gain: -0.0175 },
780
- { band: 8, gain: 0 },
781
- { band: 9, gain: 0 },
782
- { band: 10, gain: 0.0125 },
783
- { band: 11, gain: 0.025 },
784
- { band: 12, gain: 0.25 },
785
- { band: 13, gain: 0.125 },
786
- { band: 14, gain: 0.125 },
787
- ],
788
- /** Makes the Music sound like rock music / sound rock music better */
789
- Rock: [
790
- { band: 0, gain: 0.300 },
791
- { band: 1, gain: 0.250 },
792
- { band: 2, gain: 0.200 },
793
- { band: 3, gain: 0.100 },
794
- { band: 4, gain: 0.050 },
795
- { band: 5, gain: -0.050 },
796
- { band: 6, gain: -0.150 },
797
- { band: 7, gain: -0.200 },
798
- { band: 8, gain: -0.100 },
799
- { band: 9, gain: -0.050 },
800
- { band: 10, gain: 0.050 },
801
- { band: 11, gain: 0.100 },
802
- { band: 12, gain: 0.200 },
803
- { band: 13, gain: 0.250 },
804
- { band: 14, gain: 0.300 },
805
- ],
806
- /** Makes the Music sound like Classic music / sound Classic music better */
807
- Classic: [
808
- { band: 0, gain: 0.375 },
809
- { band: 1, gain: 0.350 },
810
- { band: 2, gain: 0.125 },
811
- { band: 3, gain: 0 },
812
- { band: 4, gain: 0 },
813
- { band: 5, gain: 0.125 },
814
- { band: 6, gain: 0.550 },
815
- { band: 7, gain: 0.050 },
816
- { band: 8, gain: 0.125 },
817
- { band: 9, gain: 0.250 },
818
- { band: 10, gain: 0.200 },
819
- { band: 11, gain: 0.250 },
820
- { band: 12, gain: 0.300 },
821
- { band: 13, gain: 0.250 },
822
- { band: 14, gain: 0.300 },
823
- ],
824
- /** Makes the Music sound like Pop music / sound Pop music better */
825
- Pop: [
826
- { band: 0, gain: 0.2635 },
827
- { band: 1, gain: 0.22141 },
828
- { band: 2, gain: -0.21141 },
829
- { band: 3, gain: -0.1851 },
830
- { band: 4, gain: -0.155 },
831
- { band: 5, gain: 0.21141 },
832
- { band: 6, gain: 0.22456 },
833
- { band: 7, gain: 0.237 },
834
- { band: 8, gain: 0.237 },
835
- { band: 9, gain: 0.237 },
836
- { band: 10, gain: -0.05 },
837
- { band: 11, gain: -0.116 },
838
- { band: 12, gain: 0.192 },
839
- { band: 13, gain: 0 },
840
- ],
841
- /** Makes the Music sound like Electronic music / sound Electronic music better */
842
- Electronic: [
843
- { band: 0, gain: 0.375 },
844
- { band: 1, gain: 0.350 },
845
- { band: 2, gain: 0.125 },
846
- { band: 3, gain: 0 },
847
- { band: 4, gain: 0 },
848
- { band: 5, gain: -0.125 },
849
- { band: 6, gain: -0.125 },
850
- { band: 7, gain: 0 },
851
- { band: 8, gain: 0.25 },
852
- { band: 9, gain: 0.125 },
853
- { band: 10, gain: 0.15 },
854
- { band: 11, gain: 0.2 },
855
- { band: 12, gain: 0.250 },
856
- { band: 13, gain: 0.350 },
857
- { band: 14, gain: 0.400 },
858
- ],
859
- /** Boosts all Bands slightly for louder and fuller sound */
860
- FullSound: [
861
- { band: 0, gain: 0.25 + 0.375 },
862
- { band: 1, gain: 0.25 + 0.025 },
863
- { band: 2, gain: 0.25 + 0.0125 },
864
- { band: 3, gain: 0.25 + 0 },
865
- { band: 4, gain: 0.25 + 0 },
866
- { band: 5, gain: 0.25 + -0.0125 },
867
- { band: 6, gain: 0.25 + -0.025 },
868
- { band: 7, gain: 0.25 + -0.0175 },
869
- { band: 8, gain: 0.25 + 0 },
870
- { band: 9, gain: 0.25 + 0 },
871
- { band: 10, gain: 0.25 + 0.0125 },
872
- { band: 11, gain: 0.25 + 0.025 },
873
- { band: 12, gain: 0.25 + 0.375 },
874
- { band: 13, gain: 0.25 + 0.125 },
875
- { band: 14, gain: 0.25 + 0.125 },
876
- ],
877
- /** Boosts basses + lower highs for a pro gaming sound */
878
- Gaming: [
879
- { band: 0, gain: 0.350 },
880
- { band: 1, gain: 0.300 },
881
- { band: 2, gain: 0.250 },
882
- { band: 3, gain: 0.200 },
883
- { band: 4, gain: 0.150 },
884
- { band: 5, gain: 0.100 },
885
- { band: 6, gain: 0.050 },
886
- { band: 7, gain: -0.0 },
887
- { band: 8, gain: -0.050 },
888
- { band: 9, gain: -0.100 },
889
- { band: 10, gain: -0.150 },
890
- { band: 11, gain: -0.200 },
891
- { band: 12, gain: -0.250 },
892
- { band: 13, gain: -0.300 },
893
- { band: 14, gain: -0.350 },
894
- ],
895
- };
@@ -1,182 +1,47 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from "events";
3
- import { LavalinkNodeOptions } from "./Node";
4
3
  import { NodeManager } from "./NodeManager";
5
- import { DestroyReasonsType, Player, PlayerJson, PlayerOptions } from "./Player";
6
- import { ManagerQueueOptions } from "./Queue";
7
- import { Track, UnresolvedTrack } from "./Track";
8
- import { ChannelDeletePacket, GuildShardPayload, ManagerUtils, MiniMap, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent } from "./Utils";
9
- /** How the botclient is allowed to be structured */
10
- export interface BotClientOptions {
11
- /** Bot Client Id */
12
- id: string;
13
- /** Bot Client Username */
14
- username?: string;
15
- /** So users can pass entire objects / classes */
16
- [x: string | number | symbol]: unknown;
17
- }
18
- /** Sub Manager Options, for player specific things */
19
- export interface ManagerPlayerOptions {
20
- /** If the Lavalink Volume should be decremented by x number */
21
- volumeDecrementer?: number;
22
- /** How often it should update the the player Position */
23
- clientBasedPositionUpdateInterval?: number;
24
- /** What should be used as a searchPlatform, if no source was provided during the query */
25
- defaultSearchPlatform?: SearchPlatform;
26
- /** Applies the volume via a filter, not via the lavalink volume transformer */
27
- applyVolumeAsFilter?: boolean;
28
- /** Transforms the saved data of a requested user */
29
- requesterTransformer?: (requester: unknown) => unknown;
30
- /** What lavalink-client should do when the player reconnects */
31
- onDisconnect?: {
32
- /** Try to reconnect? -> If fails -> Destroy */
33
- autoReconnect?: boolean;
34
- /** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
35
- destroyPlayer?: boolean;
36
- };
37
- onEmptyQueue?: {
38
- /** Get's executed onEmptyQueue -> You can do any track queue previous transformations, if you add a track to the queue -> it will play it, if not queueEnd will execute! */
39
- autoPlayFunction?: (player: Player, lastPlayedTrack: Track) => Promise<void>;
40
- destroyAfterMs?: number;
41
- };
42
- useUnresolvedData?: boolean;
43
- }
44
- /** Manager Options used to create the manager */
45
- export interface ManagerOptions {
46
- /** The Node Options, for all Nodes! (on init) */
47
- nodes: LavalinkNodeOptions[];
48
- /** @async The Function to send the voice connection changes from Lavalink to Discord */
49
- sendToShard: (guildId: string, payload: GuildShardPayload) => void;
50
- /** The Bot Client's Data for Authorization */
51
- client?: BotClientOptions;
52
- /** QueueOptions for all Queues */
53
- queueOptions?: ManagerQueueOptions;
54
- /** PlayerOptions for all Players */
55
- playerOptions?: ManagerPlayerOptions;
56
- /** If it should skip to the next Track on TrackEnd / TrackError etc. events */
57
- autoSkip?: boolean;
58
- /** If it should skip to the next Track if track.resolve errors while trying to play a track. */
59
- autoSkipOnResolveError?: boolean;
60
- /** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
61
- emitNewSongsOnly?: boolean;
62
- /** Only allow link requests with links either matching some of that regExp or including some of that string */
63
- linksWhitelist?: (RegExp | string)[];
64
- /** Never allow link requests with links either matching some of that regExp or including some of that string (doesn't even allow if it's whitelisted) */
65
- linksBlacklist?: (RegExp | string)[];
66
- /** If links should be allowed or not. If set to false, it will throw an error if a link was provided. */
67
- linksAllowed?: boolean;
68
- /** Advanced Options for the Library, which may or may not be "library breaking" */
69
- advancedOptions?: {
70
- /** Max duration for that the filter fix duration works (in ms) - default is 8mins */
71
- maxFilterFixDuration?: number;
72
- /** optional */
73
- debugOptions?: {
74
- /** For logging custom searches */
75
- logCustomSearches?: boolean;
76
- /** logs for debugging the "no-Audio" playing error */
77
- noAudio?: boolean;
78
- /** For Logging the Destroy function */
79
- playerDestroy?: {
80
- /** To show the debug reason at all times. */
81
- debugLog?: boolean;
82
- /** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
83
- dontThrowError?: boolean;
84
- };
85
- };
86
- };
87
- }
88
- export interface LavalinkManagerEvents {
89
- /**
90
- * Emitted when a Track started playing.
91
- * @event Manager#trackStart
92
- */
93
- "trackStart": (player: Player, track: Track, payload: TrackStartEvent) => void;
94
- /**
95
- * Emitted when a Track finished.
96
- * @event Manager#trackEnd
97
- */
98
- "trackEnd": (player: Player, track: Track | null, payload: TrackEndEvent) => void;
99
- /**
100
- * Emitted when a Track got stuck while playing.
101
- * @event Manager#trackStuck
102
- */
103
- "trackStuck": (player: Player, track: Track | null, payload: TrackStuckEvent) => void;
104
- /**
105
- * Emitted when a Track errored.
106
- * @event Manager#trackError
107
- */
108
- "trackError": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackExceptionEvent) => void;
109
- /**
110
- * Emitted when the Playing finished and no more tracks in the queue.
111
- * @event Manager#queueEnd
112
- */
113
- "queueEnd": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
114
- /**
115
- * Emitted when a Player is created.
116
- * @event Manager#playerCreate
117
- */
118
- "playerCreate": (player: Player) => void;
119
- /**
120
- * Emitted when a Player is moved within the channel.
121
- * @event Manager#playerMove
122
- */
123
- "playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
124
- /**
125
- * Emitted when a Player is disconnected from a channel.
126
- * @event Manager#playerDisconnect
127
- */
128
- "playerDisconnect": (player: Player, voiceChannelId: string) => void;
129
- /**
130
- * Emitted when a Node-Socket got closed for a specific Player.
131
- * @event Manager#playerSocketClosed
132
- */
133
- "playerSocketClosed": (player: Player, payload: WebSocketClosedEvent) => void;
134
- /**
135
- * Emitted when a Player get's destroyed
136
- * @event Manager#playerDestroy
137
- */
138
- "playerDestroy": (player: Player, destroyReason?: DestroyReasonsType) => void;
4
+ import { Player } from "./Player";
5
+ import { ManagerUtils, MiniMap } from "./Utils";
6
+ import type { BotClientOptions, LavalinkManagerEvents, ManagerOptions } from "./Types/Manager";
7
+ import type { PlayerOptions } from "./Types/Player";
8
+ import type { ChannelDeletePacket, VoicePacket, VoiceServer, VoiceState } from "./Types/Utils";
9
+ export declare class LavalinkManager extends EventEmitter {
139
10
  /**
140
- * Always emits when the player (on lavalink side) got updated
141
- * @event Manager#playerUpdate
11
+ * Emit an event
12
+ * @param event The event to emit
13
+ * @param args The arguments to pass to the event
14
+ * @returns
142
15
  */
143
- "playerUpdate": (oldPlayerJson: PlayerJson, newPlayer: Player) => void;
16
+ emit<Event extends keyof LavalinkManagerEvents>(event: Event, ...args: Parameters<LavalinkManagerEvents[Event]>): boolean;
144
17
  /**
145
- * SPONSORBLOCK-PLUGIN EVENT
146
- * Emitted when Segments are loaded
147
- * @link https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
148
- * @event Manager#trackError
18
+ * Add an event listener
19
+ * @param event The event to listen to
20
+ * @param listener The listener to add
21
+ * @returns
149
22
  */
150
- "SegmentsLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentsLoaded) => void;
23
+ on<Event extends keyof LavalinkManagerEvents>(event: Event, listener: LavalinkManagerEvents[Event]): this;
151
24
  /**
152
- * SPONSORBLOCK-PLUGIN EVENT
153
- * Emitted when a specific Segment was skipped
154
- * @link https://github.com/topi314/Sponsorblock-Plugin#segmentskipped
155
- * @event Manager#trackError
25
+ * Add an event listener that only fires once
26
+ * @param event The event to listen to
27
+ * @param listener The listener to add
28
+ * @returns
156
29
  */
157
- "SegmentSkipped": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentSkipped) => void;
30
+ once<Event extends keyof LavalinkManagerEvents>(event: Event, listener: LavalinkManagerEvents[Event]): this;
158
31
  /**
159
- * SPONSORBLOCK-PLUGIN EVENT
160
- * Emitted when a specific Chapter starts playing
161
- * @link https://github.com/topi314/Sponsorblock-Plugin#chapterstarted
162
- * @event Manager#trackError
32
+ * Remove an event listener
33
+ * @param event The event to remove the listener from
34
+ * @param listener The listener to remove
35
+ * @returns
163
36
  */
164
- "ChapterStarted": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChapterStarted) => void;
37
+ off<Event extends keyof LavalinkManagerEvents>(event: Event, listener: LavalinkManagerEvents[Event]): this;
165
38
  /**
166
- * SPONSORBLOCK-PLUGIN EVENT
167
- * Emitted when Chapters are loaded
168
- * @link https://github.com/topi314/Sponsorblock-Plugin#chaptersloaded
169
- * @event Manager#trackError
39
+ * Remove an event listener
40
+ * @param event The event to remove the listener from
41
+ * @param listener The listener to remove
42
+ * @returns
170
43
  */
171
- "ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
172
- }
173
- export interface LavalinkManager {
174
- /** @private */
175
- on<U extends keyof LavalinkManagerEvents>(event: U, listener: LavalinkManagerEvents[U]): this;
176
- /** @private */
177
- emit<U extends keyof LavalinkManagerEvents>(event: U, ...args: Parameters<LavalinkManagerEvents[U]>): boolean;
178
- }
179
- export declare class LavalinkManager extends EventEmitter {
44
+ removeListener<Event extends keyof LavalinkManagerEvents>(event: Event, listener: LavalinkManagerEvents[Event]): this;
180
45
  /** The Options of LavalinkManager (changeable) */
181
46
  options: ManagerOptions;
182
47
  /** LavalinkManager's NodeManager to manage all Nodes */
@@ -1,9 +1,55 @@
1
1
  import { EventEmitter } from "events";
2
+ import { DestroyReasons } from "./Constants";
2
3
  import { NodeManager } from "./NodeManager";
3
- import { DestroyReasons, Player } from "./Player";
4
+ import { Player } from "./Player";
4
5
  import { DefaultQueueStore } from "./Queue";
5
6
  import { ManagerUtils, MiniMap } from "./Utils";
6
7
  export class LavalinkManager extends EventEmitter {
8
+ /**
9
+ * Emit an event
10
+ * @param event The event to emit
11
+ * @param args The arguments to pass to the event
12
+ * @returns
13
+ */
14
+ emit(event, ...args) {
15
+ return super.emit(event, ...args);
16
+ }
17
+ /**
18
+ * Add an event listener
19
+ * @param event The event to listen to
20
+ * @param listener The listener to add
21
+ * @returns
22
+ */
23
+ on(event, listener) {
24
+ return super.on(event, listener);
25
+ }
26
+ /**
27
+ * Add an event listener that only fires once
28
+ * @param event The event to listen to
29
+ * @param listener The listener to add
30
+ * @returns
31
+ */
32
+ once(event, listener) {
33
+ return super.once(event, listener);
34
+ }
35
+ /**
36
+ * Remove an event listener
37
+ * @param event The event to remove the listener from
38
+ * @param listener The listener to remove
39
+ * @returns
40
+ */
41
+ off(event, listener) {
42
+ return super.off(event, listener);
43
+ }
44
+ /**
45
+ * Remove an event listener
46
+ * @param event The event to remove the listener from
47
+ * @param listener The listener to remove
48
+ * @returns
49
+ */
50
+ removeListener(event, listener) {
51
+ return super.removeListener(event, listener);
52
+ }
7
53
  /** The Options of LavalinkManager (changeable) */
8
54
  options;
9
55
  /** LavalinkManager's NodeManager to manage all Nodes */
@@ -409,16 +455,22 @@ export class LavalinkManager extends EventEmitter {
409
455
  return void await player.destroy(DestroyReasons.Disconnected);
410
456
  }
411
457
  this.emit("playerDisconnect", player, player.voiceChannelId);
412
- if (!player.paused)
413
- await player.pause();
414
458
  if (this.options?.playerOptions?.onDisconnect?.autoReconnect === true) {
415
459
  try {
460
+ const positionPrevios = player.position;
461
+ console.debug("Auto reconnect", positionPrevios, player.lastPosition);
416
462
  await player.connect();
463
+ // replay the current playing stream
464
+ await player.play({
465
+ position: positionPrevios,
466
+ paused: player.paused,
467
+ clientTrack: player.queue.current,
468
+ });
417
469
  }
418
- catch {
470
+ catch (e) {
471
+ console.error(e);
419
472
  return void await player.destroy(DestroyReasons.PlayerReconnectFail);
420
473
  }
421
- return void player.paused && await player.resume();
422
474
  }
423
475
  player.voiceChannelId = null;
424
476
  player.voice = Object.assign({});
@@ -1,4 +1,4 @@
1
- import { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
1
+ import type { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Types/Utils";
2
2
  /** Default Sources Record, to allow source parsing with multiple inputs. */
3
3
  export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
4
4
  /** Lavalink Plugins definiton */