From 0b006bf9fa45e5166c88d4e9ff8af3853dc81ee9 Mon Sep 17 00:00:00 2001 From: Agatha Date: Thu, 9 Apr 2020 22:03:48 +0300 Subject: [PATCH] Make colour optional in embeds --- src/main.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 06791e2..2f86c7a 100755 --- a/src/main.rs +++ b/src/main.rs @@ -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, description: Option, fields: Option>, 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());