diff --git a/Cargo.lock b/Cargo.lock index 4c6c5f1..e747e11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "wynnrobot" -version = "0.11.0" +version = "0.11.1" dependencies = [ "configure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "diesel 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 553083f..d8c1353 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Sakuhl <2012collector@gmail.com>"] name = "wynnrobot" -version = "0.11.0" +version = "0.11.1" [dependencies] configure = "0.1.1" diff --git a/src/commands/feed.rs b/src/commands/feed.rs index e9566e5..7f69cd5 100644 --- a/src/commands/feed.rs +++ b/src/commands/feed.rs @@ -65,7 +65,7 @@ pub fn war_livefeed() { let mut players: Value = serde_json::from_reader(resp).unwrap(); loop { - thread::sleep_ms(50_000); // 50 seconds + thread::sleep_ms(30_000); // 30 seconds let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=onlinePlayers").unwrap(); let new_players: Value = serde_json::from_reader(resp).unwrap(); diff --git a/src/commands/guild.rs b/src/commands/guild.rs index 031f1cc..1ba0dbf 100644 --- a/src/commands/guild.rs +++ b/src/commands/guild.rs @@ -13,6 +13,9 @@ use failure::Error; use ::ResponseError; pub fn wc_guild(command: &str, msg: &Message) -> Result<(), Error> { + if command.len() <= 6 { + bail!("no guild specified"); + } let guild_name = &command[6..]; let guild; diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 678305a..90bbd75 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -65,6 +65,10 @@ pub fn wc_status(msg: &Message) -> Result<(), Error> { } pub fn wc_territory(command: &str, msg: &Message) -> Result<(), Error> { + if command.len() <= 10 { + bail!("no territory specified"); + } + let territory = &command[10..]; let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList")?.text().unwrap(); diff --git a/src/commands/player.rs b/src/commands/player.rs index 5025226..60f2a47 100644 --- a/src/commands/player.rs +++ b/src/commands/player.rs @@ -5,6 +5,9 @@ use serenity::model::*; use failure::Error; pub fn wc_player(command: &str, msg: &Message) -> Result<(), Error> { + if command.len() <= 7 { + bail!("no player specified"); + } let player = &command[7..]; let player = wynncraft::player(player)?; diff --git a/src/main.rs b/src/main.rs index b74ec68..bcffcf5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,21 +141,21 @@ impl Handler { } let command = &msg.content[prefix.len()..]; - if command.starts_with("guild ") { + if command.starts_with("guild") { wc_guild(command, msg)?; } else if command == "topguilds" { wc_topguilds_limit(msg, 10)?; } else if command.starts_with("topguilds ") { wc_topguilds(command, msg)?; - } else if command.starts_with("territory ") { + } else if command.starts_with("territory") { wc_territory(command, msg)?; } else if command == "status" { wc_status(msg)?; - } else if command.starts_with("player ") { + } else if command.starts_with("player") { wc_player(command, msg)?; - } else if command == "livefeed" { + } else if command.starts_with("livefeed") { wc_livefeed(msg)?; - } else if command == "unlivefeed" { + } else if command.starts_with("unlivefeed") { wc_unlivefeed(msg)?; } else if command == "info" || command == "" { wc_info(msg)?; @@ -165,9 +165,9 @@ impl Handler { wc_crop(command, msg)?; } else if command == "crop" { wc_crop_discord_upload(msg)?; - } else if command == "warfeed" { + } else if command.starts_with("warfeed") { wc_warfeed(msg)?; - } else if command == "unwarfeed" { + } else if command.starts_with("unwarfeed") { wc_unwarfeed(msg)?; } else if command.starts_with("shout") { if msg.author.name == "Wurst" && msg.author.discriminator == 1783 { @@ -175,7 +175,7 @@ impl Handler { } else { "<@210743594061922306>".parse::().unwrap().dm(|f| f.content(format!("{} tried to shout {:?}", msg.author, &command[6..]))).unwrap(); } - } else if command.starts_with("prefix ") { + } else if command.starts_with("prefix") { wc_prefix(command, msg)?; } else { bail!(ResponseError::UnknownCommand { name: command.to_owned() });