feat: drastically speed up the committee server script, it no longer tries to remove the committee role from those who dont have it.
This commit is contained in:
parent
43ef787d59
commit
1729ec0a54
1 changed files with 16 additions and 11 deletions
|
@ -329,15 +329,11 @@ pub mod committee {
|
||||||
None => {
|
None => {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
Some(x) => {
|
Some(x) => x.to_owned(),
|
||||||
let mut tmp = x.to_owned();
|
|
||||||
if !tmp.is_empty() {
|
|
||||||
tmp.push(committee_member);
|
|
||||||
}
|
|
||||||
tmp
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let on_committee = !roles_required.is_empty();
|
||||||
|
|
||||||
let mut roles_rem = vec![];
|
let mut roles_rem = vec![];
|
||||||
let mut roles_add = vec![];
|
let mut roles_add = vec![];
|
||||||
// get a list of all the roles to remove from someone
|
// get a list of all the roles to remove from someone
|
||||||
|
@ -346,14 +342,25 @@ pub mod committee {
|
||||||
for role in &roles_current {
|
for role in &roles_current {
|
||||||
roles_current_id.push(role.id.to_owned());
|
roles_current_id.push(role.id.to_owned());
|
||||||
if !roles_required.contains(&role.id) {
|
if !roles_required.contains(&role.id) {
|
||||||
roles_rem.push(role.id.to_owned());
|
if role.id == committee_member {
|
||||||
|
if !on_committee {
|
||||||
|
roles_rem.push(role.id.to_owned());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !roles_required.is_empty() {
|
let has_committee_role = roles_current_id.contains(&committee_member);
|
||||||
|
|
||||||
|
if on_committee && !has_committee_role {
|
||||||
// if there are committee roles then give the general purporse role
|
// if there are committee roles then give the general purporse role
|
||||||
roles_add.push(committee_member);
|
roles_add.push(committee_member);
|
||||||
|
}
|
||||||
|
if !on_committee && has_committee_role {
|
||||||
|
roles_rem.push(committee_member);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !roles_required.is_empty() {
|
||||||
if let Some(x) = roles_db.get_mut(&0) {
|
if let Some(x) = roles_db.get_mut(&0) {
|
||||||
x.count += 1;
|
x.count += 1;
|
||||||
}
|
}
|
||||||
|
@ -372,8 +379,6 @@ pub mod committee {
|
||||||
if !roles_add.is_empty() {
|
if !roles_add.is_empty() {
|
||||||
// these roles are flavor roles, only there to make folks mentionable
|
// these roles are flavor roles, only there to make folks mentionable
|
||||||
member.add_roles(&ctx, &roles_add).await.unwrap_or_default();
|
member.add_roles(&ctx, &roles_add).await.unwrap_or_default();
|
||||||
} else {
|
|
||||||
member.remove_roles(&ctx, &[committee_member]).await.unwrap_or_default();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue