Skip to content

Commit

Permalink
handle banned or suspended account case
Browse files Browse the repository at this point in the history
  • Loading branch information
AsianIntel committed Nov 25, 2024
1 parent a212646 commit 049e9d9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions rowifi/src/commands/user/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ Your supposed nickname ({nickname}) is greater than 32 characters. Hence, I cann
ctx.respond(&bot).content(&message).unwrap().await?;
return Ok(());
}
UpdateUserError::BannedAccount(user_id) => {
let message = format!(
"Your selected Roblox account for this server is {}. It is believed to be a banned or suspected account. If this is not the case, please contact the RoWifi support server.",
user_id
);
ctx.respond(&bot).content(&message).unwrap().await?;
return Ok(());
}
},
};
tracing::trace!(added_roles = ?added_roles, removed_roles = ?removed_roles, nickname = ?nickname);
Expand Down
17 changes: 14 additions & 3 deletions rowifi_core/src/user/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use rowifi_models::{
discord::cache::{CachedGuild, CachedMember},
guild::{BypassRoleKind, PartialRoGuild},
id::{RoleId, UserId},
roblox::inventory::InventoryItem,
roblox::{inventory::InventoryItem, id::UserId as RobloxUserId},
user::RoUser,
};
use rowifi_roblox::{error::RobloxError, filter::AssetFilterBuilder, RobloxClient};
use rowifi_roblox::{error::{ErrorKind, RobloxError}, filter::AssetFilterBuilder, RobloxClient};
use std::collections::{HashMap, HashSet};
use twilight_http::Client as DiscordClient;

Expand Down Expand Up @@ -41,6 +41,7 @@ pub enum UpdateUserError {
CustombindEvaluation { id: u32, err: EvaluationError },
CustomDenylistParsing { id: u32, err: String },
CustomDenylistEvaluation { id: u32, err: String },
BannedAccount(RobloxUserId)
}

impl UpdateUser<'_> {
Expand All @@ -67,7 +68,17 @@ impl UpdateUser<'_> {
.map(|r| (r.group.id, r.role.rank))
.collect::<HashMap<_, _>>();

let roblox_user = self.roblox.get_user(*user_id).await?;
let roblox_user = match self.roblox.get_user(*user_id).await {
Ok(u) => u,
Err(err) => {
if let ErrorKind::Response { route: _, status, bytes: _ } = err.kind() {
if status.as_u16() == 404 {
return Err(UpdateUserError::BannedAccount(*user_id));
}
}
return Err(err.into());
}
};

let mut asset_filter = AssetFilterBuilder::new();
for assetbind in &self.guild.assetbinds {
Expand Down

0 comments on commit 049e9d9

Please sign in to comment.