diff options
| author | Nathan Perry <avaglir@gmail.com> | 2018-04-30 04:03:33 -0400 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2018-04-30 04:03:33 -0400 |
| commit | 9f3a555c2801c00a78e8380d8acc3d5931972335 (patch) | |
| tree | 836b52f30514b56d7cc18fd0f4d2cb547291d7cf | |
| parent | 8b9da75019ecb72aa2b9c3d05ff890e96a61fae9 (diff) | |
update volume command0.1.2
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/commands/mod.rs | 4 | ||||
| -rw-r--r-- | src/commands/sound.rs | 5 |
4 files changed, 8 insertions, 5 deletions
@@ -1409,7 +1409,7 @@ dependencies = [ [[package]] name = "thulani" -version = "0.1.1" +version = "0.1.2" dependencies = [ "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1,6 +1,6 @@ [package] name = "thulani" -version = "0.1.1" +version = "0.1.2" authors = ["Nathan Perry <avaglir@gmail.com>"] [features] diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 19615de..542d649 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -87,8 +87,8 @@ fn register_db(f: StandardFramework) -> StandardFramework { f } -fn send(channel: ChannelId, text: &str, tts: bool) -> Result<()> { - channel.send_message(|m| m.content(text).tts(tts))?; +fn send<A: AsRef<str>>(channel: ChannelId, text: A, tts: bool) -> Result<()> { + channel.send_message(|m| m.content(text.as_ref()).tts(tts))?; Ok(()) } diff --git a/src/commands/sound.rs b/src/commands/sound.rs index bfdab78..3085d39 100644 --- a/src/commands/sound.rs +++ b/src/commands/sound.rs @@ -46,7 +46,7 @@ pub fn volume(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> { (play_queue.volume / DEFAULT_VOLUME * 100.0) as usize }; - return send(msg.channel_id, &format!("Volume: {}/100", vol), msg.tts); + return send(msg.channel_id, &format!("volume: {}%", vol), msg.tts); } let vol: usize = match args.single::<f32>() { @@ -56,6 +56,7 @@ 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 { "" }; if vol > 3.0 { vol = 3.0; @@ -72,6 +73,8 @@ pub fn volume(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> { play_queue.volume = vol * DEFAULT_VOLUME; } + send(msg.channel_id, format!("volume adjusted{}", adjusted_text), msg.tts)?; + { let play_queue = queue_lock.read().unwrap(); |
