lavalink-client 2.6.4 → 2.6.6
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/README.md +1 -0
- package/dist/index.d.mts +338 -80
- package/dist/index.d.ts +338 -80
- package/dist/index.js +321 -149
- package/dist/index.mjs +321 -149
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -677,12 +677,12 @@ var ManagerUtils = class {
|
|
|
677
677
|
* This check is not done automatically, you need to check it yourself by doing:
|
|
678
678
|
* @example
|
|
679
679
|
* ```ts
|
|
680
|
-
* const
|
|
680
|
+
* const res = await player.search("Adele");
|
|
681
681
|
*
|
|
682
682
|
* // short hand:
|
|
683
|
-
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
683
|
+
* const validTracks = res.tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
684
684
|
* // or with options:
|
|
685
|
-
* const
|
|
685
|
+
* const validTracks = res.tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
686
686
|
*
|
|
687
687
|
* // then you can add it to the queue.
|
|
688
688
|
* await player.queue.add(validTracks);
|
|
@@ -2795,6 +2795,7 @@ var DEFAULT_FILTER_DATAS = {
|
|
|
2795
2795
|
}*/
|
|
2796
2796
|
};
|
|
2797
2797
|
var FilterManager = class {
|
|
2798
|
+
static EQList = EQList;
|
|
2798
2799
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
2799
2800
|
equalizerBands = [];
|
|
2800
2801
|
/** Private Util for the instaFix Filters option */
|
|
@@ -2832,6 +2833,17 @@ var FilterManager = class {
|
|
|
2832
2833
|
}
|
|
2833
2834
|
/**
|
|
2834
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
|
+
* ```
|
|
2835
2847
|
*/
|
|
2836
2848
|
async applyPlayerFilters() {
|
|
2837
2849
|
const sendData = { ...this.data };
|
|
@@ -2871,9 +2883,17 @@ var FilterManager = class {
|
|
|
2871
2883
|
return;
|
|
2872
2884
|
}
|
|
2873
2885
|
/**
|
|
2874
|
-
* Checks if the filters are correctly stated (active / not-active)
|
|
2886
|
+
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
2875
2887
|
* @param oldFilterTimescale
|
|
2876
|
-
* @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
|
+
* ```
|
|
2877
2897
|
*/
|
|
2878
2898
|
checkFiltersState(oldFilterTimescale) {
|
|
2879
2899
|
this.filters.rotation = this.data.rotation.rotationHz !== 0;
|
|
@@ -2899,6 +2919,13 @@ var FilterManager = class {
|
|
|
2899
2919
|
}
|
|
2900
2920
|
/**
|
|
2901
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
|
+
* ```
|
|
2902
2929
|
*/
|
|
2903
2930
|
async resetFilters() {
|
|
2904
2931
|
this.filters.lavalinkLavaDspxPlugin.echo = false;
|
|
@@ -2916,83 +2943,21 @@ var FilterManager = class {
|
|
|
2916
2943
|
this.filters.karaoke = false;
|
|
2917
2944
|
this.filters.volume = false;
|
|
2918
2945
|
this.filters.audioOutput = "stereo";
|
|
2919
|
-
|
|
2920
|
-
volume: 1,
|
|
2921
|
-
lowPass: {
|
|
2922
|
-
smoothing: 0
|
|
2923
|
-
},
|
|
2924
|
-
karaoke: {
|
|
2925
|
-
level: 0,
|
|
2926
|
-
monoLevel: 0,
|
|
2927
|
-
filterBand: 0,
|
|
2928
|
-
filterWidth: 0
|
|
2929
|
-
},
|
|
2930
|
-
timescale: {
|
|
2931
|
-
speed: 1,
|
|
2932
|
-
// 0 = x
|
|
2933
|
-
pitch: 1,
|
|
2934
|
-
// 0 = x
|
|
2935
|
-
rate: 1
|
|
2936
|
-
// 0 = x
|
|
2937
|
-
},
|
|
2938
|
-
pluginFilters: {
|
|
2939
|
-
"lavalink-filter-plugin": {
|
|
2940
|
-
echo: {
|
|
2941
|
-
// delay: 0, // in seconds
|
|
2942
|
-
// decay: 0 // 0 < 1
|
|
2943
|
-
},
|
|
2944
|
-
reverb: {
|
|
2945
|
-
// delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
2946
|
-
// gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
2947
|
-
}
|
|
2948
|
-
},
|
|
2949
|
-
"high-pass": {
|
|
2950
|
-
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2951
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2952
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2953
|
-
},
|
|
2954
|
-
"low-pass": {
|
|
2955
|
-
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2956
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2957
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2958
|
-
},
|
|
2959
|
-
"normalization": {
|
|
2960
|
-
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2961
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2962
|
-
// "adaptive": true // false
|
|
2963
|
-
},
|
|
2964
|
-
"echo": {
|
|
2965
|
-
// Self-explanatory; provides an echo effect.
|
|
2966
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2967
|
-
// "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
|
|
2968
|
-
}
|
|
2969
|
-
},
|
|
2970
|
-
rotation: {
|
|
2971
|
-
rotationHz: 0
|
|
2972
|
-
},
|
|
2973
|
-
tremolo: {
|
|
2974
|
-
frequency: 0,
|
|
2975
|
-
// 0 < x
|
|
2976
|
-
depth: 0
|
|
2977
|
-
// 0 < x = 1
|
|
2978
|
-
},
|
|
2979
|
-
vibrato: {
|
|
2980
|
-
frequency: 0,
|
|
2981
|
-
// 0 < x = 14
|
|
2982
|
-
depth: 0
|
|
2983
|
-
// 0 < x = 1
|
|
2984
|
-
},
|
|
2985
|
-
channelMix: audioOutputsData.stereo
|
|
2986
|
-
})) {
|
|
2987
|
-
this.data[key] = value;
|
|
2988
|
-
}
|
|
2946
|
+
this.data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2989
2947
|
await this.applyPlayerFilters();
|
|
2990
|
-
return this
|
|
2948
|
+
return this;
|
|
2991
2949
|
}
|
|
2992
2950
|
/**
|
|
2993
2951
|
* Set the Filter Volume
|
|
2994
|
-
* @param volume
|
|
2995
|
-
* @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
|
+
* ```
|
|
2996
2961
|
*/
|
|
2997
2962
|
async setVolume(volume) {
|
|
2998
2963
|
if (volume < 0 || volume > 5) throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
@@ -3000,12 +2965,27 @@ var FilterManager = class {
|
|
|
3000
2965
|
this.data.volume = volume;
|
|
3001
2966
|
this.filters.volume = volume !== 1;
|
|
3002
2967
|
await this.applyPlayerFilters();
|
|
3003
|
-
return this
|
|
2968
|
+
return this;
|
|
3004
2969
|
}
|
|
3005
2970
|
/**
|
|
3006
2971
|
* Set the AudioOutput Filter
|
|
3007
|
-
* @param type
|
|
3008
|
-
* @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
|
+
* ```
|
|
3009
2989
|
*/
|
|
3010
2990
|
async setAudioOutput(type) {
|
|
3011
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)");
|
|
@@ -3014,12 +2994,18 @@ var FilterManager = class {
|
|
|
3014
2994
|
this.data.channelMix = audioOutputsData[type];
|
|
3015
2995
|
this.filters.audioOutput = type;
|
|
3016
2996
|
await this.applyPlayerFilters();
|
|
3017
|
-
return this
|
|
2997
|
+
return this;
|
|
3018
2998
|
}
|
|
3019
2999
|
/**
|
|
3020
3000
|
* Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
3021
|
-
* @param speed
|
|
3022
|
-
* @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
|
+
* ```
|
|
3023
3009
|
*/
|
|
3024
3010
|
async setSpeed(speed = 1) {
|
|
3025
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)");
|
|
@@ -3029,12 +3015,18 @@ var FilterManager = class {
|
|
|
3029
3015
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, speed };
|
|
3030
3016
|
this.isCustomFilterActive();
|
|
3031
3017
|
await this.applyPlayerFilters();
|
|
3032
|
-
return this
|
|
3018
|
+
return this;
|
|
3033
3019
|
}
|
|
3034
3020
|
/**
|
|
3035
3021
|
* Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
3036
|
-
* @param
|
|
3037
|
-
* @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
|
+
* ```
|
|
3038
3030
|
*/
|
|
3039
3031
|
async setPitch(pitch = 1) {
|
|
3040
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)");
|
|
@@ -3044,12 +3036,18 @@ var FilterManager = class {
|
|
|
3044
3036
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, pitch };
|
|
3045
3037
|
this.isCustomFilterActive();
|
|
3046
3038
|
await this.applyPlayerFilters();
|
|
3047
|
-
return this
|
|
3039
|
+
return this;
|
|
3048
3040
|
}
|
|
3049
3041
|
/**
|
|
3050
3042
|
* Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
3051
|
-
* @param
|
|
3052
|
-
* @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
|
+
* ```
|
|
3053
3051
|
*/
|
|
3054
3052
|
async setRate(rate = 1) {
|
|
3055
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)");
|
|
@@ -3059,12 +3057,21 @@ var FilterManager = class {
|
|
|
3059
3057
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, rate };
|
|
3060
3058
|
this.isCustomFilterActive();
|
|
3061
3059
|
await this.applyPlayerFilters();
|
|
3062
|
-
return this
|
|
3060
|
+
return this;
|
|
3063
3061
|
}
|
|
3064
3062
|
/**
|
|
3065
3063
|
* Enables / Disables the rotation effect, (Optional: provide your Own Data)
|
|
3066
|
-
* @param rotationHz
|
|
3067
|
-
* @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
|
+
* ```
|
|
3068
3075
|
*/
|
|
3069
3076
|
async toggleRotation(rotationHz = 0.2) {
|
|
3070
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)");
|
|
@@ -3072,13 +3079,22 @@ var FilterManager = class {
|
|
|
3072
3079
|
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
3073
3080
|
this.filters.rotation = !this.filters.rotation;
|
|
3074
3081
|
await this.applyPlayerFilters();
|
|
3075
|
-
return this
|
|
3082
|
+
return this;
|
|
3076
3083
|
}
|
|
3077
3084
|
/**
|
|
3078
3085
|
* Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
|
|
3079
|
-
* @param frequency
|
|
3080
|
-
* @param depth
|
|
3081
|
-
* @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
|
+
* ```
|
|
3082
3098
|
*/
|
|
3083
3099
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3084
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)");
|
|
@@ -3086,13 +3102,22 @@ var FilterManager = class {
|
|
|
3086
3102
|
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3087
3103
|
this.filters.vibrato = !this.filters.vibrato;
|
|
3088
3104
|
await this.applyPlayerFilters();
|
|
3089
|
-
return this
|
|
3105
|
+
return this;
|
|
3090
3106
|
}
|
|
3091
3107
|
/**
|
|
3092
3108
|
* Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
|
|
3093
|
-
* @param frequency
|
|
3094
|
-
* @param depth
|
|
3095
|
-
* @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
|
+
* ```
|
|
3096
3121
|
*/
|
|
3097
3122
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3098
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)");
|
|
@@ -3100,12 +3125,21 @@ var FilterManager = class {
|
|
|
3100
3125
|
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3101
3126
|
this.filters.tremolo = !this.filters.tremolo;
|
|
3102
3127
|
await this.applyPlayerFilters();
|
|
3103
|
-
return this
|
|
3128
|
+
return this;
|
|
3104
3129
|
}
|
|
3105
3130
|
/**
|
|
3106
3131
|
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
3107
|
-
* @param smoothing
|
|
3108
|
-
* @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
|
+
* ```
|
|
3109
3143
|
*/
|
|
3110
3144
|
async toggleLowPass(smoothing = 20) {
|
|
3111
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)");
|
|
@@ -3113,14 +3147,26 @@ var FilterManager = class {
|
|
|
3113
3147
|
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3114
3148
|
this.filters.lowPass = !this.filters.lowPass;
|
|
3115
3149
|
await this.applyPlayerFilters();
|
|
3116
|
-
return this
|
|
3150
|
+
return this;
|
|
3117
3151
|
}
|
|
3152
|
+
/**
|
|
3153
|
+
* Lavalink LavaDspx Plugin Filters
|
|
3154
|
+
*/
|
|
3118
3155
|
lavalinkLavaDspxPlugin = {
|
|
3119
3156
|
/**
|
|
3120
3157
|
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
3121
|
-
* @param boostFactor
|
|
3122
|
-
* @param cutoffFrequency
|
|
3123
|
-
* @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
|
+
* ```
|
|
3124
3170
|
*/
|
|
3125
3171
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3126
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");
|
|
@@ -3131,13 +3177,22 @@ var FilterManager = class {
|
|
|
3131
3177
|
else this.data.pluginFilters["low-pass"] = { boostFactor, cutoffFrequency };
|
|
3132
3178
|
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
3133
3179
|
await this.applyPlayerFilters();
|
|
3134
|
-
return this
|
|
3180
|
+
return this;
|
|
3135
3181
|
},
|
|
3136
3182
|
/**
|
|
3137
3183
|
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
3138
|
-
* @param boostFactor
|
|
3139
|
-
* @param cutoffFrequency
|
|
3140
|
-
* @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
|
+
* ```
|
|
3141
3196
|
*/
|
|
3142
3197
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3143
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");
|
|
@@ -3148,13 +3203,22 @@ var FilterManager = class {
|
|
|
3148
3203
|
else this.data.pluginFilters["high-pass"] = { boostFactor, cutoffFrequency };
|
|
3149
3204
|
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
3150
3205
|
await this.applyPlayerFilters();
|
|
3151
|
-
return this
|
|
3206
|
+
return this;
|
|
3152
3207
|
},
|
|
3153
3208
|
/**
|
|
3154
3209
|
* Enables / Disables the Normalization effect.
|
|
3155
3210
|
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
3156
|
-
* @param {boolean} [adaptive=true]
|
|
3157
|
-
* @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
|
+
* ```
|
|
3158
3222
|
*/
|
|
3159
3223
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3160
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");
|
|
@@ -3165,13 +3229,22 @@ var FilterManager = class {
|
|
|
3165
3229
|
else this.data.pluginFilters.normalization = { adaptive, maxAmplitude };
|
|
3166
3230
|
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
3167
3231
|
await this.applyPlayerFilters();
|
|
3168
|
-
return this
|
|
3232
|
+
return this;
|
|
3169
3233
|
},
|
|
3170
3234
|
/**
|
|
3171
3235
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3172
|
-
* @param {number} [decay=0.5]
|
|
3173
|
-
* @param {number} [echoLength=0.5]
|
|
3174
|
-
* @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
|
+
* ```
|
|
3175
3248
|
*/
|
|
3176
3249
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3177
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");
|
|
@@ -3182,15 +3255,27 @@ var FilterManager = class {
|
|
|
3182
3255
|
else this.data.pluginFilters.echo = { decay, echoLength };
|
|
3183
3256
|
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
3184
3257
|
await this.applyPlayerFilters();
|
|
3185
|
-
return this
|
|
3258
|
+
return this;
|
|
3186
3259
|
}
|
|
3187
3260
|
};
|
|
3261
|
+
/**
|
|
3262
|
+
* LavalinkFilter Plugin specific Filters
|
|
3263
|
+
*/
|
|
3188
3264
|
lavalinkFilterPlugin = {
|
|
3189
3265
|
/**
|
|
3190
3266
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3191
|
-
* @param delay
|
|
3192
|
-
* @param decay
|
|
3193
|
-
* @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
|
+
* ```
|
|
3194
3279
|
*/
|
|
3195
3280
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3196
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");
|
|
@@ -3206,13 +3291,22 @@ var FilterManager = class {
|
|
|
3206
3291
|
};
|
|
3207
3292
|
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
3208
3293
|
await this.applyPlayerFilters();
|
|
3209
|
-
return this
|
|
3294
|
+
return this;
|
|
3210
3295
|
},
|
|
3211
3296
|
/**
|
|
3212
3297
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3213
|
-
* @param delays
|
|
3214
|
-
* @param gains
|
|
3215
|
-
* @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
|
+
* ```
|
|
3216
3310
|
*/
|
|
3217
3311
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3218
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");
|
|
@@ -3228,15 +3322,24 @@ var FilterManager = class {
|
|
|
3228
3322
|
};
|
|
3229
3323
|
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
3230
3324
|
await this.applyPlayerFilters();
|
|
3231
|
-
return this
|
|
3325
|
+
return this;
|
|
3232
3326
|
}
|
|
3233
3327
|
};
|
|
3234
3328
|
/**
|
|
3235
3329
|
* Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
|
|
3236
|
-
* @param speed
|
|
3237
|
-
* @param pitch
|
|
3238
|
-
* @param rate
|
|
3239
|
-
* @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
|
+
* ```
|
|
3240
3343
|
*/
|
|
3241
3344
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3242
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)");
|
|
@@ -3246,14 +3349,23 @@ var FilterManager = class {
|
|
|
3246
3349
|
this.filters.vaporwave = false;
|
|
3247
3350
|
this.filters.custom = false;
|
|
3248
3351
|
await this.applyPlayerFilters();
|
|
3249
|
-
return this
|
|
3352
|
+
return this;
|
|
3250
3353
|
}
|
|
3251
3354
|
/**
|
|
3252
3355
|
* Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
|
|
3253
|
-
* @param speed
|
|
3254
|
-
* @param pitch
|
|
3255
|
-
* @param rate
|
|
3256
|
-
* @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
|
+
* ```
|
|
3257
3369
|
*/
|
|
3258
3370
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3259
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)");
|
|
@@ -3263,15 +3375,24 @@ var FilterManager = class {
|
|
|
3263
3375
|
this.filters.nightcore = false;
|
|
3264
3376
|
this.filters.custom = false;
|
|
3265
3377
|
await this.applyPlayerFilters();
|
|
3266
|
-
return this
|
|
3378
|
+
return this;
|
|
3267
3379
|
}
|
|
3268
3380
|
/**
|
|
3269
3381
|
* Enable / Disables a Karaoke like Filter Effect
|
|
3270
|
-
* @param level
|
|
3271
|
-
* @param monoLevel
|
|
3272
|
-
* @param filterBand
|
|
3273
|
-
* @param filterWidth
|
|
3274
|
-
* @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
|
+
* ```
|
|
3275
3396
|
*/
|
|
3276
3397
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3277
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)");
|
|
@@ -3279,17 +3400,56 @@ var FilterManager = class {
|
|
|
3279
3400
|
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3280
3401
|
this.filters.karaoke = !this.filters.karaoke;
|
|
3281
3402
|
await this.applyPlayerFilters();
|
|
3282
|
-
return this
|
|
3403
|
+
return this;
|
|
3283
3404
|
}
|
|
3284
|
-
/**
|
|
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
|
+
*/
|
|
3285
3416
|
isCustomFilterActive() {
|
|
3286
3417
|
this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some((d) => d !== 1);
|
|
3287
3418
|
return this.filters.custom;
|
|
3288
3419
|
}
|
|
3289
3420
|
/**
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
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
|
+
*/
|
|
3293
3453
|
async setEQ(bands) {
|
|
3294
3454
|
if (!Array.isArray(bands)) bands = [bands];
|
|
3295
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.");
|
|
@@ -3306,7 +3466,16 @@ var FilterManager = class {
|
|
|
3306
3466
|
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
3307
3467
|
return this;
|
|
3308
3468
|
}
|
|
3309
|
-
/**
|
|
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
|
+
*/
|
|
3310
3479
|
async clearEQ() {
|
|
3311
3480
|
return this.setEQ(Array.from({ length: 15 }, (_v, i) => ({ band: i, gain: 0 })));
|
|
3312
3481
|
}
|
|
@@ -3595,6 +3764,9 @@ var Queue = class {
|
|
|
3595
3764
|
* ```
|
|
3596
3765
|
*/
|
|
3597
3766
|
async remove(removeQueryTrack) {
|
|
3767
|
+
if (removeQueryTrack === null || removeQueryTrack === void 0 || Array.isArray(removeQueryTrack) && removeQueryTrack.length === 0) {
|
|
3768
|
+
return null;
|
|
3769
|
+
}
|
|
3598
3770
|
const oldStored = typeof this.queueChanges?.tracksRemoved === "function" ? this.utils.toJSON() : null;
|
|
3599
3771
|
if (typeof removeQueryTrack === "number") {
|
|
3600
3772
|
const toRemove2 = this.tracks[removeQueryTrack];
|