Fix urbandict lookup None unwrap error
This commit is contained in:
parent
b35e2a7721
commit
7ade211de6
|
@ -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)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "rustcord"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
authors = ["Agatha <@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
52
src/main.rs
52
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(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue