Add support for command permissions to the framework
This commit is contained in:
@@ -31,12 +31,21 @@ impl<T: Send + Sync + 'static> OnMessageHandler<T> for CommandRunner {
|
||||
});
|
||||
|
||||
if let Some(command) = command {
|
||||
command
|
||||
.execute(
|
||||
CommandContext::new(event, rt.clone(), &prefixes[0]),
|
||||
parts.args,
|
||||
)
|
||||
.await?;
|
||||
let ctx = CommandContext::new(event, rt.clone(), &prefixes[0]);
|
||||
|
||||
for permission in command.permissions() {
|
||||
if !permission
|
||||
.check(&ctx)
|
||||
.await
|
||||
.inspect_err(|e| log::error!("Permission check failed: {e}"))?
|
||||
{
|
||||
return Err(
|
||||
format!("The check for permission {permission:?} failed").into()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
command.execute(ctx, parts.args).await?;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user