component models
This commit is contained in:
@ -1,23 +1,23 @@
|
||||
mod sender;
|
||||
|
||||
use std::env;
|
||||
|
||||
use log::info;
|
||||
use serenity::client::Context;
|
||||
use sqlx::{Executor, MySql};
|
||||
use std::env;
|
||||
use tokio::time::sleep_until;
|
||||
use tokio::time::{Duration, Instant};
|
||||
use tokio::time::{sleep_until, Duration, Instant};
|
||||
|
||||
type Database = MySql;
|
||||
|
||||
pub async fn initialize(ctx: Context, pool: impl Executor<'_, Database = Database> + Copy) {
|
||||
let REMIND_INTERVAL = env::var("REMIND_INTERVAL")
|
||||
let remind_interval = env::var("REMIND_INTERVAL")
|
||||
.map(|inner| inner.parse::<u64>().ok())
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or(10);
|
||||
|
||||
loop {
|
||||
let sleep_to = Instant::now() + Duration::from_secs(REMIND_INTERVAL);
|
||||
let sleep_to = Instant::now() + Duration::from_secs(remind_interval);
|
||||
let reminders = sender::Reminder::fetch_reminders(pool).await;
|
||||
|
||||
if reminders.len() > 0 {
|
||||
|
Reference in New Issue
Block a user