Skip to content

Commit

Permalink
potential fix for unknown webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
AsianIntel committed Nov 30, 2024
1 parent a9aa616 commit 6581863
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
17 changes: 4 additions & 13 deletions rowifi/src/commands/user/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ use itertools::Itertools;
use rowifi_core::user::update::{UpdateUser, UpdateUserError};
use rowifi_framework::prelude::*;
use rowifi_models::{
deny_list::DenyListActionType,
discord::{
http::interaction::{InteractionResponse, InteractionResponseType},
util::Timestamp,
},
guild::BypassRoleKind,
id::UserId,
deny_list::DenyListActionType, discord::util::Timestamp, guild::BypassRoleKind, id::UserId,
user::RoUser,
};
use std::{error::Error, fmt::Write};
Expand All @@ -27,16 +21,12 @@ pub async fn update_route(
bot: Extension<BotContext>,
command: Command<UpdateArguments>,
) -> impl IntoResponse {
tokio::spawn(async move {
let _ = tokio::spawn(async move {
if let Err(err) = update_func(&bot, &command.ctx, command.args).await {
handle_error(bot.0, command.ctx, err).await;
}
});

Json(InteractionResponse {
kind: InteractionResponseType::DeferredChannelMessageWithSource,
data: None,
})
.await;
}

#[allow(clippy::too_many_lines)]
Expand All @@ -46,6 +36,7 @@ pub async fn update_func(
ctx: &CommandContext,
args: UpdateArguments,
) -> CommandResult {
ctx.defer_response(bot, DeferredResponse::Normal).await?;
tracing::debug!("update command invoked");
let server = bot.server(ctx.guild_id).await?;

Expand Down
21 changes: 16 additions & 5 deletions rowifi_core/src/user/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ use rowifi_models::{
discord::cache::{CachedGuild, CachedMember},
guild::{BypassRoleKind, PartialRoGuild},
id::{RoleId, UserId},
roblox::{inventory::InventoryItem, id::UserId as RobloxUserId},
roblox::{id::UserId as RobloxUserId, inventory::InventoryItem},
user::RoUser,
};
use rowifi_roblox::{error::{ErrorKind, 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,7 +45,7 @@ pub enum UpdateUserError {
CustombindEvaluation { id: u32, err: EvaluationError },
CustomDenylistParsing { id: u32, err: String },
CustomDenylistEvaluation { id: u32, err: String },
BannedAccount(RobloxUserId)
BannedAccount(RobloxUserId),
}

impl UpdateUser<'_> {
Expand Down Expand Up @@ -71,7 +75,12 @@ impl UpdateUser<'_> {
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 let ErrorKind::Response {
route: _,
status,
bytes: _,
} = err.kind()
{
if status.as_u16() == 404 {
return Err(UpdateUserError::BannedAccount(*user_id));
}
Expand Down Expand Up @@ -249,7 +258,9 @@ impl UpdateUser<'_> {
added_roles.push(*bind_role);
}
} else {
if self.member.roles.contains(bind_role) && !self.guild.sticky_roles.contains(bind_role) {
if self.member.roles.contains(bind_role)
&& !self.guild.sticky_roles.contains(bind_role)
{
removed_roles.push(*bind_role);
}
}
Expand Down

0 comments on commit 6581863

Please sign in to comment.