lavalink-client 2.2.2 → 2.3.0

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 (88) hide show
  1. package/README.md +95 -1
  2. package/dist/cjs/index.d.ts +7 -1
  3. package/dist/cjs/index.js +7 -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/cjs/structures/Types/Track.js +2 -0
  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 +7 -1
  36. package/dist/esm/index.js +7 -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/{types/structures → esm/structures/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 +7 -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/{esm/structures → types/structures/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/cjs/structures/{Track.js → Types/Filters.js} +0 -0
  88. /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EQList = exports.audioOutputsData = exports.FilterManager = void 0;
3
+ exports.FilterManager = void 0;
4
+ const Constants_1 = require("./Constants");
4
5
  /**
5
6
  * The FilterManager for each player
6
7
  */
@@ -87,7 +88,7 @@ class FilterManager {
87
88
  // "decay": 0.4649 // Float, within the range of 0.0 - 1.0. A value of 1.0 means no decay, and a value of 0.0 means
88
89
  },
89
90
  },
90
- channelMix: exports.audioOutputsData.stereo,
91
+ channelMix: Constants_1.audioOutputsData.stereo,
91
92
  /*distortion: {
92
93
  sinOffset: 0,
93
94
  sinScale: 1,
@@ -273,7 +274,7 @@ class FilterManager {
273
274
  frequency: 0,
274
275
  depth: 0 // 0 < x = 1
275
276
  },
276
- channelMix: exports.audioOutputsData.stereo,
277
+ channelMix: Constants_1.audioOutputsData.stereo,
277
278
  })) {
278
279
  this.data[key] = value;
279
280
  }
@@ -300,9 +301,9 @@ class FilterManager {
300
301
  async setAudioOutput(type) {
301
302
  if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix"))
302
303
  throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
303
- if (!type || !exports.audioOutputsData[type])
304
+ if (!type || !Constants_1.audioOutputsData[type])
304
305
  throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
305
- this.data.channelMix = exports.audioOutputsData[type];
306
+ this.data.channelMix = Constants_1.audioOutputsData[type];
306
307
  this.filters.audioOutput = type;
307
308
  await this.applyPlayerFilters();
308
309
  return this.filters.audioOutput;
@@ -383,7 +384,8 @@ class FilterManager {
383
384
  throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
384
385
  this.data.rotation.rotationHz = this.filters.rotation ? 0 : rotationHz;
385
386
  this.filters.rotation = !this.filters.rotation;
386
- return await this.applyPlayerFilters(), this.filters.rotation;
387
+ await this.applyPlayerFilters();
388
+ return this.filters.rotation;
387
389
  }
388
390
  /**
389
391
  * Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
@@ -671,229 +673,3 @@ class FilterManager {
671
673
  }
672
674
  }
673
675
  exports.FilterManager = FilterManager;
674
- /** The audio Outputs Data map declaration */
675
- exports.audioOutputsData = {
676
- mono: {
677
- leftToLeft: 0.5,
678
- leftToRight: 0.5,
679
- rightToLeft: 0.5,
680
- rightToRight: 0.5,
681
- },
682
- stereo: {
683
- leftToLeft: 1,
684
- leftToRight: 0,
685
- rightToLeft: 0,
686
- rightToRight: 1,
687
- },
688
- left: {
689
- leftToLeft: 1,
690
- leftToRight: 0,
691
- rightToLeft: 1,
692
- rightToRight: 0,
693
- },
694
- right: {
695
- leftToLeft: 0,
696
- leftToRight: 1,
697
- rightToLeft: 0,
698
- rightToRight: 1,
699
- },
700
- };
701
- exports.EQList = {
702
- /** A Bassboost Equalizer, so high it distorts the audio */
703
- BassboostEarrape: [
704
- { band: 0, gain: 0.6 * 0.375 },
705
- { band: 1, gain: 0.67 * 0.375 },
706
- { band: 2, gain: 0.67 * 0.375 },
707
- { band: 3, gain: 0.4 * 0.375 },
708
- { band: 4, gain: -0.5 * 0.375 },
709
- { band: 5, gain: 0.15 * 0.375 },
710
- { band: 6, gain: -0.45 * 0.375 },
711
- { band: 7, gain: 0.23 * 0.375 },
712
- { band: 8, gain: 0.35 * 0.375 },
713
- { band: 9, gain: 0.45 * 0.375 },
714
- { band: 10, gain: 0.55 * 0.375 },
715
- { band: 11, gain: -0.6 * 0.375 },
716
- { band: 12, gain: 0.55 * 0.375 },
717
- { band: 13, gain: -0.5 * 0.375 },
718
- { band: 14, gain: -0.75 * 0.375 },
719
- ],
720
- /** A High and decent Bassboost Equalizer */
721
- BassboostHigh: [
722
- { band: 0, gain: 0.6 * 0.25 },
723
- { band: 1, gain: 0.67 * 0.25 },
724
- { band: 2, gain: 0.67 * 0.25 },
725
- { band: 3, gain: 0.4 * 0.25 },
726
- { band: 4, gain: -0.5 * 0.25 },
727
- { band: 5, gain: 0.15 * 0.25 },
728
- { band: 6, gain: -0.45 * 0.25 },
729
- { band: 7, gain: 0.23 * 0.25 },
730
- { band: 8, gain: 0.35 * 0.25 },
731
- { band: 9, gain: 0.45 * 0.25 },
732
- { band: 10, gain: 0.55 * 0.25 },
733
- { band: 11, gain: -0.6 * 0.25 },
734
- { band: 12, gain: 0.55 * 0.25 },
735
- { band: 13, gain: -0.5 * 0.25 },
736
- { band: 14, gain: -0.75 * 0.25 },
737
- ],
738
- /** A decent Bassboost Equalizer */
739
- BassboostMedium: [
740
- { band: 0, gain: 0.6 * 0.1875 },
741
- { band: 1, gain: 0.67 * 0.1875 },
742
- { band: 2, gain: 0.67 * 0.1875 },
743
- { band: 3, gain: 0.4 * 0.1875 },
744
- { band: 4, gain: -0.5 * 0.1875 },
745
- { band: 5, gain: 0.15 * 0.1875 },
746
- { band: 6, gain: -0.45 * 0.1875 },
747
- { band: 7, gain: 0.23 * 0.1875 },
748
- { band: 8, gain: 0.35 * 0.1875 },
749
- { band: 9, gain: 0.45 * 0.1875 },
750
- { band: 10, gain: 0.55 * 0.1875 },
751
- { band: 11, gain: -0.6 * 0.1875 },
752
- { band: 12, gain: 0.55 * 0.1875 },
753
- { band: 13, gain: -0.5 * 0.1875 },
754
- { band: 14, gain: -0.75 * 0.1875 },
755
- ],
756
- /** A slight Bassboost Equalizer */
757
- BassboostLow: [
758
- { band: 0, gain: 0.6 * 0.125 },
759
- { band: 1, gain: 0.67 * 0.125 },
760
- { band: 2, gain: 0.67 * 0.125 },
761
- { band: 3, gain: 0.4 * 0.125 },
762
- { band: 4, gain: -0.5 * 0.125 },
763
- { band: 5, gain: 0.15 * 0.125 },
764
- { band: 6, gain: -0.45 * 0.125 },
765
- { band: 7, gain: 0.23 * 0.125 },
766
- { band: 8, gain: 0.35 * 0.125 },
767
- { band: 9, gain: 0.45 * 0.125 },
768
- { band: 10, gain: 0.55 * 0.125 },
769
- { band: 11, gain: -0.6 * 0.125 },
770
- { band: 12, gain: 0.55 * 0.125 },
771
- { band: 13, gain: -0.5 * 0.125 },
772
- { band: 14, gain: -0.75 * 0.125 },
773
- ],
774
- /** Makes the Music slightly "better" */
775
- BetterMusic: [
776
- { band: 0, gain: 0.25 },
777
- { band: 1, gain: 0.025 },
778
- { band: 2, gain: 0.0125 },
779
- { band: 3, gain: 0 },
780
- { band: 4, gain: 0 },
781
- { band: 5, gain: -0.0125 },
782
- { band: 6, gain: -0.025 },
783
- { band: 7, gain: -0.0175 },
784
- { band: 8, gain: 0 },
785
- { band: 9, gain: 0 },
786
- { band: 10, gain: 0.0125 },
787
- { band: 11, gain: 0.025 },
788
- { band: 12, gain: 0.25 },
789
- { band: 13, gain: 0.125 },
790
- { band: 14, gain: 0.125 },
791
- ],
792
- /** Makes the Music sound like rock music / sound rock music better */
793
- Rock: [
794
- { band: 0, gain: 0.300 },
795
- { band: 1, gain: 0.250 },
796
- { band: 2, gain: 0.200 },
797
- { band: 3, gain: 0.100 },
798
- { band: 4, gain: 0.050 },
799
- { band: 5, gain: -0.050 },
800
- { band: 6, gain: -0.150 },
801
- { band: 7, gain: -0.200 },
802
- { band: 8, gain: -0.100 },
803
- { band: 9, gain: -0.050 },
804
- { band: 10, gain: 0.050 },
805
- { band: 11, gain: 0.100 },
806
- { band: 12, gain: 0.200 },
807
- { band: 13, gain: 0.250 },
808
- { band: 14, gain: 0.300 },
809
- ],
810
- /** Makes the Music sound like Classic music / sound Classic music better */
811
- Classic: [
812
- { band: 0, gain: 0.375 },
813
- { band: 1, gain: 0.350 },
814
- { band: 2, gain: 0.125 },
815
- { band: 3, gain: 0 },
816
- { band: 4, gain: 0 },
817
- { band: 5, gain: 0.125 },
818
- { band: 6, gain: 0.550 },
819
- { band: 7, gain: 0.050 },
820
- { band: 8, gain: 0.125 },
821
- { band: 9, gain: 0.250 },
822
- { band: 10, gain: 0.200 },
823
- { band: 11, gain: 0.250 },
824
- { band: 12, gain: 0.300 },
825
- { band: 13, gain: 0.250 },
826
- { band: 14, gain: 0.300 },
827
- ],
828
- /** Makes the Music sound like Pop music / sound Pop music better */
829
- Pop: [
830
- { band: 0, gain: 0.2635 },
831
- { band: 1, gain: 0.22141 },
832
- { band: 2, gain: -0.21141 },
833
- { band: 3, gain: -0.1851 },
834
- { band: 4, gain: -0.155 },
835
- { band: 5, gain: 0.21141 },
836
- { band: 6, gain: 0.22456 },
837
- { band: 7, gain: 0.237 },
838
- { band: 8, gain: 0.237 },
839
- { band: 9, gain: 0.237 },
840
- { band: 10, gain: -0.05 },
841
- { band: 11, gain: -0.116 },
842
- { band: 12, gain: 0.192 },
843
- { band: 13, gain: 0 },
844
- ],
845
- /** Makes the Music sound like Electronic music / sound Electronic music better */
846
- Electronic: [
847
- { band: 0, gain: 0.375 },
848
- { band: 1, gain: 0.350 },
849
- { band: 2, gain: 0.125 },
850
- { band: 3, gain: 0 },
851
- { band: 4, gain: 0 },
852
- { band: 5, gain: -0.125 },
853
- { band: 6, gain: -0.125 },
854
- { band: 7, gain: 0 },
855
- { band: 8, gain: 0.25 },
856
- { band: 9, gain: 0.125 },
857
- { band: 10, gain: 0.15 },
858
- { band: 11, gain: 0.2 },
859
- { band: 12, gain: 0.250 },
860
- { band: 13, gain: 0.350 },
861
- { band: 14, gain: 0.400 },
862
- ],
863
- /** Boosts all Bands slightly for louder and fuller sound */
864
- FullSound: [
865
- { band: 0, gain: 0.25 + 0.375 },
866
- { band: 1, gain: 0.25 + 0.025 },
867
- { band: 2, gain: 0.25 + 0.0125 },
868
- { band: 3, gain: 0.25 + 0 },
869
- { band: 4, gain: 0.25 + 0 },
870
- { band: 5, gain: 0.25 + -0.0125 },
871
- { band: 6, gain: 0.25 + -0.025 },
872
- { band: 7, gain: 0.25 + -0.0175 },
873
- { band: 8, gain: 0.25 + 0 },
874
- { band: 9, gain: 0.25 + 0 },
875
- { band: 10, gain: 0.25 + 0.0125 },
876
- { band: 11, gain: 0.25 + 0.025 },
877
- { band: 12, gain: 0.25 + 0.375 },
878
- { band: 13, gain: 0.25 + 0.125 },
879
- { band: 14, gain: 0.25 + 0.125 },
880
- ],
881
- /** Boosts basses + lower highs for a pro gaming sound */
882
- Gaming: [
883
- { band: 0, gain: 0.350 },
884
- { band: 1, gain: 0.300 },
885
- { band: 2, gain: 0.250 },
886
- { band: 3, gain: 0.200 },
887
- { band: 4, gain: 0.150 },
888
- { band: 5, gain: 0.100 },
889
- { band: 6, gain: 0.050 },
890
- { band: 7, gain: -0.0 },
891
- { band: 8, gain: -0.050 },
892
- { band: 9, gain: -0.100 },
893
- { band: 10, gain: -0.150 },
894
- { band: 11, gain: -0.200 },
895
- { band: 12, gain: -0.250 },
896
- { band: 13, gain: -0.300 },
897
- { band: 14, gain: -0.350 },
898
- ],
899
- };
@@ -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 */
@@ -2,11 +2,57 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LavalinkManager = void 0;
4
4
  const events_1 = require("events");
5
+ const Constants_1 = require("./Constants");
5
6
  const NodeManager_1 = require("./NodeManager");
6
7
  const Player_1 = require("./Player");
7
8
  const Queue_1 = require("./Queue");
8
9
  const Utils_1 = require("./Utils");
9
10
  class LavalinkManager extends events_1.EventEmitter {
11
+ /**
12
+ * Emit an event
13
+ * @param event The event to emit
14
+ * @param args The arguments to pass to the event
15
+ * @returns
16
+ */
17
+ emit(event, ...args) {
18
+ return super.emit(event, ...args);
19
+ }
20
+ /**
21
+ * Add an event listener
22
+ * @param event The event to listen to
23
+ * @param listener The listener to add
24
+ * @returns
25
+ */
26
+ on(event, listener) {
27
+ return super.on(event, listener);
28
+ }
29
+ /**
30
+ * Add an event listener that only fires once
31
+ * @param event The event to listen to
32
+ * @param listener The listener to add
33
+ * @returns
34
+ */
35
+ once(event, listener) {
36
+ return super.once(event, listener);
37
+ }
38
+ /**
39
+ * Remove an event listener
40
+ * @param event The event to remove the listener from
41
+ * @param listener The listener to remove
42
+ * @returns
43
+ */
44
+ off(event, listener) {
45
+ return super.off(event, listener);
46
+ }
47
+ /**
48
+ * Remove an event listener
49
+ * @param event The event to remove the listener from
50
+ * @param listener The listener to remove
51
+ * @returns
52
+ */
53
+ removeListener(event, listener) {
54
+ return super.removeListener(event, listener);
55
+ }
10
56
  /** The Options of LavalinkManager (changeable) */
11
57
  options;
12
58
  /** LavalinkManager's NodeManager to manage all Nodes */
@@ -352,7 +398,7 @@ class LavalinkManager extends events_1.EventEmitter {
352
398
  return;
353
399
  const player = this.getPlayer(update.guild_id);
354
400
  if (player && player.voiceChannelId === update.id)
355
- return void player.destroy(Player_1.DestroyReasons.ChannelDeleted);
401
+ return void player.destroy(Constants_1.DestroyReasons.ChannelDeleted);
356
402
  }
357
403
  // for voice updates
358
404
  if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
@@ -409,19 +455,25 @@ class LavalinkManager extends events_1.EventEmitter {
409
455
  }
410
456
  else {
411
457
  if (this.options?.playerOptions?.onDisconnect?.destroyPlayer === true) {
412
- return void await player.destroy(Player_1.DestroyReasons.Disconnected);
458
+ return void await player.destroy(Constants_1.DestroyReasons.Disconnected);
413
459
  }
414
460
  this.emit("playerDisconnect", player, player.voiceChannelId);
415
- if (!player.paused)
416
- await player.pause();
417
461
  if (this.options?.playerOptions?.onDisconnect?.autoReconnect === true) {
418
462
  try {
463
+ const positionPrevios = player.position;
464
+ console.debug("Auto reconnect", positionPrevios, player.lastPosition);
419
465
  await player.connect();
466
+ // replay the current playing stream
467
+ await player.play({
468
+ position: positionPrevios,
469
+ paused: player.paused,
470
+ clientTrack: player.queue.current,
471
+ });
420
472
  }
421
- catch {
422
- return void await player.destroy(Player_1.DestroyReasons.PlayerReconnectFail);
473
+ catch (e) {
474
+ console.error(e);
475
+ return void await player.destroy(Constants_1.DestroyReasons.PlayerReconnectFail);
423
476
  }
424
- return void player.paused && await player.resume();
425
477
  }
426
478
  player.voiceChannelId = null;
427
479
  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 */