parent
66442efae6
commit
ae7d9cf996
|
@ -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)?;
|
||||
|
|
Loading…
Reference in New Issue