Classes

FilterManager

Class representing a filter manager for a player. A filter is active when its key is present in the payload, and inactive when it is absent: there is no neutral "off" payload. {@link FilterManager.set} writes a key, {@link FilterManager.clear} removes it, and {@link FilterManager.isEnabled} is presence. {@link FilterRegistry} routes the filters it knows to their envelope (top level, flat `pluginFilters`, or nested under a plugin) and validates them against the node. Filters it does not know can still be set: their envelope comes from {@link SetFilterOptions} instead, so no registration is required. The commit/envelope internals live in {@link FilterPayload } (util/functions/filters), which takes the manager as an argument rather than through `this` — no private members, matching the project convention.

Signature

export declare class FilterManager

JSDoc

@classFilterManager

Properties

readonly player: PlayerStructure;

The player this filter manager belongs to.

@type{PlayerStructure}@public@readonly
readonly bands: EQBandSettings[];

The bands applied to the player. Kept in sync with `data.equalizer`.

@type{EQBandSettings[]}@readonly
data: FilterSettings;

The current filter payload (wire-bound). Starts empty: a key is only present while its filter is active. Mutated by {@link FilterManager.set} and {@link FilterManager.clear}.

@type{FilterSettings}@public
readonly plugin: LavalinkPluginFilter;

Thin facade for filters provided by the `lavalink-filter-plugin`.

@type{LavalinkPluginFilter}@readonly
readonly dspx: DSPXPluginFilter;

Thin facade for filters provided by the `lavadspx-plugin`.

@type{DSPXPluginFilter}@readonly

Methods

set<K extends RegistryFilterName>(name: K, payload: PayloadOf<K>, options?: SetFilterOptions): Promise<this>;

Set a filter to `payload` and commit. Any filter can be set, registered or not: {@link SetFilterOptions} decides the envelope when the registry does not know the name (or when you want to override what it resolved). Idempotent — calling repeatedly with the same payload yields the same wire state. The payload is checked against {@link FilterPayloads} for the built-ins and against {@link CustomizableFilters} for anything you declared; a name neither knows takes `unknown`.

Parameters

name
The filter name (or alias) to set.
payload
The payload to write.
options
Envelope and validation options.

Returns

A promise that resolves to the filter manager.

Examples

await player.filterManager.set(FilterType.Echo, { decay: 0.5, delay: 200 }); // registry routes it
await player.filterManager.set("myFilter", { gain: 2 });                     // pluginFilters.myFilter
await player.filterManager.set("boost", { gain: 2 }, { plugin: "my-plugin" }); // nested
await player.filterManager.set("forkEcho", { decay: 0.5 }, { top: true });   // top level
@throws{PlayerError} If `plugin` and `top` are combined, or if validation was requested for a filter the node does not advertise.@throws{NodeError} If a registered filter is not supported by the node (unless `validate: false`).
apply(): Promise<this>;apply<K extends RegistryFilterName>(name: K, payload: PayloadOf<K>): Promise<this>;

Commit the current filter payload to the node. Set the given filter to `payload` and commit.

Deprecated

Use {@link FilterManager.set } instead, which also takes {@link SetFilterOptions } .

Parameters

name
The canonical filter name (or alias) to set.
payload
The payload to write into the envelope chosen by the registry.

Returns

A promise that resolves to the filter manager.

A promise that resolves to the filter manager.

clear(name: RegistryFilterName, options?: SetFilterOptions): Promise<this>;

Remove the given filter from the payload and commit. Pass the same {@link SetFilterOptions} routing used to set it, so an unregistered filter is cleared from the envelope it was written to.

Parameters

name
The filter name (or alias) to clear.
options
The routing options used when it was set.

Returns

A promise that resolves to the filter manager.

Examples

await player.filterManager.clear(FilterType.Karaoke);
await player.filterManager.clear("boost", { plugin: "my-plugin" });
get<K extends RegistryFilterName>(name: K, options?: SetFilterOptions): PayloadOf<K> | undefined;

Read the payload a filter is currently set to. Typed the same way {@link FilterManager.set} is, so there is no need to reach into {@link FilterManager.data} and narrow by hand.

Parameters

name
The filter name (or alias).
options
The routing options used when it was set.

Returns

The payload, or `undefined` when the filter is not active.

Examples

const timescale = player.filterManager.get(FilterType.Timescale); // TimescaleSettings | undefined
const boost = player.filterManager.get("boost", { plugin: "my-plugin" });
isEnabled(name: RegistryFilterName, options?: SetFilterOptions): boolean;

Whether the given filter is currently active, i.e. whether its key is present in the payload.

Parameters

name
The filter name (or alias).
options
The routing options used when it was set.

Returns

True if the filter has a payload, false otherwise.

getEnabled(): string[];

Returns every active filter name as derived from the current payload. Only covers registered filters; keys written for unregistered ones are not listed.

Returns

Canonical filter names present in the payload.

has(filter: RegistryFilterName, options?: SetFilterOptions): boolean;

Backward-compatible alias for {@link isEnabled}.

Parameters

filter
The filter to check.
options
The routing options used when it was set.

Returns

True if active.

reset(): Promise<this>;

Drop every filter and commit an empty payload.

Returns

A promise that resolves to the filter manager.

toJSON(): FilterSettings;

Serialise the current filter payload.

Returns

A deep clone of the wire payload (a snapshot; mutating it never touches live state).

setVolume(volume: number): Promise<this>;

Set the volume.

Parameters

volume
Volume between 0 and 5.
clearEQBands(): Promise<this>;

Clear every equalizer band.

setSpeed(speed?: number): Promise<this>;

Adjust timescale speed only.

setRate(rate?: number): Promise<this>;

Adjust timescale rate only.

setPitch(pitch?: number): Promise<this>;

Adjust timescale pitch only.

isNightcore(): boolean;

Whether the timescale currently matches the Nightcore preset exactly.

isVaporwave(): boolean;

Whether the timescale currently matches the Vaporwave preset exactly.

isCustomTimescale(): boolean;

Whether the timescale represents any non-default playback rate that is neither Nightcore nor Vaporwave.