Add empty args handling for urbandict lookup, bump version
This commit is contained in:
parent
f9bde2fcb5
commit
cc25f78970
|
@ -1030,7 +1030,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustcord"
|
||||
version = "0.3.2"
|
||||
version = "0.3.4"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"owoify 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "rustcord"
|
||||
version = "0.3.2"
|
||||
version = "0.3.4"
|
||||
authors = ["Agatha <@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -542,6 +542,7 @@ fn compare_bot(ctx: &mut Context, message: &Message, mut args: Args) -> CommandR
|
|||
fn what(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
|
||||
let text: String = args.rest().trim().to_string();
|
||||
let defs = &urbandict::get_definitions(&text);
|
||||
if !args.is_empty() {
|
||||
match defs {
|
||||
Err(_e) => {
|
||||
let _ = message.channel_id.say(&ctx.http, "Invalid query >w<");
|
||||
|
@ -551,7 +552,8 @@ fn what(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
|
|||
let def = &v[0];
|
||||
let _ = message.channel_id.send_message(&ctx.http, |m| {
|
||||
m.embed(|e| {
|
||||
e.title(format!("Author: {}", def.author)).field(
|
||||
e.title(format!("Query: {}, Author: {}", text, def.author))
|
||||
.field(
|
||||
"Definition: ",
|
||||
def.definition.replace(|c| c == '[' || c == ']', ""),
|
||||
false,
|
||||
|
@ -559,7 +561,8 @@ fn what(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
|
|||
})
|
||||
});
|
||||
} else {
|
||||
println!("No resuwults");
|
||||
let _ = message.channel_id.say(&ctx.http, "No results!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue