feat: got the committee update running smoothly (using cache and far far faster due to fixing some logic issues)

This commit is contained in:
silver 2025-07-20 22:32:55 +01:00
parent 5815cde38b
commit 96eb81293b
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D

View file

@ -18,7 +18,7 @@ use serenity::{
};
use skynet_discord_bot::common::database::{db_init, get_server_config, get_server_config_bulk, get_server_member, DataBase};
use skynet_discord_bot::common::set_roles::committee::update_committees;
use skynet_discord_bot::common::set_roles::normal;
use skynet_discord_bot::common::set_roles::{committee, normal};
use skynet_discord_bot::common::wolves::committees::Committees;
use skynet_discord_bot::{get_config, Config};
use sqlx::{Pool, Sqlite};
@ -70,6 +70,19 @@ impl EventHandler for Handler {
});
}
{
// this is to update committee roles every 5 min
let ctx_task = Arc::clone(&ctx);
tokio::spawn(async move {
loop {
println!("Update - Committee - Start");
committee::check_committee(&ctx_task).await;
println!("Update - Committee - End");
tokio::time::sleep(Duration::from_secs(60 * 5)).await;
}
});
}
// Now that the loop is running, we set the bool to true
self.is_loop_running.swap(true, Ordering::Relaxed);
}