Make permissions checking and notification separate functions

This commit is contained in:
2025-08-18 23:45:52 -03:00
parent 0af585cf9e
commit cddda58aca
6 changed files with 21 additions and 21 deletions
+14 -10
View File
@@ -19,19 +19,23 @@ impl Permission<State> for NotBannedPermission {
.map_err(|_| CommandError::DatabaseQueryFailed)?;
if incidents.iter().any(|i| i.is_active()) {
ctx.send()
.content("❌ You've been banned from Payphone.")
.component(CodeOfConductButton, 1)
.component(NeedHelpButton, 1)
.await
.inspect_err(|e| {
log::error!("Failed to send message: {e}");
})
.map_err(|_| CommandError::MessageSendingFailed)?;
Ok(false)
} else {
Ok(true)
}
}
async fn on_handle_denied(&self, ctx: &CommandContext<State>) -> Result<(), CommandError> {
ctx.send()
.content("❌ You've been banned from Payphone.")
.component(CodeOfConductButton, 1)
.component(NeedHelpButton, 1)
.await
.inspect_err(|e| {
log::error!("Failed to send message: {e}");
})
.map_err(|_| CommandError::MessageSendingFailed)?;
Ok(())
}
}