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.d.mts +352 -76
- package/dist/index.d.ts +352 -76
- package/dist/index.js +338 -146
- package/dist/index.mjs +338 -146
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -671,6 +671,29 @@ var ManagerUtils = class {
|
|
|
671
671
|
if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== void 0)) return false;
|
|
672
672
|
return true;
|
|
673
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
676
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
677
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* const tracks = await player.search("Adele");
|
|
681
|
+
*
|
|
682
|
+
* // short hand:
|
|
683
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
684
|
+
* // or with options:
|
|
685
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
686
|
+
*
|
|
687
|
+
* // then you can add it to the queue.
|
|
688
|
+
* await player.queue.add(validTracks);
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
isNotBrokenTrack(data, minDuration = 29e3) {
|
|
692
|
+
if (typeof data?.info?.duration !== "number" || isNaN(data?.info?.duration)) return false;
|
|
693
|
+
if (data.info.duration <= Math.max(minDuration, 0)) return false;
|
|
694
|
+
if (!data.info) return false;
|
|
695
|
+
return this.isTrack(data);
|
|
696
|
+
}
|
|
674
697
|
/**
|
|
675
698
|
* Validate if a data is equal to a track
|
|
676
699
|
* @param data the Track to validate
|
|
@@ -2772,6 +2795,7 @@ var DEFAULT_FILTER_DATAS = {
|
|
|
2772
2795
|
}*/
|
|
2773
2796
|
};
|
|
2774
2797
|
var FilterManager = class {
|
|
2798
|
+
static EQList = EQList;
|
|
2775
2799
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
2776
2800
|
equalizerBands = [];
|
|
2777
2801
|
/** Private Util for the instaFix Filters option */
|
|
@@ -2809,6 +2833,17 @@ var FilterManager = class {
|
|
|
2809
2833
|
}
|
|
2810
2834
|
/**
|
|
2811
2835
|
* Apply Player filters for lavalink filter sending data, if the filter is enabled / not
|
|
2836
|
+
*
|
|
2837
|
+
* @returns {Promise<void>}
|
|
2838
|
+
*
|
|
2839
|
+
* @example
|
|
2840
|
+
* ```ts
|
|
2841
|
+
* // Apply the filters after changing them manually:
|
|
2842
|
+
* player.filterManager.data.volume = 0.5;
|
|
2843
|
+
* // maybe you wanna manually set a distorition filter? then do it like this...
|
|
2844
|
+
* player.filterManager.data.distortion = { sinOffset: 0.5, sinScale: 2, cosOffset: 0.5, cosScale: 2, tanOffset: 0.5, tanScale: 2, offset: 0.5, scale: 2 };
|
|
2845
|
+
* await player.filterManager.applyPlayerFilters();
|
|
2846
|
+
* ```
|
|
2812
2847
|
*/
|
|
2813
2848
|
async applyPlayerFilters() {
|
|
2814
2849
|
const sendData = { ...this.data };
|
|
@@ -2848,9 +2883,17 @@ var FilterManager = class {
|
|
|
2848
2883
|
return;
|
|
2849
2884
|
}
|
|
2850
2885
|
/**
|
|
2851
|
-
* Checks if the filters are correctly stated (active / not-active)
|
|
2886
|
+
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
2852
2887
|
* @param oldFilterTimescale
|
|
2853
|
-
* @returns
|
|
2888
|
+
* @returns {boolean} True, if the check was successfull
|
|
2889
|
+
*
|
|
2890
|
+
* @example
|
|
2891
|
+
* ```ts
|
|
2892
|
+
* // Check the filter states
|
|
2893
|
+
* player.filterManager.checkFiltersState();
|
|
2894
|
+
* // Apply the filters after checking
|
|
2895
|
+
* await player.filterManager.applyPlayerFilters();
|
|
2896
|
+
* ```
|
|
2854
2897
|
*/
|
|
2855
2898
|
checkFiltersState(oldFilterTimescale) {
|
|
2856
2899
|
this.filters.rotation = this.data.rotation.rotationHz !== 0;
|
|
@@ -2876,6 +2919,13 @@ var FilterManager = class {
|
|
|
2876
2919
|
}
|
|
2877
2920
|
/**
|
|
2878
2921
|
* Reset all Filters
|
|
2922
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2923
|
+
*
|
|
2924
|
+
* @example
|
|
2925
|
+
* ```ts
|
|
2926
|
+
* // Reset all filters
|
|
2927
|
+
* await player.filterManager.resetFilters();
|
|
2928
|
+
* ```
|
|
2879
2929
|
*/
|
|
2880
2930
|
async resetFilters() {
|
|
2881
2931
|
this.filters.lavalinkLavaDspxPlugin.echo = false;
|
|
@@ -2893,83 +2943,21 @@ var FilterManager = class {
|
|
|
2893
2943
|
this.filters.karaoke = false;
|
|
2894
2944
|
this.filters.volume = false;
|
|
2895
2945
|
this.filters.audioOutput = "stereo";
|
|
2896
|
-
|
|
2897
|
-
volume: 1,
|
|
2898
|
-
lowPass: {
|
|
2899
|
-
smoothing: 0
|
|
2900
|
-
},
|
|
2901
|
-
karaoke: {
|
|
2902
|
-
level: 0,
|
|
2903
|
-
monoLevel: 0,
|
|
2904
|
-
filterBand: 0,
|
|
2905
|
-
filterWidth: 0
|
|
2906
|
-
},
|
|
2907
|
-
timescale: {
|
|
2908
|
-
speed: 1,
|
|
2909
|
-
// 0 = x
|
|
2910
|
-
pitch: 1,
|
|
2911
|
-
// 0 = x
|
|
2912
|
-
rate: 1
|
|
2913
|
-
// 0 = x
|
|
2914
|
-
},
|
|
2915
|
-
pluginFilters: {
|
|
2916
|
-
"lavalink-filter-plugin": {
|
|
2917
|
-
echo: {
|
|
2918
|
-
// delay: 0, // in seconds
|
|
2919
|
-
// decay: 0 // 0 < 1
|
|
2920
|
-
},
|
|
2921
|
-
reverb: {
|
|
2922
|
-
// delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
2923
|
-
// gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
2924
|
-
}
|
|
2925
|
-
},
|
|
2926
|
-
"high-pass": {
|
|
2927
|
-
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2928
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2929
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2930
|
-
},
|
|
2931
|
-
"low-pass": {
|
|
2932
|
-
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2933
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2934
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2935
|
-
},
|
|
2936
|
-
"normalization": {
|
|
2937
|
-
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2938
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2939
|
-
// "adaptive": true // false
|
|
2940
|
-
},
|
|
2941
|
-
"echo": {
|
|
2942
|
-
// Self-explanatory; provides an echo effect.
|
|
2943
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2944
|
-
// "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
|
|
2945
|
-
}
|
|
2946
|
-
},
|
|
2947
|
-
rotation: {
|
|
2948
|
-
rotationHz: 0
|
|
2949
|
-
},
|
|
2950
|
-
tremolo: {
|
|
2951
|
-
frequency: 0,
|
|
2952
|
-
// 0 < x
|
|
2953
|
-
depth: 0
|
|
2954
|
-
// 0 < x = 1
|
|
2955
|
-
},
|
|
2956
|
-
vibrato: {
|
|
2957
|
-
frequency: 0,
|
|
2958
|
-
// 0 < x = 14
|
|
2959
|
-
depth: 0
|
|
2960
|
-
// 0 < x = 1
|
|
2961
|
-
},
|
|
2962
|
-
channelMix: audioOutputsData.stereo
|
|
2963
|
-
})) {
|
|
2964
|
-
this.data[key] = value;
|
|
2965
|
-
}
|
|
2946
|
+
this.data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2966
2947
|
await this.applyPlayerFilters();
|
|
2967
|
-
return this
|
|
2948
|
+
return this;
|
|
2968
2949
|
}
|
|
2969
2950
|
/**
|
|
2970
2951
|
* Set the Filter Volume
|
|
2971
|
-
* @param volume
|
|
2972
|
-
* @returns
|
|
2952
|
+
* @param volume the volume (0.0 - 5.0)
|
|
2953
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2954
|
+
*
|
|
2955
|
+
* @example
|
|
2956
|
+
* ```ts
|
|
2957
|
+
* // Set Volume to 50%
|
|
2958
|
+
* await player.filterManager.setVolume(0.5);
|
|
2959
|
+
* // 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
|
|
2960
|
+
* ```
|
|
2973
2961
|
*/
|
|
2974
2962
|
async setVolume(volume) {
|
|
2975
2963
|
if (volume < 0 || volume > 5) throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
@@ -2977,12 +2965,27 @@ var FilterManager = class {
|
|
|
2977
2965
|
this.data.volume = volume;
|
|
2978
2966
|
this.filters.volume = volume !== 1;
|
|
2979
2967
|
await this.applyPlayerFilters();
|
|
2980
|
-
return this
|
|
2968
|
+
return this;
|
|
2981
2969
|
}
|
|
2982
2970
|
/**
|
|
2983
2971
|
* Set the AudioOutput Filter
|
|
2984
|
-
* @param type
|
|
2985
|
-
* @returns
|
|
2972
|
+
* @param {AudioOutputs} type the audio output type
|
|
2973
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2974
|
+
*
|
|
2975
|
+
* @example
|
|
2976
|
+
* ```ts
|
|
2977
|
+
* // Set Audio Output to Mono
|
|
2978
|
+
* await player.filterManager.setAudioOutput("mono");
|
|
2979
|
+
*
|
|
2980
|
+
* // Set Audio Output to Stereo
|
|
2981
|
+
* await player.filterManager.setAudioOutput("stereo");
|
|
2982
|
+
*
|
|
2983
|
+
* // Set Audio Output to Left
|
|
2984
|
+
* await player.filterManager.setAudioOutput("left");
|
|
2985
|
+
*
|
|
2986
|
+
* // Set Audio Output to Right
|
|
2987
|
+
* await player.filterManager.setAudioOutput("right");
|
|
2988
|
+
* ```
|
|
2986
2989
|
*/
|
|
2987
2990
|
async setAudioOutput(type) {
|
|
2988
2991
|
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)");
|
|
@@ -2991,12 +2994,18 @@ var FilterManager = class {
|
|
|
2991
2994
|
this.data.channelMix = audioOutputsData[type];
|
|
2992
2995
|
this.filters.audioOutput = type;
|
|
2993
2996
|
await this.applyPlayerFilters();
|
|
2994
|
-
return this
|
|
2997
|
+
return this;
|
|
2995
2998
|
}
|
|
2996
2999
|
/**
|
|
2997
3000
|
* Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
2998
|
-
* @param speed
|
|
2999
|
-
* @returns
|
|
3001
|
+
* @param {number} speed set the speed of the filter
|
|
3002
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3003
|
+
*
|
|
3004
|
+
* @example
|
|
3005
|
+
* ```ts
|
|
3006
|
+
* // Set Speed to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
|
|
3007
|
+
* await player.filterManager.setSpeed(1.25);
|
|
3008
|
+
* ```
|
|
3000
3009
|
*/
|
|
3001
3010
|
async setSpeed(speed = 1) {
|
|
3002
3011
|
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)");
|
|
@@ -3006,12 +3015,18 @@ var FilterManager = class {
|
|
|
3006
3015
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, speed };
|
|
3007
3016
|
this.isCustomFilterActive();
|
|
3008
3017
|
await this.applyPlayerFilters();
|
|
3009
|
-
return this
|
|
3018
|
+
return this;
|
|
3010
3019
|
}
|
|
3011
3020
|
/**
|
|
3012
3021
|
* Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
3013
|
-
* @param
|
|
3014
|
-
* @returns
|
|
3022
|
+
* @param {number} pitch set the pitch of the filter
|
|
3023
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3024
|
+
*
|
|
3025
|
+
* @example
|
|
3026
|
+
* ```ts
|
|
3027
|
+
* // Set Pitch to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
|
|
3028
|
+
* await player.filterManager.setPitch(1.25);
|
|
3029
|
+
* ```
|
|
3015
3030
|
*/
|
|
3016
3031
|
async setPitch(pitch = 1) {
|
|
3017
3032
|
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)");
|
|
@@ -3021,12 +3036,18 @@ var FilterManager = class {
|
|
|
3021
3036
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, pitch };
|
|
3022
3037
|
this.isCustomFilterActive();
|
|
3023
3038
|
await this.applyPlayerFilters();
|
|
3024
|
-
return this
|
|
3039
|
+
return this;
|
|
3025
3040
|
}
|
|
3026
3041
|
/**
|
|
3027
3042
|
* Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
3028
|
-
* @param
|
|
3029
|
-
* @returns
|
|
3043
|
+
* @param {number} rate set the rate of the filter
|
|
3044
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3045
|
+
*
|
|
3046
|
+
* @example
|
|
3047
|
+
* ```ts
|
|
3048
|
+
* // Set Rate to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
|
|
3049
|
+
* await player.filterManager.setRate(1.25);
|
|
3050
|
+
* ```
|
|
3030
3051
|
*/
|
|
3031
3052
|
async setRate(rate = 1) {
|
|
3032
3053
|
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)");
|
|
@@ -3036,12 +3057,21 @@ var FilterManager = class {
|
|
|
3036
3057
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, rate };
|
|
3037
3058
|
this.isCustomFilterActive();
|
|
3038
3059
|
await this.applyPlayerFilters();
|
|
3039
|
-
return this
|
|
3060
|
+
return this;
|
|
3040
3061
|
}
|
|
3041
3062
|
/**
|
|
3042
3063
|
* Enables / Disables the rotation effect, (Optional: provide your Own Data)
|
|
3043
|
-
* @param rotationHz
|
|
3044
|
-
* @returns
|
|
3064
|
+
* @param {number} rotationHz set the rotationHz of the filter
|
|
3065
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3066
|
+
*
|
|
3067
|
+
* @example
|
|
3068
|
+
* ```ts
|
|
3069
|
+
* // Toggle Rotation filter with custom settings
|
|
3070
|
+
* await player.filterManager.toggleRotation(0.4);
|
|
3071
|
+
* // or use the defaults
|
|
3072
|
+
* await player.filterManager.toggleRotation();
|
|
3073
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3074
|
+
* ```
|
|
3045
3075
|
*/
|
|
3046
3076
|
async toggleRotation(rotationHz = 0.2) {
|
|
3047
3077
|
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)");
|
|
@@ -3049,13 +3079,22 @@ var FilterManager = class {
|
|
|
3049
3079
|
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
3050
3080
|
this.filters.rotation = !this.filters.rotation;
|
|
3051
3081
|
await this.applyPlayerFilters();
|
|
3052
|
-
return this
|
|
3082
|
+
return this;
|
|
3053
3083
|
}
|
|
3054
3084
|
/**
|
|
3055
3085
|
* Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
|
|
3056
|
-
* @param frequency
|
|
3057
|
-
* @param depth
|
|
3058
|
-
* @returns
|
|
3086
|
+
* @param {number} frequency set the frequency of the filter
|
|
3087
|
+
* @param {number} depth set the depth of the filter
|
|
3088
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3089
|
+
*
|
|
3090
|
+
* @example
|
|
3091
|
+
* ```ts
|
|
3092
|
+
* // Toggle Vibrato filter with custom settings
|
|
3093
|
+
* await player.filterManager.toggleVibrato(8, 0.5);
|
|
3094
|
+
* // or use the defaults
|
|
3095
|
+
* await player.filterManager.toggleVibrato();
|
|
3096
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3097
|
+
* ```
|
|
3059
3098
|
*/
|
|
3060
3099
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3061
3100
|
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)");
|
|
@@ -3063,13 +3102,22 @@ var FilterManager = class {
|
|
|
3063
3102
|
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3064
3103
|
this.filters.vibrato = !this.filters.vibrato;
|
|
3065
3104
|
await this.applyPlayerFilters();
|
|
3066
|
-
return this
|
|
3105
|
+
return this;
|
|
3067
3106
|
}
|
|
3068
3107
|
/**
|
|
3069
3108
|
* Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
|
|
3070
|
-
* @param frequency
|
|
3071
|
-
* @param depth
|
|
3072
|
-
* @returns
|
|
3109
|
+
* @param {number} frequency set the frequency of the filter
|
|
3110
|
+
* @param {number} depth set the depth of the filter
|
|
3111
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3112
|
+
*
|
|
3113
|
+
* @example
|
|
3114
|
+
* ```ts
|
|
3115
|
+
* // Toggle Tremolo filter with custom settings
|
|
3116
|
+
* await player.filterManager.toggleTremolo(5, 0.7);
|
|
3117
|
+
* // or use the defaults
|
|
3118
|
+
* await player.filterManager.toggleTremolo();
|
|
3119
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3120
|
+
* ```
|
|
3073
3121
|
*/
|
|
3074
3122
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3075
3123
|
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)");
|
|
@@ -3077,12 +3125,21 @@ var FilterManager = class {
|
|
|
3077
3125
|
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3078
3126
|
this.filters.tremolo = !this.filters.tremolo;
|
|
3079
3127
|
await this.applyPlayerFilters();
|
|
3080
|
-
return this
|
|
3128
|
+
return this;
|
|
3081
3129
|
}
|
|
3082
3130
|
/**
|
|
3083
3131
|
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
3084
|
-
* @param smoothing
|
|
3085
|
-
* @returns
|
|
3132
|
+
* @param {number} smoothing set the smoothing of the filter
|
|
3133
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3134
|
+
*
|
|
3135
|
+
* @example
|
|
3136
|
+
* ```ts
|
|
3137
|
+
* // Toggle LowPass filter with custom settings
|
|
3138
|
+
* await player.filterManager.toggleLowPass(30);
|
|
3139
|
+
* // or use the defaults
|
|
3140
|
+
* await player.filterManager.toggleLowPass();
|
|
3141
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3142
|
+
* ```
|
|
3086
3143
|
*/
|
|
3087
3144
|
async toggleLowPass(smoothing = 20) {
|
|
3088
3145
|
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)");
|
|
@@ -3090,14 +3147,26 @@ var FilterManager = class {
|
|
|
3090
3147
|
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3091
3148
|
this.filters.lowPass = !this.filters.lowPass;
|
|
3092
3149
|
await this.applyPlayerFilters();
|
|
3093
|
-
return this
|
|
3150
|
+
return this;
|
|
3094
3151
|
}
|
|
3152
|
+
/**
|
|
3153
|
+
* Lavalink LavaDspx Plugin Filters
|
|
3154
|
+
*/
|
|
3095
3155
|
lavalinkLavaDspxPlugin = {
|
|
3096
3156
|
/**
|
|
3097
3157
|
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
3098
|
-
* @param boostFactor
|
|
3099
|
-
* @param cutoffFrequency
|
|
3100
|
-
* @returns
|
|
3158
|
+
* @param {number} boostFactor set the boost factor of the filter
|
|
3159
|
+
* @param {number} cutoffFrequency set the cutoff frequency of the filter
|
|
3160
|
+
* @returns {Promise<boolean>} the state of the filter after execution.
|
|
3161
|
+
*
|
|
3162
|
+
* @example
|
|
3163
|
+
* ```ts
|
|
3164
|
+
* // Toggle LowPass filter with custom settings
|
|
3165
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(1.2, 300);
|
|
3166
|
+
* // or use the defaults
|
|
3167
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass();
|
|
3168
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3169
|
+
* ```
|
|
3101
3170
|
*/
|
|
3102
3171
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3103
3172
|
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");
|
|
@@ -3108,13 +3177,22 @@ var FilterManager = class {
|
|
|
3108
3177
|
else this.data.pluginFilters["low-pass"] = { boostFactor, cutoffFrequency };
|
|
3109
3178
|
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
3110
3179
|
await this.applyPlayerFilters();
|
|
3111
|
-
return this
|
|
3180
|
+
return this;
|
|
3112
3181
|
},
|
|
3113
3182
|
/**
|
|
3114
3183
|
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
3115
|
-
* @param boostFactor
|
|
3116
|
-
* @param cutoffFrequency
|
|
3117
|
-
* @returns
|
|
3184
|
+
* @param {number} boostFactor [] set the boost factor of the filter
|
|
3185
|
+
* @param {number} cutoffFrequency set the cutoff frequency of the filter
|
|
3186
|
+
* @returns {Promise<boolean>} the state of the filter after execution.
|
|
3187
|
+
*
|
|
3188
|
+
* @example
|
|
3189
|
+
* ```ts
|
|
3190
|
+
* // Toggle HighPass filter with custom settings
|
|
3191
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass(1.2, 150); // custom values
|
|
3192
|
+
* // or use the defaults
|
|
3193
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass();
|
|
3194
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3195
|
+
* ```
|
|
3118
3196
|
*/
|
|
3119
3197
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3120
3198
|
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");
|
|
@@ -3125,13 +3203,22 @@ var FilterManager = class {
|
|
|
3125
3203
|
else this.data.pluginFilters["high-pass"] = { boostFactor, cutoffFrequency };
|
|
3126
3204
|
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
3127
3205
|
await this.applyPlayerFilters();
|
|
3128
|
-
return this
|
|
3206
|
+
return this;
|
|
3129
3207
|
},
|
|
3130
3208
|
/**
|
|
3131
3209
|
* Enables / Disables the Normalization effect.
|
|
3132
3210
|
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
3133
|
-
* @param {boolean} [adaptive=true]
|
|
3134
|
-
* @returns {Promise<
|
|
3211
|
+
* @param {boolean} [adaptive=true] Whether to use adaptive normalization or not.
|
|
3212
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3213
|
+
*
|
|
3214
|
+
* @example
|
|
3215
|
+
* ```ts
|
|
3216
|
+
* // Toggle Normalization filter with custom settings
|
|
3217
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization(0.9, false); // custom values
|
|
3218
|
+
* // or use the defaults
|
|
3219
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization();
|
|
3220
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3221
|
+
* ```
|
|
3135
3222
|
*/
|
|
3136
3223
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3137
3224
|
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");
|
|
@@ -3142,13 +3229,22 @@ var FilterManager = class {
|
|
|
3142
3229
|
else this.data.pluginFilters.normalization = { adaptive, maxAmplitude };
|
|
3143
3230
|
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
3144
3231
|
await this.applyPlayerFilters();
|
|
3145
|
-
return this
|
|
3232
|
+
return this;
|
|
3146
3233
|
},
|
|
3147
3234
|
/**
|
|
3148
3235
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3149
|
-
* @param {number} [decay=0.5]
|
|
3150
|
-
* @param {number} [echoLength=0.5]
|
|
3151
|
-
* @returns {Promise<
|
|
3236
|
+
* @param {number} [decay=0.5] The decay of the echo effect.
|
|
3237
|
+
* @param {number} [echoLength=0.5] The length of the echo effect.
|
|
3238
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3239
|
+
*
|
|
3240
|
+
* @example
|
|
3241
|
+
* ```ts
|
|
3242
|
+
* // Toggle Echo filter with custom settings
|
|
3243
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho(0.7, 0.6); // custom values
|
|
3244
|
+
* // or use the defaults
|
|
3245
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho();
|
|
3246
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3247
|
+
* ```
|
|
3152
3248
|
*/
|
|
3153
3249
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3154
3250
|
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");
|
|
@@ -3159,15 +3255,27 @@ var FilterManager = class {
|
|
|
3159
3255
|
else this.data.pluginFilters.echo = { decay, echoLength };
|
|
3160
3256
|
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
3161
3257
|
await this.applyPlayerFilters();
|
|
3162
|
-
return this
|
|
3258
|
+
return this;
|
|
3163
3259
|
}
|
|
3164
3260
|
};
|
|
3261
|
+
/**
|
|
3262
|
+
* LavalinkFilter Plugin specific Filters
|
|
3263
|
+
*/
|
|
3165
3264
|
lavalinkFilterPlugin = {
|
|
3166
3265
|
/**
|
|
3167
3266
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3168
|
-
* @param delay
|
|
3169
|
-
* @param decay
|
|
3170
|
-
* @returns
|
|
3267
|
+
* @param {number} delay set the delay of the echo
|
|
3268
|
+
* @param {number} decay set the decay of the echo
|
|
3269
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3270
|
+
*
|
|
3271
|
+
* @example
|
|
3272
|
+
* ```ts
|
|
3273
|
+
* // Toggle Echo filter with custom settings
|
|
3274
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleEcho(3, 0.7); // custom values
|
|
3275
|
+
* // or use the defaults
|
|
3276
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleEcho();
|
|
3277
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3278
|
+
* ```
|
|
3171
3279
|
*/
|
|
3172
3280
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3173
3281
|
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");
|
|
@@ -3183,13 +3291,22 @@ var FilterManager = class {
|
|
|
3183
3291
|
};
|
|
3184
3292
|
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
3185
3293
|
await this.applyPlayerFilters();
|
|
3186
|
-
return this
|
|
3294
|
+
return this;
|
|
3187
3295
|
},
|
|
3188
3296
|
/**
|
|
3189
3297
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3190
|
-
* @param delays
|
|
3191
|
-
* @param gains
|
|
3192
|
-
* @returns
|
|
3298
|
+
* @param {number} delays set the delays of the reverb
|
|
3299
|
+
* @param {number} gains set the gains of the reverb
|
|
3300
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3301
|
+
*
|
|
3302
|
+
* @example
|
|
3303
|
+
* ```ts
|
|
3304
|
+
* // Toggle Reverb filter with custom settings
|
|
3305
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleReverb([0.04, 0.045, 0.05, 0.055], [0.85, 0.84, 0.83, 0.82]);
|
|
3306
|
+
* // or use the defaults
|
|
3307
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleReverb();
|
|
3308
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3309
|
+
* ```
|
|
3193
3310
|
*/
|
|
3194
3311
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3195
3312
|
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");
|
|
@@ -3205,15 +3322,24 @@ var FilterManager = class {
|
|
|
3205
3322
|
};
|
|
3206
3323
|
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
3207
3324
|
await this.applyPlayerFilters();
|
|
3208
|
-
return this
|
|
3325
|
+
return this;
|
|
3209
3326
|
}
|
|
3210
3327
|
};
|
|
3211
3328
|
/**
|
|
3212
3329
|
* Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
|
|
3213
|
-
* @param speed
|
|
3214
|
-
* @param pitch
|
|
3215
|
-
* @param rate
|
|
3216
|
-
* @returns
|
|
3330
|
+
* @param {number} speed set the speed of the filter
|
|
3331
|
+
* @param {number} pitch set the pitch of the filter
|
|
3332
|
+
* @param {number} rate set the rate of the filter
|
|
3333
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3334
|
+
*
|
|
3335
|
+
* @example
|
|
3336
|
+
* ```ts
|
|
3337
|
+
* // Toggle Nightcore filter with custom settings
|
|
3338
|
+
* await player.filterManager.toggleNightcore(1.3, 1.3, 0.9);
|
|
3339
|
+
* // or use the defaults
|
|
3340
|
+
* await player.filterManager.toggleNightcore();
|
|
3341
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3342
|
+
* ```
|
|
3217
3343
|
*/
|
|
3218
3344
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3219
3345
|
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)");
|
|
@@ -3223,14 +3349,23 @@ var FilterManager = class {
|
|
|
3223
3349
|
this.filters.vaporwave = false;
|
|
3224
3350
|
this.filters.custom = false;
|
|
3225
3351
|
await this.applyPlayerFilters();
|
|
3226
|
-
return this
|
|
3352
|
+
return this;
|
|
3227
3353
|
}
|
|
3228
3354
|
/**
|
|
3229
3355
|
* Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
|
|
3230
|
-
* @param speed
|
|
3231
|
-
* @param pitch
|
|
3232
|
-
* @param rate
|
|
3233
|
-
* @returns
|
|
3356
|
+
* @param {number} speed set the speed of the filterq
|
|
3357
|
+
* @param {number} pitch set the pitch of the filter
|
|
3358
|
+
* @param {number} rate set the rate of the filter
|
|
3359
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3360
|
+
*
|
|
3361
|
+
* @example
|
|
3362
|
+
* ```ts
|
|
3363
|
+
* // Toggle Vaporwave filter with custom settings
|
|
3364
|
+
* await player.filterManager.toggleVaporwave(0.9, 0.7, 1);
|
|
3365
|
+
* // or use the defaults
|
|
3366
|
+
* await player.filterManager.toggleVaporwave();
|
|
3367
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3368
|
+
* ```
|
|
3234
3369
|
*/
|
|
3235
3370
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3236
3371
|
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)");
|
|
@@ -3240,15 +3375,24 @@ var FilterManager = class {
|
|
|
3240
3375
|
this.filters.nightcore = false;
|
|
3241
3376
|
this.filters.custom = false;
|
|
3242
3377
|
await this.applyPlayerFilters();
|
|
3243
|
-
return this
|
|
3378
|
+
return this;
|
|
3244
3379
|
}
|
|
3245
3380
|
/**
|
|
3246
3381
|
* Enable / Disables a Karaoke like Filter Effect
|
|
3247
|
-
* @param level
|
|
3248
|
-
* @param monoLevel
|
|
3249
|
-
* @param filterBand
|
|
3250
|
-
* @param filterWidth
|
|
3251
|
-
* @returns
|
|
3382
|
+
* @param {number} level set the level of the filter
|
|
3383
|
+
* @param {number} monoLevel set the mono level of the filter
|
|
3384
|
+
* @param {number} filterBand set the filter band of the filter
|
|
3385
|
+
* @param {number} filterWidth set the filter width of the filter
|
|
3386
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3387
|
+
*
|
|
3388
|
+
* @example
|
|
3389
|
+
* ```ts
|
|
3390
|
+
* // Toggle Karaoke filter with custom settings
|
|
3391
|
+
* await player.filterManager.toggleKaraoke(1.5, 1.0, 220, 100);
|
|
3392
|
+
* // or use the defaults
|
|
3393
|
+
* await player.filterManager.toggleKaraoke();
|
|
3394
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3395
|
+
* ```
|
|
3252
3396
|
*/
|
|
3253
3397
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3254
3398
|
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)");
|
|
@@ -3256,17 +3400,56 @@ var FilterManager = class {
|
|
|
3256
3400
|
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3257
3401
|
this.filters.karaoke = !this.filters.karaoke;
|
|
3258
3402
|
await this.applyPlayerFilters();
|
|
3259
|
-
return this
|
|
3403
|
+
return this;
|
|
3260
3404
|
}
|
|
3261
|
-
/**
|
|
3405
|
+
/**
|
|
3406
|
+
* Function to find out if currently there is a custom timescamle etc. filter applied
|
|
3407
|
+
* @returns {boolean} whether a custom filter is active
|
|
3408
|
+
*
|
|
3409
|
+
* @example
|
|
3410
|
+
* ```ts
|
|
3411
|
+
* // Check if a custom filter is active
|
|
3412
|
+
* const isCustom = player.filterManager.isCustomFilterActive();
|
|
3413
|
+
* console.log(`Is custom filter active? ${isCustom}`);
|
|
3414
|
+
* ```
|
|
3415
|
+
*/
|
|
3262
3416
|
isCustomFilterActive() {
|
|
3263
3417
|
this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some((d) => d !== 1);
|
|
3264
3418
|
return this.filters.custom;
|
|
3265
3419
|
}
|
|
3266
3420
|
/**
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3421
|
+
* Sets the players equalizer bands using one of the predefined presets.
|
|
3422
|
+
* @param {keyof typeof EQList} preset The preset to use.
|
|
3423
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3424
|
+
*
|
|
3425
|
+
* @example
|
|
3426
|
+
* ```ts
|
|
3427
|
+
* // Set EQ preset
|
|
3428
|
+
* await player.filterManager.setEQPreset('BassboostMedium');
|
|
3429
|
+
* ```
|
|
3430
|
+
*/
|
|
3431
|
+
async setEQPreset(preset) {
|
|
3432
|
+
const bands = EQList[preset];
|
|
3433
|
+
return this.setEQ(bands);
|
|
3434
|
+
}
|
|
3435
|
+
/**
|
|
3436
|
+
* Sets the players equalizer band on-top of the existing ones.
|
|
3437
|
+
* @param {number} bands
|
|
3438
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3439
|
+
*
|
|
3440
|
+
* @example
|
|
3441
|
+
* ```ts
|
|
3442
|
+
* // Set EQ bands
|
|
3443
|
+
* await player.filterManager.setEQ([
|
|
3444
|
+
* { band: 0, gain: 0.3 },
|
|
3445
|
+
* { band: 1, gain: -0.2 },
|
|
3446
|
+
* { band: 2, gain: 0.1 }
|
|
3447
|
+
* ]);
|
|
3448
|
+
*
|
|
3449
|
+
* // or use one of the templates:
|
|
3450
|
+
* await player.filterManager.setEQ(player.filterManager.EQList.BassboostMedium); // you can also import EQList from somewhere package if wanted.
|
|
3451
|
+
* ```
|
|
3452
|
+
*/
|
|
3270
3453
|
async setEQ(bands) {
|
|
3271
3454
|
if (!Array.isArray(bands)) bands = [bands];
|
|
3272
3455
|
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.");
|
|
@@ -3283,7 +3466,16 @@ var FilterManager = class {
|
|
|
3283
3466
|
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
3284
3467
|
return this;
|
|
3285
3468
|
}
|
|
3286
|
-
/**
|
|
3469
|
+
/**
|
|
3470
|
+
* Clears the equalizer bands.
|
|
3471
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3472
|
+
*
|
|
3473
|
+
* @example
|
|
3474
|
+
* ```ts
|
|
3475
|
+
* // Clear all EQ bands
|
|
3476
|
+
* await player.filterManager.clearEQ();
|
|
3477
|
+
* ```
|
|
3478
|
+
*/
|
|
3287
3479
|
async clearEQ() {
|
|
3288
3480
|
return this.setEQ(Array.from({ length: 15 }, (_v, i) => ({ band: i, gain: 0 })));
|
|
3289
3481
|
}
|