From 3ec319b93d9fccf9eb5a98469f3b1c842e76bb81 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Mon, 4 Aug 2025 12:16:51 -0600 Subject: [PATCH] Fixed issue with listener add role actions treating seconds as hours --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/config.rs | 4 ++++ src/discord/shop.rs | 6 +++--- src/event_listener/mod.rs | 12 ++++++------ 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9f1a61..496889d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,7 +1093,7 @@ dependencies = [ [[package]] name = "fren" -version = "2.1.0" +version = "2.1.1" dependencies = [ "axum 0.8.1", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index fbfb305..de73b3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fren" -version = "2.1.0" +version = "2.1.1" edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/config.rs b/src/config.rs index adda60f..f842050 100644 --- a/src/config.rs +++ b/src/config.rs @@ -59,6 +59,10 @@ impl BotConfig { cfg.try_deserialize() } + + pub fn effect_role_duration(&self) -> chrono::Duration { + chrono::Duration::seconds(self.effect_role_duration) + } } #[derive(Debug)] diff --git a/src/discord/shop.rs b/src/discord/shop.rs index 5e1585d..6b9f144 100644 --- a/src/discord/shop.rs +++ b/src/discord/shop.rs @@ -175,7 +175,7 @@ pub async fn land_mine( channel_id: Some(channel.id()), 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, Expiration::NumberOfTriggers { triggers: 1 }, false @@ -211,7 +211,7 @@ pub async fn phrase_canceler( channel_id: None, 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, Expiration::NumberOfTriggers { triggers: 1 }, false @@ -241,7 +241,7 @@ pub async fn nuke(ctx: Context<'_>) -> Result<(), Error> { content: None, }, 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()} ], 0.5, diff --git a/src/event_listener/mod.rs b/src/event_listener/mod.rs index 8da0a2c..94821c5 100644 --- a/src/event_listener/mod.rs +++ b/src/event_listener/mod.rs @@ -91,13 +91,13 @@ impl TriggerEvent { #[serde(tag = "type")] pub enum Action { Kill { - hours: u16, + hours: i64, }, Cancel { - hours: u16, + hours: i64, }, Ghoulify { - hours: u16, + hours: i64, }, UpdateSocialCredit { score_diff: i64, @@ -194,7 +194,7 @@ impl Listener { trigger_event.triggerer, data.cfg.guild_id, UserRole::Dead, - Duration::hours(*hours as i64), + Duration::hours(*hours), ) .await?; } @@ -205,7 +205,7 @@ impl Listener { trigger_event.triggerer, data.cfg.guild_id, UserRole::Cancelled, - Duration::hours(*hours as i64), + Duration::hours(*hours), ) .await?; } @@ -249,7 +249,7 @@ impl Listener { trigger_event.triggerer, data.cfg.guild_id, UserRole::Ghoul, - Duration::hours(*hours as i64), + Duration::hours(*hours), ) .await?; }