feat: bumped serenity to the latest version

Lots of changes to how it runs
This commit is contained in:
silver 2025-02-19 00:17:02 +00:00
parent a8c1cc9cf1
commit 6b84f33d2e
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
12 changed files with 352 additions and 485 deletions

View file

@ -31,7 +31,7 @@ pub mod normal {
let mut members_all = members.len();
if let Ok(x) = server.members(ctx, None, None).await {
for mut member in x {
for member in x {
// members_changed acts as an override to only deal with teh users in it
if !members_changed.is_empty() && !members_changed.contains(&member.user.id) {
continue;
@ -83,7 +83,7 @@ pub mod normal {
set_server_numbers(&db, server, members_all as i64, members.len() as i64).await;
// small bit of logging to note changes over time
println!("{:?} Changes: New: +{}, Current: +{}/-{}", server.as_u64(), roles_set[0], roles_set[1], roles_set[2]);
println!("{:?} Changes: New: +{}, Current: +{}/-{}", server.get(), roles_set[0], roles_set[1], roles_set[2]);
}
pub async fn get_server_member_bulk(db: &Pool<Sqlite>, server: &GuildId) -> Vec<ServerMembersWolves> {
@ -99,7 +99,7 @@ pub mod normal {
)
"#,
)
.bind(*server.as_u64() as i64)
.bind(server.get() as i64)
.bind(get_now_iso(true))
.fetch_all(db)
.await
@ -116,13 +116,13 @@ pub mod normal {
)
.bind(past)
.bind(current)
.bind(*server.as_u64() as i64)
.bind(server.get() as i64)
.fetch_optional(db)
.await
{
Ok(_) => {}
Err(e) => {
println!("Failure to insert into {}", server.as_u64());
println!("Failure to insert into {}", server.get());
println!("{:?}", e);
}
}
@ -134,6 +134,8 @@ pub mod committee {
use crate::common::database::{DataBase, Wolves};
use crate::common::wolves::committees::Committees;
use crate::Config;
use serenity::all::EditRole;
use serenity::builder::CreateChannel;
use serenity::client::Context;
use serenity::model::channel::ChannelType;
use serenity::model::guild::Member;
@ -170,9 +172,16 @@ pub mod committee {
*/
pub async fn update_committees(db: &Pool<Sqlite>, ctx: &Context, config: &Config, members: &mut Vec<Member>) {
let server = config.committee_server;
let committee_member = config.committee_role;
let committee_member = RoleId::new(1226602779968274573);
let committees = get_committees(db).await;
let categories = vec![config.committee_category, ChannelId(1341457244973305927), ChannelId(1341457509717639279)];
let categories = vec![
// C&S Chats 1
ChannelId::new(1226606560973815839),
// C&S Chats 2
ChannelId::new(1341457244973305927),
// C&S Chats 3
ChannelId::new(1341457509717639279),
];
// information about the server
let roles = server.roles(&ctx).await.unwrap_or_default();
@ -216,7 +225,10 @@ pub mod committee {
Some(x) => Some(x.to_owned()),
None => {
// create teh role if it does not exist
match server.create_role(&ctx, |r| r.hoist(false).mentionable(true).name(&committee.name_full)).await {
match server
.create_role(&ctx, EditRole::new().name(&committee.name_full).hoist(false).mentionable(true))
.await
{
Ok(x) => Some(x),
Err(_) => None,
}
@ -226,7 +238,12 @@ pub mod committee {
// create teh channel if it does nto exist
if !channels_name.contains_key(&committee.name_profile) {
match server
.create_channel(&ctx, |c| c.name(&committee.name_profile).kind(ChannelType::Text).category(categories[category_index]))
.create_channel(
&ctx,
CreateChannel::new(&committee.name_profile)
.kind(ChannelType::Text)
.category(categories[category_index]),
)
.await
{
Ok(x) => {
@ -277,7 +294,7 @@ pub mod committee {
Some(x) => {
let mut tmp = x.to_owned();
if !tmp.is_empty() {
tmp.push(RoleId(1226602779968274573));
tmp.push(committee_member);
}
tmp
}
@ -309,7 +326,7 @@ pub mod committee {
// these roles are flavor roles, only there to make folks mentionable
member.add_roles(&ctx, &roles_add).await.unwrap_or_default();
} else {
member.remove_roles(&ctx, &[RoleId(1226602779968274573)]).await.unwrap_or_default();
member.remove_roles(&ctx, &[committee_member]).await.unwrap_or_default();
}
}
@ -347,8 +364,9 @@ pub mod committee {
FROM committees
"#,
)
.fetch_all(db)
.await.unwrap_or_else(|e| {
.fetch_all(db)
.await
.unwrap_or_else(|e| {
dbg!(e);
vec![]
})