forked from projectmoon/tenebrous-dicebot
Change execution_allowed to a match for shorter reading.
This commit is contained in:
parent
8f5b6f0636
commit
1ebd13e912
|
@ -109,14 +109,10 @@ pub trait Command: Send + Sync {
|
||||||
/// ever. Later, we can add stuff like admin/regular user power
|
/// ever. Later, we can add stuff like admin/regular user power
|
||||||
/// separation, etc.
|
/// separation, etc.
|
||||||
fn execution_allowed(cmd: &(impl Command + ?Sized), ctx: &Context<'_>) -> Result<(), CommandError> {
|
fn execution_allowed(cmd: &(impl Command + ?Sized), ctx: &Context<'_>) -> Result<(), CommandError> {
|
||||||
if cmd.is_secure() {
|
match cmd {
|
||||||
if ctx.is_secure() {
|
cmd if cmd.is_secure() && ctx.is_secure() => Ok(()),
|
||||||
Ok(())
|
cmd if cmd.is_secure() && !ctx.is_secure() => Err(CommandError::InsecureExecution),
|
||||||
} else {
|
_ => Ok(()),
|
||||||
Err(CommandError::InsecureExecution)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue