diff --git a/src/api/volume.ts b/src/api/volume.ts index 8f5eb9c..b2d54b5 100644 --- a/src/api/volume.ts +++ b/src/api/volume.ts @@ -5,10 +5,10 @@ import { ParsedMessage } from '../core/BotCommandParser'; const volume = async (cmd: ParsedMessage, msg: Message, bot: Bot): Promise => { if (cmd.arguments.length) { - const temp = cmd.arguments[0]; + const temp = cmd.arguments[0] ? parseFloat(cmd.arguments[0]) : null; if (temp) { - const vol = Math.min(Math.max(parseInt(temp, 10), 0), 100); + const vol = Math.min(Math.max(temp / 100, 0.1), 1); bot.player.setVolume(vol); } diff --git a/src/core/BotMediaPlayer.ts b/src/core/BotMediaPlayer.ts index 897b5c2..1f37540 100644 --- a/src/core/BotMediaPlayer.ts +++ b/src/core/BotMediaPlayer.ts @@ -200,15 +200,15 @@ class MediaPlayer { } public setVolume(volume: number): void { - this.config.stream.volume = Math.min(Math.max(volume / 100 + 0.5, 0.5), 2); + this.config.stream.volume = volume; if (this.dispatcher) { - this.dispatcher.setVolume(volume); + this.dispatcher.setVolumeLogarithmic(volume); } } public getVolume(): string { - return `${+(this.config.stream.volume - 0.5) * 100}%`; + return `${this.config.stream.volume * 100}%`; } public remove(item: MediaItem): void {