fix: make sure that wolves data is pulled in before roles are ran
This commit is contained in:
parent
5745118ede
commit
1e486d7a57
4 changed files with 204 additions and 191 deletions
|
@ -6,7 +6,8 @@ use serenity::{
|
|||
prelude::{command::CommandOptionType, interaction::application_command::CommandDataOptionValue},
|
||||
},
|
||||
};
|
||||
use skynet_discord_bot::{get_server_config, update_server, DataBase, Servers};
|
||||
use skynet_discord_bot::get_data::get_wolves;
|
||||
use skynet_discord_bot::{get_server_config, set_roles::update_server, Config, DataBase, Servers};
|
||||
use sqlx::{Error, Pool, Sqlite};
|
||||
|
||||
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
|
||||
|
@ -172,6 +173,15 @@ async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Resul
|
|||
|
||||
// update all users
|
||||
if update {
|
||||
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;
|
||||
|
||||
// handle wolves api here
|
||||
get_wolves(db, &config).await;
|
||||
|
||||
let mut roles_remove = vec![];
|
||||
if current_remove {
|
||||
roles_remove.push(current_role)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue