Make colour optional in embeds

This commit is contained in:
Agatha 2020-04-09 22:03:48 +03:00
parent a355edf2a1
commit 3bb4a4796a
1 changed files with 10 additions and 7 deletions

View File

@ -178,7 +178,7 @@ fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
#[derive(Deserialize)]
struct EmbedProperties {
author: Option<(String, String)>,
colour: String,
colour: Option<String>,
description: Option<String>,
fields: Option<Vec<(String, String, bool)>>,
footer: Option<(String, String)>,
@ -195,7 +195,7 @@ fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
EmbedProperties {
author: None,
colour: 000000.to_string(),
colour: None,
description: None,
fields: None,
footer: None,
@ -221,11 +221,14 @@ fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
});
}
e.color(Colour::new(
u32::from_str_radix(&input_embed.colour, 16)
.ok()
.unwrap_or(0x000000),
));
if input_embed.colour.is_some() {
e.color(Colour::new(
u32::from_str_radix(&input_embed.colour.unwrap(), 16)
.ok()
.unwrap_or(0x000000),
));
}
// Set embed description unless empty
if input_embed.description != None {
e.description(input_embed.description.unwrap());