Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
devianllert committed Aug 31, 2019
2 parents db82fca + 5347714 commit 74b01a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { ParsedMessage } from '../core/BotCommandParser';

const volume = async (cmd: ParsedMessage, msg: Message, bot: Bot): Promise<void> => {
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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/BotMediaPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 74b01a8

Please sign in to comment.