Skip to content

Commit

Permalink
Merge pull request #21 from Jadiction/patch-1
Browse files Browse the repository at this point in the history
fix(Filters): Fix player volume
  • Loading branch information
hmes98318 authored Nov 16, 2024
2 parents ce7d723 + 4ada58c commit 6843107
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib/Filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ export default class Filters {
if (typeof vol !== 'number') throw new TypeError('Volume must be an number.');
if (vol < 0 || vol > 500) throw new TypeError('Volume must be an number between 0 and 500.');

this.options.volume = vol;

this.player.node?.rest.updatePlayer(this.player.guildId, { volume: vol });

return this;
}

/** Sets all filters */
public set(filters: FilterOptions): void {
this.options = {};
this.options = this.options.volume ? { volume: this.options.volume } : {};

for (const [filter, config] of Object.entries(filters)) {
if (!['channelMix', 'distortion', 'equalizer', 'karaoke', 'lowPass', 'rotation', 'timescale', 'tremolo', 'vibrato'].includes(filter)) {
Expand All @@ -244,8 +246,11 @@ export default class Filters {
/** Sends filters payload to Lavalink Node */
public apply(): void {
const payload = this.options;
if('volume' in payload) {
delete payload.volume;
}
if (this.options.equalizer) { Object.assign(payload, { equalizer: this.options.equalizer.map((gain, band) => ({ band, gain })) }); }

this.player.node?.rest.updatePlayer(this.player.guildId, { filters: this.options });
this.player.node?.rest.updatePlayer(this.player.guildId, { filters: payload });
}
}
}

0 comments on commit 6843107

Please sign in to comment.