feat: updating teh data from wolves should now also update roles for whoever changed.
This should lead to faster activations of folks who have previously linked, join a server, then get membership. Closes #6
This commit is contained in:
parent
7303b5782c
commit
3779222a38
4 changed files with 127 additions and 23 deletions
|
@ -7,7 +7,7 @@ use serenity::{
|
|||
},
|
||||
};
|
||||
use skynet_discord_bot::get_data::get_wolves;
|
||||
use skynet_discord_bot::{get_server_config, set_roles::update_server, Config, DataBase, Servers};
|
||||
use skynet_discord_bot::{get_server_config, set_roles::update_server, DataBase, Servers};
|
||||
use sqlx::{Error, Pool, Sqlite};
|
||||
|
||||
pub async fn run(command: &ApplicationCommandInteraction, ctx: &Context) -> String {
|
||||
|
@ -173,14 +173,8 @@ 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;
|
||||
get_wolves(ctx).await;
|
||||
|
||||
let mut roles_remove = vec![];
|
||||
if current_remove {
|
||||
|
@ -189,7 +183,7 @@ async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Resul
|
|||
if past_remove {
|
||||
roles_remove.push(past_role)
|
||||
}
|
||||
update_server(db, ctx, server, &roles_remove).await;
|
||||
update_server(ctx, server, &roles_remove, &vec![]).await;
|
||||
}
|
||||
|
||||
insert
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue