feat: got the committee update running smoothly (using cache and far far faster due to fixing some logic issues)
This commit is contained in:
parent
5815cde38b
commit
96eb81293b
1 changed files with 14 additions and 1 deletions
15
src/main.rs
15
src/main.rs
|
@ -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::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::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::common::wolves::committees::Committees;
|
||||||
use skynet_discord_bot::{get_config, Config};
|
use skynet_discord_bot::{get_config, Config};
|
||||||
use sqlx::{Pool, Sqlite};
|
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
|
// Now that the loop is running, we set the bool to true
|
||||||
self.is_loop_running.swap(true, Ordering::Relaxed);
|
self.is_loop_running.swap(true, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue