diff --git a/Cargo.lock b/Cargo.lock index 9e8937f..b626e75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "rustcord" -version = "0.2.5" +version = "0.2.6" dependencies = [ "owoify 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 32f6efc..1f7240d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustcord" -version = "0.2.5" +version = "0.2.6" authors = ["Agatha "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 6804ae0..6fc62e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -95,10 +95,7 @@ fn init(ctx: &mut Context, message: &Message) -> CommandResult { .say(&ctx.http, "The Discordinator9000 is gonna hug ny'all!"); } 1 => { - let _ = message.channel_id.say( - &ctx.http, - "Nyaa~!", - ); + let _ = message.channel_id.say(&ctx.http, "Nyaa~!"); } _ => { let _ = message.channel_id.say(&ctx.http, "Oopsie woopsie! UwU"); @@ -305,12 +302,12 @@ fn sausage(ctx: &mut Context, message: &Message) -> CommandResult { #[checks(Server)] fn ad(ctx: &mut Context, message: &Message) -> CommandResult { let _ = message.channel_id.send_message(&ctx.http, |m| m - .embed(|e| e - .title(":b:ottom text") - ***REMOVED*** - .thumbnail("https://i.imgur.com/8MU0gqD.png") - .color(0x00f3ff)) - ); + .embed(|e| e + .title(":b:ottom text") + ***REMOVED*** + .thumbnail("https://i.imgur.com/8MU0gqD.png") + .color(0x00f3ff)) + ); Ok(()) } @@ -402,17 +399,30 @@ fn compare_bot(ctx: &mut Context, message: &Message, mut args: Args) -> CommandR #[aliases("what's this")] fn what(ctx: &mut Context, message: &Message, args: Args) -> CommandResult { let text: String = args.rest().trim().to_string(); - let defs = &urbandict::get_definitions(&text.to_string())?; - let def = &defs[0]; - let _ = message.channel_id.send_message(&ctx.http, |m| { - m.embed(|e| { - e.title(format!("Author: {}", def.author)).field( - "Definition: ", - def.definition.replace(|c| c == '[' || c == ']', ""), - false, - ) - }) - }); + let defs = &urbandict::get_definitions(&text.to_string()); + match defs { + Err(_e) => { + let _ = message + .channel_id + .say(&ctx.http, format!("Invalid query >w<")); + } + Ok(v) => { + if v.len() > 0 { + let def = &v[0]; + let _ = message.channel_id.send_message(&ctx.http, |m| { + m.embed(|e| { + e.title(format!("Author: {}", def.author)).field( + "Definition: ", + def.definition.replace(|c| c == '[' || c == ']', ""), + false, + ) + }) + }); + } else { + println!("No resuwults"); + } + } + } Ok(()) }