feat: split out the minecraft script so it runs at 5am instead of regularly
This commit is contained in:
parent
7e6d892b67
commit
cf2c7683d2
4 changed files with 20 additions and 8 deletions
14
src/bin/update_minecraft.rs
Normal file
14
src/bin/update_minecraft.rs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<Context>) {
|
|||
|
||||
let db = db_lock.read().await;
|
||||
|
||||
let config_lock = {
|
||||
let data_read = ctx.data.read().await;
|
||||
data_read.get::<Config>().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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue