lavalink-client 2.6.3 → 2.6.5

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.mjs CHANGED
@@ -611,6 +611,29 @@ var ManagerUtils = class {
611
611
  if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== void 0)) return false;
612
612
  return true;
613
613
  }
614
+ /**
615
+ * Validate tracks based on duration wether they are playble or broken tracks.
616
+ * most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
617
+ * This check is not done automatically, you need to check it yourself by doing:
618
+ * @example
619
+ * ```ts
620
+ * const tracks = await player.search("Adele");
621
+ *
622
+ * // short hand:
623
+ * const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
624
+ * // or with options:
625
+ * const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
626
+ *
627
+ * // then you can add it to the queue.
628
+ * await player.queue.add(validTracks);
629
+ * ```
630
+ */
631
+ isNotBrokenTrack(data, minDuration = 29e3) {
632
+ if (typeof data?.info?.duration !== "number" || isNaN(data?.info?.duration)) return false;
633
+ if (data.info.duration <= Math.max(minDuration, 0)) return false;
634
+ if (!data.info) return false;
635
+ return this.isTrack(data);
636
+ }
614
637
  /**
615
638
  * Validate if a data is equal to a track
616
639
  * @param data the Track to validate
@@ -2712,6 +2735,7 @@ var DEFAULT_FILTER_DATAS = {
2712
2735
  }*/
2713
2736
  };
2714
2737
  var FilterManager = class {
2738
+ static EQList = EQList;
2715
2739
  /** The Equalizer bands currently applied to the Lavalink Server */
2716
2740
  equalizerBands = [];
2717
2741
  /** Private Util for the instaFix Filters option */
@@ -2749,6 +2773,17 @@ var FilterManager = class {
2749
2773
  }
2750
2774
  /**
2751
2775
  * Apply Player filters for lavalink filter sending data, if the filter is enabled / not
2776
+ *
2777
+ * @returns {Promise<void>}
2778
+ *
2779
+ * @example
2780
+ * ```ts
2781
+ * // Apply the filters after changing them manually:
2782
+ * player.filterManager.data.volume = 0.5;
2783
+ * // maybe you wanna manually set a distorition filter? then do it like this...
2784
+ * player.filterManager.data.distortion = { sinOffset: 0.5, sinScale: 2, cosOffset: 0.5, cosScale: 2, tanOffset: 0.5, tanScale: 2, offset: 0.5, scale: 2 };
2785
+ * await player.filterManager.applyPlayerFilters();
2786
+ * ```
2752
2787
  */
2753
2788
  async applyPlayerFilters() {
2754
2789
  const sendData = { ...this.data };
@@ -2788,9 +2823,17 @@ var FilterManager = class {
2788
2823
  return;
2789
2824
  }
2790
2825
  /**
2791
- * Checks if the filters are correctly stated (active / not-active)
2826
+ * Checks if the filters are correctly stated (active / not-active) - mostly used internally.
2792
2827
  * @param oldFilterTimescale
2793
- * @returns
2828
+ * @returns {boolean} True, if the check was successfull
2829
+ *
2830
+ * @example
2831
+ * ```ts
2832
+ * // Check the filter states
2833
+ * player.filterManager.checkFiltersState();
2834
+ * // Apply the filters after checking
2835
+ * await player.filterManager.applyPlayerFilters();
2836
+ * ```
2794
2837
  */
2795
2838
  checkFiltersState(oldFilterTimescale) {
2796
2839
  this.filters.rotation = this.data.rotation.rotationHz !== 0;
@@ -2816,6 +2859,13 @@ var FilterManager = class {
2816
2859
  }
2817
2860
  /**
2818
2861
  * Reset all Filters
2862
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
2863
+ *
2864
+ * @example
2865
+ * ```ts
2866
+ * // Reset all filters
2867
+ * await player.filterManager.resetFilters();
2868
+ * ```
2819
2869
  */
2820
2870
  async resetFilters() {
2821
2871
  this.filters.lavalinkLavaDspxPlugin.echo = false;
@@ -2833,83 +2883,21 @@ var FilterManager = class {
2833
2883
  this.filters.karaoke = false;
2834
2884
  this.filters.volume = false;
2835
2885
  this.filters.audioOutput = "stereo";
2836
- for (const [key, value] of Object.entries({
2837
- volume: 1,
2838
- lowPass: {
2839
- smoothing: 0
2840
- },
2841
- karaoke: {
2842
- level: 0,
2843
- monoLevel: 0,
2844
- filterBand: 0,
2845
- filterWidth: 0
2846
- },
2847
- timescale: {
2848
- speed: 1,
2849
- // 0 = x
2850
- pitch: 1,
2851
- // 0 = x
2852
- rate: 1
2853
- // 0 = x
2854
- },
2855
- pluginFilters: {
2856
- "lavalink-filter-plugin": {
2857
- echo: {
2858
- // delay: 0, // in seconds
2859
- // decay: 0 // 0 < 1
2860
- },
2861
- reverb: {
2862
- // delays: [], // [0.037, 0.042, 0.048, 0.053]
2863
- // gains: [] // [0.84, 0.83, 0.82, 0.81]
2864
- }
2865
- },
2866
- "high-pass": {
2867
- // Cuts off frequencies lower than the specified {cutoffFrequency}.
2868
- // "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
2869
- // "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
2870
- },
2871
- "low-pass": {
2872
- // Cuts off frequencies higher than the specified {cutoffFrequency}.
2873
- // "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
2874
- // "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
2875
- },
2876
- "normalization": {
2877
- // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
2878
- // "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
2879
- // "adaptive": true // false
2880
- },
2881
- "echo": {
2882
- // Self-explanatory; provides an echo effect.
2883
- // "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
2884
- // "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
2885
- }
2886
- },
2887
- rotation: {
2888
- rotationHz: 0
2889
- },
2890
- tremolo: {
2891
- frequency: 0,
2892
- // 0 < x
2893
- depth: 0
2894
- // 0 < x = 1
2895
- },
2896
- vibrato: {
2897
- frequency: 0,
2898
- // 0 < x = 14
2899
- depth: 0
2900
- // 0 < x = 1
2901
- },
2902
- channelMix: audioOutputsData.stereo
2903
- })) {
2904
- this.data[key] = value;
2905
- }
2886
+ this.data = structuredClone(DEFAULT_FILTER_DATAS);
2906
2887
  await this.applyPlayerFilters();
2907
- return this.filters;
2888
+ return this;
2908
2889
  }
2909
2890
  /**
2910
2891
  * Set the Filter Volume
2911
- * @param volume
2912
- * @returns
2892
+ * @param volume the volume (0.0 - 5.0)
2893
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
2894
+ *
2895
+ * @example
2896
+ * ```ts
2897
+ * // Set Volume to 50%
2898
+ * await player.filterManager.setVolume(0.5);
2899
+ * // note this is a filter, so it will "jump" to the volume, i think it's like a "volume boost effect" so i marketed it as a filter
2900
+ * ```
2913
2901
  */
2914
2902
  async setVolume(volume) {
2915
2903
  if (volume < 0 || volume > 5) throw new SyntaxError("Volume-Filter must be between 0 and 5");
@@ -2917,12 +2905,27 @@ var FilterManager = class {
2917
2905
  this.data.volume = volume;
2918
2906
  this.filters.volume = volume !== 1;
2919
2907
  await this.applyPlayerFilters();
2920
- return this.filters.volume;
2908
+ return this;
2921
2909
  }
2922
2910
  /**
2923
2911
  * Set the AudioOutput Filter
2924
- * @param type
2925
- * @returns
2912
+ * @param {AudioOutputs} type the audio output type
2913
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
2914
+ *
2915
+ * @example
2916
+ * ```ts
2917
+ * // Set Audio Output to Mono
2918
+ * await player.filterManager.setAudioOutput("mono");
2919
+ *
2920
+ * // Set Audio Output to Stereo
2921
+ * await player.filterManager.setAudioOutput("stereo");
2922
+ *
2923
+ * // Set Audio Output to Left
2924
+ * await player.filterManager.setAudioOutput("left");
2925
+ *
2926
+ * // Set Audio Output to Right
2927
+ * await player.filterManager.setAudioOutput("right");
2928
+ * ```
2926
2929
  */
2927
2930
  async setAudioOutput(type) {
2928
2931
  if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix")) throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
@@ -2931,12 +2934,18 @@ var FilterManager = class {
2931
2934
  this.data.channelMix = audioOutputsData[type];
2932
2935
  this.filters.audioOutput = type;
2933
2936
  await this.applyPlayerFilters();
2934
- return this.filters.audioOutput;
2937
+ return this;
2935
2938
  }
2936
2939
  /**
2937
2940
  * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
2938
- * @param speed
2939
- * @returns
2941
+ * @param {number} speed set the speed of the filter
2942
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
2943
+ *
2944
+ * @example
2945
+ * ```ts
2946
+ * // Set Speed to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
2947
+ * await player.filterManager.setSpeed(1.25);
2948
+ * ```
2940
2949
  */
2941
2950
  async setSpeed(speed = 1) {
2942
2951
  if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
@@ -2946,12 +2955,18 @@ var FilterManager = class {
2946
2955
  this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, speed };
2947
2956
  this.isCustomFilterActive();
2948
2957
  await this.applyPlayerFilters();
2949
- return this.filters.custom;
2958
+ return this;
2950
2959
  }
2951
2960
  /**
2952
2961
  * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
2953
- * @param speed
2954
- * @returns
2962
+ * @param {number} pitch set the pitch of the filter
2963
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
2964
+ *
2965
+ * @example
2966
+ * ```ts
2967
+ * // Set Pitch to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
2968
+ * await player.filterManager.setPitch(1.25);
2969
+ * ```
2955
2970
  */
2956
2971
  async setPitch(pitch = 1) {
2957
2972
  if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
@@ -2961,12 +2976,18 @@ var FilterManager = class {
2961
2976
  this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, pitch };
2962
2977
  this.isCustomFilterActive();
2963
2978
  await this.applyPlayerFilters();
2964
- return this.filters.custom;
2979
+ return this;
2965
2980
  }
2966
2981
  /**
2967
2982
  * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
2968
- * @param speed
2969
- * @returns
2983
+ * @param {number} rate set the rate of the filter
2984
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
2985
+ *
2986
+ * @example
2987
+ * ```ts
2988
+ * // Set Rate to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
2989
+ * await player.filterManager.setRate(1.25);
2990
+ * ```
2970
2991
  */
2971
2992
  async setRate(rate = 1) {
2972
2993
  if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
@@ -2976,12 +2997,21 @@ var FilterManager = class {
2976
2997
  this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, rate };
2977
2998
  this.isCustomFilterActive();
2978
2999
  await this.applyPlayerFilters();
2979
- return this.filters.custom;
3000
+ return this;
2980
3001
  }
2981
3002
  /**
2982
3003
  * Enables / Disables the rotation effect, (Optional: provide your Own Data)
2983
- * @param rotationHz
2984
- * @returns
3004
+ * @param {number} rotationHz set the rotationHz of the filter
3005
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3006
+ *
3007
+ * @example
3008
+ * ```ts
3009
+ * // Toggle Rotation filter with custom settings
3010
+ * await player.filterManager.toggleRotation(0.4);
3011
+ * // or use the defaults
3012
+ * await player.filterManager.toggleRotation();
3013
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3014
+ * ```
2985
3015
  */
2986
3016
  async toggleRotation(rotationHz = 0.2) {
2987
3017
  if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation")) throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
@@ -2989,13 +3019,22 @@ var FilterManager = class {
2989
3019
  this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
2990
3020
  this.filters.rotation = !this.filters.rotation;
2991
3021
  await this.applyPlayerFilters();
2992
- return this.filters.rotation;
3022
+ return this;
2993
3023
  }
2994
3024
  /**
2995
3025
  * Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
2996
- * @param frequency
2997
- * @param depth
2998
- * @returns
3026
+ * @param {number} frequency set the frequency of the filter
3027
+ * @param {number} depth set the depth of the filter
3028
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3029
+ *
3030
+ * @example
3031
+ * ```ts
3032
+ * // Toggle Vibrato filter with custom settings
3033
+ * await player.filterManager.toggleVibrato(8, 0.5);
3034
+ * // or use the defaults
3035
+ * await player.filterManager.toggleVibrato();
3036
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3037
+ * ```
2999
3038
  */
3000
3039
  async toggleVibrato(frequency = 10, depth = 1) {
3001
3040
  if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato")) throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
@@ -3003,13 +3042,22 @@ var FilterManager = class {
3003
3042
  this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
3004
3043
  this.filters.vibrato = !this.filters.vibrato;
3005
3044
  await this.applyPlayerFilters();
3006
- return this.filters.vibrato;
3045
+ return this;
3007
3046
  }
3008
3047
  /**
3009
3048
  * Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
3010
- * @param frequency
3011
- * @param depth
3012
- * @returns
3049
+ * @param {number} frequency set the frequency of the filter
3050
+ * @param {number} depth set the depth of the filter
3051
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3052
+ *
3053
+ * @example
3054
+ * ```ts
3055
+ * // Toggle Tremolo filter with custom settings
3056
+ * await player.filterManager.toggleTremolo(5, 0.7);
3057
+ * // or use the defaults
3058
+ * await player.filterManager.toggleTremolo();
3059
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3060
+ * ```
3013
3061
  */
3014
3062
  async toggleTremolo(frequency = 4, depth = 0.8) {
3015
3063
  if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo")) throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
@@ -3017,12 +3065,21 @@ var FilterManager = class {
3017
3065
  this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
3018
3066
  this.filters.tremolo = !this.filters.tremolo;
3019
3067
  await this.applyPlayerFilters();
3020
- return this.filters.tremolo;
3068
+ return this;
3021
3069
  }
3022
3070
  /**
3023
3071
  * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
3024
- * @param smoothing
3025
- * @returns
3072
+ * @param {number} smoothing set the smoothing of the filter
3073
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3074
+ *
3075
+ * @example
3076
+ * ```ts
3077
+ * // Toggle LowPass filter with custom settings
3078
+ * await player.filterManager.toggleLowPass(30);
3079
+ * // or use the defaults
3080
+ * await player.filterManager.toggleLowPass();
3081
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3082
+ * ```
3026
3083
  */
3027
3084
  async toggleLowPass(smoothing = 20) {
3028
3085
  if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass")) throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
@@ -3030,14 +3087,26 @@ var FilterManager = class {
3030
3087
  this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
3031
3088
  this.filters.lowPass = !this.filters.lowPass;
3032
3089
  await this.applyPlayerFilters();
3033
- return this.filters.lowPass;
3090
+ return this;
3034
3091
  }
3092
+ /**
3093
+ * Lavalink LavaDspx Plugin Filters
3094
+ */
3035
3095
  lavalinkLavaDspxPlugin = {
3036
3096
  /**
3037
3097
  * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
3038
- * @param boostFactor
3039
- * @param cutoffFrequency
3040
- * @returns
3098
+ * @param {number} boostFactor set the boost factor of the filter
3099
+ * @param {number} cutoffFrequency set the cutoff frequency of the filter
3100
+ * @returns {Promise<boolean>} the state of the filter after execution.
3101
+ *
3102
+ * @example
3103
+ * ```ts
3104
+ * // Toggle LowPass filter with custom settings
3105
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(1.2, 300);
3106
+ * // or use the defaults
3107
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass();
3108
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3109
+ * ```
3041
3110
  */
3042
3111
  toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
3043
3112
  if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
@@ -3048,13 +3117,22 @@ var FilterManager = class {
3048
3117
  else this.data.pluginFilters["low-pass"] = { boostFactor, cutoffFrequency };
3049
3118
  this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
3050
3119
  await this.applyPlayerFilters();
3051
- return this.filters.lavalinkLavaDspxPlugin.lowPass;
3120
+ return this;
3052
3121
  },
3053
3122
  /**
3054
3123
  * Enables / Disables the HighPass effect, (Optional: provide your Own Data)
3055
- * @param boostFactor
3056
- * @param cutoffFrequency
3057
- * @returns
3124
+ * @param {number} boostFactor [] set the boost factor of the filter
3125
+ * @param {number} cutoffFrequency set the cutoff frequency of the filter
3126
+ * @returns {Promise<boolean>} the state of the filter after execution.
3127
+ *
3128
+ * @example
3129
+ * ```ts
3130
+ * // Toggle HighPass filter with custom settings
3131
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass(1.2, 150); // custom values
3132
+ * // or use the defaults
3133
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass();
3134
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3135
+ * ```
3058
3136
  */
3059
3137
  toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
3060
3138
  if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
@@ -3065,13 +3143,22 @@ var FilterManager = class {
3065
3143
  else this.data.pluginFilters["high-pass"] = { boostFactor, cutoffFrequency };
3066
3144
  this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
3067
3145
  await this.applyPlayerFilters();
3068
- return this.filters.lavalinkLavaDspxPlugin.highPass;
3146
+ return this;
3069
3147
  },
3070
3148
  /**
3071
3149
  * Enables / Disables the Normalization effect.
3072
3150
  * @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
3073
- * @param {boolean} [adaptive=true] - Whether to use adaptive normalization or not.
3074
- * @returns {Promise<boolean>} - The state of the filter after execution.
3151
+ * @param {boolean} [adaptive=true] Whether to use adaptive normalization or not.
3152
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3153
+ *
3154
+ * @example
3155
+ * ```ts
3156
+ * // Toggle Normalization filter with custom settings
3157
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization(0.9, false); // custom values
3158
+ * // or use the defaults
3159
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization();
3160
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3161
+ * ```
3075
3162
  */
3076
3163
  toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
3077
3164
  if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
@@ -3082,13 +3169,22 @@ var FilterManager = class {
3082
3169
  else this.data.pluginFilters.normalization = { adaptive, maxAmplitude };
3083
3170
  this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
3084
3171
  await this.applyPlayerFilters();
3085
- return this.filters.lavalinkLavaDspxPlugin.normalization;
3172
+ return this;
3086
3173
  },
3087
3174
  /**
3088
3175
  * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
3089
- * @param {number} [decay=0.5] - The decay of the echo effect.
3090
- * @param {number} [echoLength=0.5] - The length of the echo effect.
3091
- * @returns {Promise<boolean>} - The state of the filter after execution.
3176
+ * @param {number} [decay=0.5] The decay of the echo effect.
3177
+ * @param {number} [echoLength=0.5] The length of the echo effect.
3178
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3179
+ *
3180
+ * @example
3181
+ * ```ts
3182
+ * // Toggle Echo filter with custom settings
3183
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho(0.7, 0.6); // custom values
3184
+ * // or use the defaults
3185
+ * await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho();
3186
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3187
+ * ```
3092
3188
  */
3093
3189
  toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
3094
3190
  if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
@@ -3099,15 +3195,27 @@ var FilterManager = class {
3099
3195
  else this.data.pluginFilters.echo = { decay, echoLength };
3100
3196
  this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
3101
3197
  await this.applyPlayerFilters();
3102
- return this.filters.lavalinkLavaDspxPlugin.echo;
3198
+ return this;
3103
3199
  }
3104
3200
  };
3201
+ /**
3202
+ * LavalinkFilter Plugin specific Filters
3203
+ */
3105
3204
  lavalinkFilterPlugin = {
3106
3205
  /**
3107
3206
  * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
3108
- * @param delay
3109
- * @param decay
3110
- * @returns
3207
+ * @param {number} delay set the delay of the echo
3208
+ * @param {number} decay set the decay of the echo
3209
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3210
+ *
3211
+ * @example
3212
+ * ```ts
3213
+ * // Toggle Echo filter with custom settings
3214
+ * await player.filterManager.lavalinkFilterPlugin.toggleEcho(3, 0.7); // custom values
3215
+ * // or use the defaults
3216
+ * await player.filterManager.lavalinkFilterPlugin.toggleEcho();
3217
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3218
+ * ```
3111
3219
  */
3112
3220
  toggleEcho: async (delay = 4, decay = 0.8) => {
3113
3221
  if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
@@ -3123,13 +3231,22 @@ var FilterManager = class {
3123
3231
  };
3124
3232
  this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
3125
3233
  await this.applyPlayerFilters();
3126
- return this.filters.lavalinkFilterPlugin.echo;
3234
+ return this;
3127
3235
  },
3128
3236
  /**
3129
3237
  * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
3130
- * @param delays
3131
- * @param gains
3132
- * @returns
3238
+ * @param {number} delays set the delays of the reverb
3239
+ * @param {number} gains set the gains of the reverb
3240
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3241
+ *
3242
+ * @example
3243
+ * ```ts
3244
+ * // Toggle Reverb filter with custom settings
3245
+ * await player.filterManager.lavalinkFilterPlugin.toggleReverb([0.04, 0.045, 0.05, 0.055], [0.85, 0.84, 0.83, 0.82]);
3246
+ * // or use the defaults
3247
+ * await player.filterManager.lavalinkFilterPlugin.toggleReverb();
3248
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3249
+ * ```
3133
3250
  */
3134
3251
  toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
3135
3252
  if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
@@ -3145,15 +3262,24 @@ var FilterManager = class {
3145
3262
  };
3146
3263
  this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
3147
3264
  await this.applyPlayerFilters();
3148
- return this.filters.lavalinkFilterPlugin.reverb;
3265
+ return this;
3149
3266
  }
3150
3267
  };
3151
3268
  /**
3152
3269
  * Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
3153
- * @param speed
3154
- * @param pitch
3155
- * @param rate
3156
- * @returns
3270
+ * @param {number} speed set the speed of the filter
3271
+ * @param {number} pitch set the pitch of the filter
3272
+ * @param {number} rate set the rate of the filter
3273
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3274
+ *
3275
+ * @example
3276
+ * ```ts
3277
+ * // Toggle Nightcore filter with custom settings
3278
+ * await player.filterManager.toggleNightcore(1.3, 1.3, 0.9);
3279
+ * // or use the defaults
3280
+ * await player.filterManager.toggleNightcore();
3281
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3282
+ * ```
3157
3283
  */
3158
3284
  async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
3159
3285
  if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
@@ -3163,14 +3289,23 @@ var FilterManager = class {
3163
3289
  this.filters.vaporwave = false;
3164
3290
  this.filters.custom = false;
3165
3291
  await this.applyPlayerFilters();
3166
- return this.filters.nightcore;
3292
+ return this;
3167
3293
  }
3168
3294
  /**
3169
3295
  * Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
3170
- * @param speed
3171
- * @param pitch
3172
- * @param rate
3173
- * @returns
3296
+ * @param {number} speed set the speed of the filterq
3297
+ * @param {number} pitch set the pitch of the filter
3298
+ * @param {number} rate set the rate of the filter
3299
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3300
+ *
3301
+ * @example
3302
+ * ```ts
3303
+ * // Toggle Vaporwave filter with custom settings
3304
+ * await player.filterManager.toggleVaporwave(0.9, 0.7, 1);
3305
+ * // or use the defaults
3306
+ * await player.filterManager.toggleVaporwave();
3307
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3308
+ * ```
3174
3309
  */
3175
3310
  async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
3176
3311
  if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
@@ -3180,15 +3315,24 @@ var FilterManager = class {
3180
3315
  this.filters.nightcore = false;
3181
3316
  this.filters.custom = false;
3182
3317
  await this.applyPlayerFilters();
3183
- return this.filters.vaporwave;
3318
+ return this;
3184
3319
  }
3185
3320
  /**
3186
3321
  * Enable / Disables a Karaoke like Filter Effect
3187
- * @param level
3188
- * @param monoLevel
3189
- * @param filterBand
3190
- * @param filterWidth
3191
- * @returns
3322
+ * @param {number} level set the level of the filter
3323
+ * @param {number} monoLevel set the mono level of the filter
3324
+ * @param {number} filterBand set the filter band of the filter
3325
+ * @param {number} filterWidth set the filter width of the filter
3326
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3327
+ *
3328
+ * @example
3329
+ * ```ts
3330
+ * // Toggle Karaoke filter with custom settings
3331
+ * await player.filterManager.toggleKaraoke(1.5, 1.0, 220, 100);
3332
+ * // or use the defaults
3333
+ * await player.filterManager.toggleKaraoke();
3334
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
3335
+ * ```
3192
3336
  */
3193
3337
  async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
3194
3338
  if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke")) throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
@@ -3196,17 +3340,56 @@ var FilterManager = class {
3196
3340
  this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
3197
3341
  this.filters.karaoke = !this.filters.karaoke;
3198
3342
  await this.applyPlayerFilters();
3199
- return this.filters.karaoke;
3343
+ return this;
3200
3344
  }
3201
- /** Function to find out if currently there is a custom timescamle etc. filter applied */
3345
+ /**
3346
+ * Function to find out if currently there is a custom timescamle etc. filter applied
3347
+ * @returns {boolean} whether a custom filter is active
3348
+ *
3349
+ * @example
3350
+ * ```ts
3351
+ * // Check if a custom filter is active
3352
+ * const isCustom = player.filterManager.isCustomFilterActive();
3353
+ * console.log(`Is custom filter active? ${isCustom}`);
3354
+ * ```
3355
+ */
3202
3356
  isCustomFilterActive() {
3203
3357
  this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some((d) => d !== 1);
3204
3358
  return this.filters.custom;
3205
3359
  }
3206
3360
  /**
3207
- * Sets the players equalizer band on-top of the existing ones.
3208
- * @param bands
3209
- */
3361
+ * Sets the players equalizer bands using one of the predefined presets.
3362
+ * @param {keyof typeof EQList} preset The preset to use.
3363
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3364
+ *
3365
+ * @example
3366
+ * ```ts
3367
+ * // Set EQ preset
3368
+ * await player.filterManager.setEQPreset('BassboostMedium');
3369
+ * ```
3370
+ */
3371
+ async setEQPreset(preset) {
3372
+ const bands = EQList[preset];
3373
+ return this.setEQ(bands);
3374
+ }
3375
+ /**
3376
+ * Sets the players equalizer band on-top of the existing ones.
3377
+ * @param {number} bands
3378
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3379
+ *
3380
+ * @example
3381
+ * ```ts
3382
+ * // Set EQ bands
3383
+ * await player.filterManager.setEQ([
3384
+ * { band: 0, gain: 0.3 },
3385
+ * { band: 1, gain: -0.2 },
3386
+ * { band: 2, gain: 0.1 }
3387
+ * ]);
3388
+ *
3389
+ * // or use one of the templates:
3390
+ * await player.filterManager.setEQ(player.filterManager.EQList.BassboostMedium); // you can also import EQList from somewhere package if wanted.
3391
+ * ```
3392
+ */
3210
3393
  async setEQ(bands) {
3211
3394
  if (!Array.isArray(bands)) bands = [bands];
3212
3395
  if (!bands.length || !bands.every((band) => safeStringify(Object.keys(band).sort()) === '["band","gain"]')) throw new TypeError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
@@ -3223,7 +3406,16 @@ var FilterManager = class {
3223
3406
  this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
3224
3407
  return this;
3225
3408
  }
3226
- /** Clears the equalizer bands. */
3409
+ /**
3410
+ * Clears the equalizer bands.
3411
+ * @returns {Promise<FilterManager>} The Filter Manager, for chaining.
3412
+ *
3413
+ * @example
3414
+ * ```ts
3415
+ * // Clear all EQ bands
3416
+ * await player.filterManager.clearEQ();
3417
+ * ```
3418
+ */
3227
3419
  async clearEQ() {
3228
3420
  return this.setEQ(Array.from({ length: 15 }, (_v, i) => ({ band: i, gain: 0 })));
3229
3421
  }