feat: updated teh bot to use the new wolves_id for clubs/socs
This commit is contained in:
parent
9ce5b8136b
commit
6481fcb89f
5 changed files with 21 additions and 15 deletions
|
@ -87,7 +87,7 @@ pub mod cns {
|
|||
server,
|
||||
// this is the unique api key for each club/soc
|
||||
wolves_api,
|
||||
server_name,
|
||||
wolves_id,
|
||||
..
|
||||
} = &server_config;
|
||||
// dbg!(&server_config);
|
||||
|
@ -101,7 +101,7 @@ pub mod cns {
|
|||
for user in wolves.get_members(wolves_api).await {
|
||||
// dbg!(&user.committee);
|
||||
if server_name_tmp.is_none() {
|
||||
server_name_tmp = Some(user.committee.to_owned());
|
||||
server_name_tmp = Some(user.committee_id);
|
||||
}
|
||||
let id = user.member_id.parse::<u64>().unwrap_or_default();
|
||||
match existing.get(&(id as i64)) {
|
||||
|
@ -124,9 +124,9 @@ pub mod cns {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(name) = server_name_tmp {
|
||||
if &name != server_name {
|
||||
set_server_member(&db, server, &name).await;
|
||||
if let Some(cs_id) = server_name_tmp {
|
||||
if &cs_id != wolves_id {
|
||||
set_server_member(&db, server, cs_id).await;
|
||||
}
|
||||
}
|
||||
if !user_to_update.is_empty() {
|
||||
|
@ -135,15 +135,15 @@ pub mod cns {
|
|||
}
|
||||
}
|
||||
|
||||
async fn set_server_member(db: &Pool<Sqlite>, server: &GuildId, name: &str) {
|
||||
async fn set_server_member(db: &Pool<Sqlite>, server: &GuildId, wolves_id: i64) {
|
||||
match sqlx::query_as::<_, Servers>(
|
||||
"
|
||||
UPDATE servers
|
||||
SET server_name = ?
|
||||
SET wolves_id = ?
|
||||
WHERE server = ?
|
||||
",
|
||||
)
|
||||
.bind(name)
|
||||
.bind(wolves_id)
|
||||
.bind(server.get() as i64)
|
||||
.fetch_optional(db)
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue