diff --git a/Cargo.toml b/Cargo.toml index cb6d3cd..e396f36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ name = "update_data" [[bin]] name = "update_users" +[[bin]] +name = "update_minecraft" + [dependencies] serenity = { version = "0.11.6", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "cache"] } tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } diff --git a/flake.nix b/flake.nix index cbec3d1..4fc26b8 100644 --- a/flake.nix +++ b/flake.nix @@ -94,6 +94,8 @@ "update_data" = "*:0,20,40"; # groups are updated every hour, offset from teh ldap "update_users" = "*:05:00"; + # minecraft stuff is updated at 5am + "update_minecraft" = "5:10:00"; }; in { diff --git a/src/bin/update_minecraft.rs b/src/bin/update_minecraft.rs new file mode 100644 index 0000000..37aaee9 --- /dev/null +++ b/src/bin/update_minecraft.rs @@ -0,0 +1,14 @@ +use skynet_discord_bot::{db_init, get_config, get_server_config_bulk, update_server}; + +#[tokio::main] +async fn main() { + let config = get_config(); + let db = match db_init(&config).await { + Ok(x) => x, + Err(_) => return, + }; + + for server_config in get_server_config_bulk(&db).await { + update_server(server_config.server_minecraft, &db, &server_config.server, &config).await; + } +} diff --git a/src/bin/update_users.rs b/src/bin/update_users.rs index 974fc1e..34a0bc0 100644 --- a/src/bin/update_users.rs +++ b/src/bin/update_users.rs @@ -4,7 +4,7 @@ use serenity::{ model::gateway::{GatewayIntents, Ready}, Client, }; -use skynet_discord_bot::{db_init, get_config, get_server_config_bulk, set_roles, update_server, Config, DataBase}; +use skynet_discord_bot::{db_init, get_config, get_server_config_bulk, set_roles, Config, DataBase}; use std::{process, sync::Arc}; use tokio::sync::RwLock; @@ -58,14 +58,7 @@ async fn bulk_check(ctx: Arc) { let db = db_lock.read().await; - let config_lock = { - let data_read = ctx.data.read().await; - data_read.get::().expect("Expected Config in TypeMap.").clone() - }; - let config = config_lock.read().await; - for server_config in get_server_config_bulk(&db).await { set_roles::update_server(&ctx, &server_config, &[], &vec![]).await; - update_server(server_config.server_minecraft, &db, &server_config.server, &config).await; } }