feat: new command to see how many of each club/soc are on teh server
Some checks failed
On_Push / lint_clippy (push) Failing after 34s
On_Push / lint_fmt (push) Successful in 50s
On_Push / build (push) Has been skipped
On_Push / deploy (push) Has been skipped

This commit is contained in:
silver 2025-02-27 03:02:35 +00:00
parent 0bedf96da5
commit 143483d3b3
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
4 changed files with 110 additions and 9 deletions

View file

@ -221,7 +221,7 @@ pub mod committee {
x.name_role = committee.name_full.to_owned();
x.name_channel = committee.name_profile.to_owned();
}
// handle new clubs/socs
if let std::collections::hash_map::Entry::Vacant(e) = roles_db.entry(committee.id) {
// create channel
@ -293,11 +293,13 @@ pub mod committee {
// ID in this is the wolves ID, so we need to get a matching discord ID (if one exists)
if let Some(x) = get_server_member_discord(db, id_wolves).await {
if let Some(member_tmp) = x.discord {
let values = users_roles.entry(member_tmp).or_insert(vec![]);
values.push(r);
if server.member(ctx, &member_tmp).await.is_ok() {
let values = users_roles.entry(member_tmp).or_insert(vec![]);
values.push(r);
if let Some(x) = roles_db.get_mut(&committee.id) {
x.count += 1;
if let Some(x) = roles_db.get_mut(&committee.id) {
x.count += 1;
}
}
}
}
@ -399,13 +401,13 @@ pub mod committee {
}
#[derive(Debug, Clone, Deserialize, Serialize)]
struct CommitteeRoles {
pub struct CommitteeRoles {
id_wolves: i64,
id_role: RoleId,
id_channel: ChannelId,
name_role: String,
pub name_role: String,
name_channel: String,
count: i64,
pub count: i64,
}
impl<'r> FromRow<'r, SqliteRow> for CommitteeRoles {
@ -447,7 +449,7 @@ pub mod committee {
}
}
async fn db_roles_get(db: &Pool<Sqlite>) -> Vec<CommitteeRoles> {
pub async fn db_roles_get(db: &Pool<Sqlite>) -> Vec<CommitteeRoles> {
// expiry
sqlx::query_as::<_, CommitteeRoles>(
"