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