aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands/sound_levels.rs15
-rw-r--r--src/main.rs1
2 files changed, 7 insertions, 9 deletions
diff --git a/src/commands/sound_levels.rs b/src/commands/sound_levels.rs
index ab98806..d913d06 100644
--- a/src/commands/sound_levels.rs
+++ b/src/commands/sound_levels.rs
@@ -20,7 +20,8 @@ use crate::{
util::CtxExt,
};
-pub const DEFAULT_VOLUME: f32 = 0.10;
+pub const DEFAULT_VOLUME: f32 = 0.20;
+const MAX_VOLUME: f32 = 5.0;
#[command]
pub fn mute(ctx: &mut Context, _: &Message, _: Args) -> Result<()> {
@@ -86,15 +87,11 @@ pub fn volume(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> {
};
let mut vol: f32 = (vol as f32)/100.0; // force aliasing to reasonable values
- let adjusted_text = if vol > 3.0 { " (300% max)" } else { "" };
+ let adjusted_text = if vol > MAX_VOLUME {
+ format!(" ({:.0}% max)", MAX_VOLUME * 100.0)
+ } else { "".to_owned() };
- if vol > 3.0 {
- vol = 3.0;
- }
-
- if vol < 0.0 {
- vol = 0.0;
- }
+ vol = vol.clamp(0.0, MAX_VOLUME);
let queue_lock = ctx.data.write().get::<PlayQueue>().cloned().unwrap();
diff --git a/src/main.rs b/src/main.rs
index 55205ba..6888f5f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@
#![feature(pattern)]
#![feature(concat_idents)]
#![feature(associated_type_defaults)]
+#![feature(clamp)]
#![feature(box_syntax, box_patterns)]