fmt: re-organise the regular data request
This commit is contained in:
parent
3927734083
commit
273c58d035
3 changed files with 12 additions and 9 deletions
|
@ -8,7 +8,7 @@ use skynet_discord_bot::{get_config, Config};
|
|||
use std::{process, sync::Arc};
|
||||
use tokio::sync::RwLock;
|
||||
use skynet_discord_bot::common::database::{db_init, DataBase};
|
||||
use skynet_discord_bot::common::wolves::get_data::get_wolves_cns;
|
||||
use skynet_discord_bot::common::wolves::cns::get_wolves;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
@ -46,7 +46,7 @@ impl EventHandler for Handler {
|
|||
println!("{} is connected!", ready.user.name);
|
||||
|
||||
// get the data for each individual club/soc
|
||||
get_wolves_cns(&ctx).await;
|
||||
get_wolves(&ctx).await;
|
||||
|
||||
// finish up
|
||||
process::exit(0);
|
||||
|
|
|
@ -6,7 +6,7 @@ use serenity::{
|
|||
prelude::{command::CommandOptionType, interaction::application_command::CommandDataOptionValue},
|
||||
},
|
||||
};
|
||||
use skynet_discord_bot::common::wolves::get_data::get_wolves_cns;
|
||||
use skynet_discord_bot::common::wolves::cns::get_wolves;
|
||||
use skynet_discord_bot::{is_admin, set_roles::update_server};
|
||||
use sqlx::{Error, Pool, Sqlite};
|
||||
use skynet_discord_bot::common::database::{get_server_config, DataBase, Servers};
|
||||
|
@ -216,7 +216,7 @@ async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Resul
|
|||
// update all users
|
||||
if update {
|
||||
// handle wolves api here
|
||||
get_wolves_cns(ctx).await;
|
||||
get_wolves(ctx).await;
|
||||
|
||||
let mut roles_remove = vec![];
|
||||
if current_remove {
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
// pub members: Vec<i64>,
|
||||
// }
|
||||
|
||||
pub mod get_data {
|
||||
/**
|
||||
This is getting data for Clubs and Socs
|
||||
*/
|
||||
pub mod cns {
|
||||
use crate::set_roles::update_server;
|
||||
use std::collections::BTreeMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -50,7 +53,7 @@ pub mod get_data {
|
|||
pub email: String,
|
||||
pub expiry: String,
|
||||
}
|
||||
pub async fn get_wolves_cns(ctx: &Context) {
|
||||
pub async fn get_wolves(ctx: &Context) {
|
||||
let db_lock = {
|
||||
let data_read = ctx.data.read().await;
|
||||
data_read.get::<DataBase>().expect("Expected Database in TypeMap.").clone()
|
||||
|
@ -75,7 +78,7 @@ pub mod get_data {
|
|||
|
||||
// list of users that need to be updated for this server
|
||||
let mut user_to_update = vec![];
|
||||
for user in get_wolves_cns_sub(&config, wolves_api).await {
|
||||
for user in get_wolves_sub(&config, wolves_api).await {
|
||||
let id = user.member_id.parse::<u64>().unwrap_or_default();
|
||||
match existing.get(&(id as i64)) {
|
||||
None => {
|
||||
|
@ -103,7 +106,7 @@ pub mod get_data {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn get_server_member(db: &Pool<Sqlite>, server: &GuildId) -> Vec<ServerMembersWolves> {
|
||||
async fn get_server_member(db: &Pool<Sqlite>, server: &GuildId) -> Vec<ServerMembersWolves> {
|
||||
sqlx::query_as::<_, ServerMembersWolves>(
|
||||
r#"
|
||||
SELECT *
|
||||
|
@ -121,7 +124,7 @@ pub mod get_data {
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
async fn get_wolves_cns_sub(config: &Config, wolves_api: &str) -> Vec<WolvesResultUser> {
|
||||
async fn get_wolves_sub(config: &Config, wolves_api: &str) -> Vec<WolvesResultUser> {
|
||||
if config.wolves_url.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue