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)]
|
#[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());
|
||||||
|
|
Loading…
Reference in New Issue