Make colour optional in embeds
This commit is contained in:
parent
cc25f78970
commit
0b006bf9fa
17
src/main.rs
17
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<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());
|
||||
|
|
Loading…
Reference in New Issue