diff --git a/Cargo.lock b/Cargo.lock index b446da6..5e84a7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1125,7 +1125,7 @@ dependencies = [ [[package]] name = "wynnrobot" -version = "0.10.0" +version = "0.10.1" dependencies = [ "diesel 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/commands/guild.rs b/src/commands/guild.rs index 54ea75a..9165ddf 100644 --- a/src/commands/guild.rs +++ b/src/commands/guild.rs @@ -35,7 +35,8 @@ pub fn wc_guild(command: &str, msg: &Message) -> Result<(), Error> { } } - let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList")?.text().unwrap(); + let message = (|| { + let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList")?.text()?; let territories: Value = if let Ok(error) = serde_json::from_str::(&resp) { bail!("API error ({})", error.error); @@ -54,6 +55,8 @@ pub fn wc_guild(command: &str, msg: &Message) -> Result<(), Error> { //territories_count += 1; } } + Ok(message) + })().unwrap_or_else(|e| format!("\nError getting territories: {}", e)); let full_msg = format!( "**Guild**: {} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index fe19e4d..620307c 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -111,7 +111,7 @@ Visit the Discord for more help: https://discord.gg/GbN7HeG"))?; pub fn wc_crop(command: &str, msg: &Message) -> Result<(), Error> { let url = &command[5..]; let new_url = reqwest::get(&format!("https://wynncraft-autocrop.herokuapp.com/crop?url={}", url))?.text().unwrap(); - if new_url.starts_with("https://i.imgur.com") { + if new_url.starts_with("https://res.cloudinary.com") { msg.channel_id.say(&new_url)?; } else { bail!(failure::err_msg("could not crop image")); @@ -125,7 +125,7 @@ pub fn wc_crop_discord_upload(msg: &Message) -> Result<(), Error> { for attachment in &last.attachments { let url = &attachment.url; let new_url = reqwest::get(&format!("https://wynncraft-autocrop.herokuapp.com/crop?url={}", url))?.text().unwrap(); - if new_url.starts_with("https://i.imgur.com") { + if new_url.starts_with("https://res.cloudinary.com") { msg.channel_id.say(&new_url)?; } else { bail!(failure::err_msg("could not crop image"));