Make colour optional in embeds

This commit is contained in:
Agatha 2020-04-09 22:03:48 +03:00
parent cc25f78970
commit 0b006bf9fa
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)] #[derive(Deserialize)]
struct EmbedProperties { struct EmbedProperties {
author: Option<(String, String)>, author: Option<(String, String)>,
colour: String, colour: Option<String>,
description: Option<String>, description: Option<String>,
fields: Option<Vec<(String, String, bool)>>, fields: Option<Vec<(String, String, bool)>>,
footer: Option<(String, String)>, footer: Option<(String, String)>,
@ -195,7 +195,7 @@ fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
EmbedProperties { EmbedProperties {
author: None, author: None,
colour: 000000.to_string(), colour: None,
description: None, description: None,
fields: None, fields: None,
footer: None, footer: None,
@ -221,11 +221,14 @@ fn embed(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
}); });
} }
e.color(Colour::new( if input_embed.colour.is_some() {
u32::from_str_radix(&input_embed.colour, 16) e.color(Colour::new(
.ok() u32::from_str_radix(&input_embed.colour.unwrap(), 16)
.unwrap_or(0x000000), .ok()
)); .unwrap_or(0x000000),
));
}
// Set embed description unless empty // Set embed description unless empty
if input_embed.description != None { if input_embed.description != None {
e.description(input_embed.description.unwrap()); e.description(input_embed.description.unwrap());