fix: role_current needednt have been an Option
This commit is contained in:
parent
e9aed40f41
commit
11240914ac
4 changed files with 22 additions and 33 deletions
36
src/lib.rs
36
src/lib.rs
|
@ -228,8 +228,7 @@ pub struct Servers {
|
|||
pub server: GuildId,
|
||||
pub wolves_api: String,
|
||||
pub role_past: Option<RoleId>,
|
||||
// TODO: this should not be option
|
||||
pub role_current: Option<RoleId>,
|
||||
pub role_current: RoleId,
|
||||
pub member_past: i64,
|
||||
pub member_current: i64,
|
||||
pub bot_channel_id: ChannelId,
|
||||
|
@ -255,13 +254,9 @@ impl<'r> FromRow<'r, SqliteRow> for Servers {
|
|||
let role_current = match row.try_get("role_current") {
|
||||
Ok(x) => {
|
||||
let tmp: i64 = x;
|
||||
if tmp == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(RoleId::from(tmp as u64))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
RoleId::from(tmp as u64)
|
||||
}
|
||||
_ => RoleId::from(0u64),
|
||||
};
|
||||
|
||||
let bot_channel_tmp: i64 = row.try_get("bot_channel_id")?;
|
||||
|
@ -414,13 +409,13 @@ pub mod set_roles {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(role) = &role_current {
|
||||
if !member.roles.contains(role) {
|
||||
roles_set[1] += 1;
|
||||
roles.push(role.to_owned());
|
||||
}
|
||||
|
||||
if !member.roles.contains(role_current) {
|
||||
roles_set[1] += 1;
|
||||
roles.push(role_current.to_owned());
|
||||
}
|
||||
|
||||
|
||||
if let Err(e) = member.add_roles(ctx, &roles).await {
|
||||
println!("{:?}", e);
|
||||
}
|
||||
|
@ -433,13 +428,12 @@ pub mod set_roles {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(role) = &role_current {
|
||||
if member.roles.contains(role) {
|
||||
roles_set[2] += 1;
|
||||
// if theya re not a current member and have the role then remove it
|
||||
if let Err(e) = member.remove_role(ctx, role).await {
|
||||
println!("{:?}", e);
|
||||
}
|
||||
|
||||
if member.roles.contains(role_current) {
|
||||
roles_set[2] += 1;
|
||||
// if theya re not a current member and have the role then remove it
|
||||
if let Err(e) = member.remove_role(ctx, role_current).await {
|
||||
println!("{:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue