Fixed issue with listener add role actions treating seconds as hours

This commit is contained in:
Joey Hines 2025-08-04 12:16:51 -06:00
parent df1900a7f8
commit 3ec319b93d
Signed by: joeyahines
GPG Key ID: 38BA6F25C94C9382
5 changed files with 15 additions and 11 deletions

2
Cargo.lock generated
View File

@ -1093,7 +1093,7 @@ dependencies = [
[[package]] [[package]]
name = "fren" name = "fren"
version = "2.1.0" version = "2.1.1"
dependencies = [ dependencies = [
"axum 0.8.1", "axum 0.8.1",
"base64 0.22.1", "base64 0.22.1",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fren" name = "fren"
version = "2.1.0" version = "2.1.1"
edition = "2024" edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -59,6 +59,10 @@ impl BotConfig {
cfg.try_deserialize() cfg.try_deserialize()
} }
pub fn effect_role_duration(&self) -> chrono::Duration {
chrono::Duration::seconds(self.effect_role_duration)
}
} }
#[derive(Debug)] #[derive(Debug)]

View File

@ -175,7 +175,7 @@ pub async fn land_mine(
channel_id: Some(channel.id()), channel_id: Some(channel.id()),
content: None, content: None,
}, },
vec![Action::Kill { hours: ctx.data().cfg.effect_role_duration as u16}, Action::Speak {msg: "*click* **BOOM**, sorry kid you've run out of time. That was a landmine. You're dead.".to_string()}], vec![Action::Kill { hours: ctx.data().cfg.effect_role_duration().num_hours() }, Action::Speak {msg: "*click* **BOOM**, sorry kid you've run out of time. That was a landmine. You're dead.".to_string()}],
0.95, 0.95,
Expiration::NumberOfTriggers { triggers: 1 }, Expiration::NumberOfTriggers { triggers: 1 },
false false
@ -211,7 +211,7 @@ pub async fn phrase_canceler(
channel_id: None, channel_id: None,
content: Some(phrase), content: Some(phrase),
}, },
vec![Action::Cancel { hours: ctx.data().cfg.effect_role_duration as u16}, Action::Speak {msg: "oof, dude. Don't you know the Christopher Columbus connotations of what you just said? Consider yourself canceled.".to_string()}], vec![Action::Cancel { hours: ctx.data().cfg.effect_role_duration().num_hours() }, Action::Speak {msg: "oof, dude. Don't you know the Christopher Columbus connotations of what you just said? Consider yourself canceled.".to_string()}],
1.0, 1.0,
Expiration::NumberOfTriggers { triggers: 1 }, Expiration::NumberOfTriggers { triggers: 1 },
false false
@ -241,7 +241,7 @@ pub async fn nuke(ctx: Context<'_>) -> Result<(), Error> {
content: None, content: None,
}, },
vec![ vec![
Action::Ghoulify { hours: ctx.data().cfg.effect_role_duration as u16 }, Action::Ghoulify { hours: ctx.data().cfg.effect_role_duration().num_hours() },
Action::Speak { msg: "As the radiation exposure sets in, you notice changes. Your flesh begins to deteriorate. Your voice becomes raspy. You are now a ghoul. https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExdjJpcmtwbXRhZml1djd3ZGI3bjhhb3dxYm1vdmVpN2swN2hiZnNzZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/83uF5ITtkxbUul6gMB/giphy.gif".to_string()} Action::Speak { msg: "As the radiation exposure sets in, you notice changes. Your flesh begins to deteriorate. Your voice becomes raspy. You are now a ghoul. https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExdjJpcmtwbXRhZml1djd3ZGI3bjhhb3dxYm1vdmVpN2swN2hiZnNzZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/83uF5ITtkxbUul6gMB/giphy.gif".to_string()}
], ],
0.5, 0.5,

View File

@ -91,13 +91,13 @@ impl TriggerEvent {
#[serde(tag = "type")] #[serde(tag = "type")]
pub enum Action { pub enum Action {
Kill { Kill {
hours: u16, hours: i64,
}, },
Cancel { Cancel {
hours: u16, hours: i64,
}, },
Ghoulify { Ghoulify {
hours: u16, hours: i64,
}, },
UpdateSocialCredit { UpdateSocialCredit {
score_diff: i64, score_diff: i64,
@ -194,7 +194,7 @@ impl Listener {
trigger_event.triggerer, trigger_event.triggerer,
data.cfg.guild_id, data.cfg.guild_id,
UserRole::Dead, UserRole::Dead,
Duration::hours(*hours as i64), Duration::hours(*hours),
) )
.await?; .await?;
} }
@ -205,7 +205,7 @@ impl Listener {
trigger_event.triggerer, trigger_event.triggerer,
data.cfg.guild_id, data.cfg.guild_id,
UserRole::Cancelled, UserRole::Cancelled,
Duration::hours(*hours as i64), Duration::hours(*hours),
) )
.await?; .await?;
} }
@ -249,7 +249,7 @@ impl Listener {
trigger_event.triggerer, trigger_event.triggerer,
data.cfg.guild_id, data.cfg.guild_id,
UserRole::Ghoul, UserRole::Ghoul,
Duration::hours(*hours as i64), Duration::hours(*hours),
) )
.await?; .await?;
} }