diff --git a/src/main.rs b/src/main.rs index 348fb8a0e8a332afdb2d6e685171ff9f31a7b685..89d412c7002f3981cf97729488eb2b135b9cafb2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,8 +74,7 @@ impl EventHandler for Handler { } _ => {} } - } - if msg.content.starts_with("!move") { + } else if msg.content.starts_with("!move") { let mut iter = msg.content.chars(); iter.by_ref().nth(5); let topic = iter.as_str(); @@ -93,8 +92,7 @@ impl EventHandler for Handler { if let Err(why) = msg.channel_id.say(&ctx.http, "I hope you're not having a motion. You may have wanted to !move something instead.") { println!("Error sending message: {:?}", why); } - } - if msg.content.starts_with("!poll") { + } else if msg.content.starts_with("!poll") { let mut iter = msg.content.chars(); iter.by_ref().nth(5); let topic = iter.as_str(); @@ -163,11 +161,13 @@ impl EventHandler for Handler { println!("Error deleting motion prompt: {:?}", why); } } else if msg.content.starts_with("!cowsay") { - let mut iter = msg.content.chars(); - iter.by_ref().nth(7); - let text = iter.as_str(); + let mut text = msg.content.split_at(7).1.to_owned(); + text.escape_default(); + // Guess what buddy! You definitely are passing a string to cowsay + text.insert(0, '\''); + text.insert(text.len(), '\''); let output = std::process::Command::new("cowsay") - .arg(text.escape_default()) + .arg(text) .output() .expect("failed to execute cowsay"); let mut message = MessageBuilder::new();