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
+4
View File
@@ -7,4 +7,8 @@ use crate::framework::commands::{CommandError, context::CommandContext};
#[async_trait]
pub trait Permission<S: Send + Sync + 'static>: Debug {
async fn check(&self, ctx: &CommandContext<S>) -> Result<bool, CommandError>;
async fn on_handle_denied(&self, _ctx: &CommandContext<S>) -> Result<(), CommandError> {
Ok(())
}
}
+1
View File
@@ -39,6 +39,7 @@ impl<T: Send + Sync + 'static> OnMessageHandler<T> for CommandRunner {
.await
.inspect_err(|e| log::error!("Permission check failed: {e}"))?
{
permission.on_handle_denied(&ctx).await?;
return Ok(());
}
}