diff --git a/src/scheduler.rs b/src/scheduler.rs index 7f701d4..bd3be73 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -30,7 +30,7 @@ pub async fn run_scheduler(ctx: SerenityContext) { async fn schedule_task(ctx: SerenityContext, task: Box) { loop { - let next_run_in = task.interval(); + let next_run_in = task.run_in(); tokio::time::sleep(next_run_in).await; task.run(ctx.clone()).await; diff --git a/src/tasks.rs b/src/tasks.rs index 5a3811e..ed9c9bd 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -36,7 +36,7 @@ const STATUS_UPDATE_CHANNEL_ID: u64 = 764575524127244318; #[async_trait] pub trait Task: Send + Sync { fn name(&self) -> &'static str; - fn interval(&self) -> Duration; + fn run_in(&self) -> Duration; async fn run(&self, ctx: Context); } @@ -48,7 +48,7 @@ impl Task for StatusUpdateCheck { "StatusUpdateCheck" } - fn interval(&self) -> Duration { + fn run_in(&self) -> Duration { time_until(5, 0) } @@ -75,10 +75,11 @@ impl Task for StatusUpdateCheck { let filtered_messages: Vec = messages .into_iter() .filter(|msg| { + let msg_content = msg.content.to_lowercase(); msg.timestamp >= yesterday_five_am.into() && msg.timestamp < today_five_am.into() - && msg.content.to_lowercase().contains("namah shivaya") - && msg.content.to_lowercase().contains("regards") + && msg_content.contains("namah shivaya") + && msg_content.contains("regards") }) .collect();