More cleanup for new theme

+ Clippy + fmt
main
Joey Hines 2023-01-08 21:00:59 -07:00
parent 66442efae6
commit ae7d9cf996
No known key found for this signature in database
GPG Key ID: 995E531F7A569DDB
1 changed files with 15 additions and 0 deletions

View File

@ -62,6 +62,20 @@ fn role_color() -> TeraFnRet {
)
}
fn seer_color() -> TeraFnRet {
Box::new(
move |args: &HashMap<String, Value>| -> tera::Result<Value> {
match args.get("role") {
Some(val) => match tera::from_value::<Role>(val.clone()) {
Ok(v) => Ok(tera::to_value(v.seer_color().to_string()).unwrap()),
Err(_) => Err("Failed to parse value as role".into()),
},
None => Err("Missing parameter".into()),
}
},
)
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiscordUser {
pub(crate) display_name: String,
@ -188,6 +202,7 @@ impl TryFrom<MessageConfig> for MessageTemplates {
templates.register_function("to_local_time", time_to_discord_time("f"));
templates.register_function("player_color", role_color());
templates.register_function("player_role", role_name());
templates.register_function("seer_color", seer_color());
templates.add_raw_template("welcome_message", &config.welcome_message)?;
templates.add_raw_template("status_message", &config.status_message)?;