aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-07-13 23:09:22 +0200
committeracdenisSK <[email protected]>2017-07-13 23:09:22 +0200
commiteb47559fa00c13c8fdc8f40a8fe3d06690c0570c (patch)
tree6fa002b4f2c272309899e7912e2a18c5646e3040 /src/framework
parentImprove `BanOptions` to be more efficient and remove uneccessary `Read` imports (diff)
downloadserenity-eb47559fa00c13c8fdc8f40a8fe3d06690c0570c.tar.xz
serenity-eb47559fa00c13c8fdc8f40a8fe3d06690c0570c.zip
Provide the command into the checks
Although in the future, this will be changed to just bits of data of an actual command that wouldn't collide with the framework's code, but would still be useful for a check to use.
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/command.rs2
-rw-r--r--src/framework/create_command.rs2
-rw-r--r--src/framework/mod.rs2
3 files changed, 3 insertions, 3 deletions
diff --git a/src/framework/command.rs b/src/framework/command.rs
index 2aa6bbe..a1c25de 100644
--- a/src/framework/command.rs
+++ b/src/framework/command.rs
@@ -4,7 +4,7 @@ use ::client::Context;
use ::model::{Message, Permissions};
use std::collections::HashMap;
-pub type Check = Fn(&mut Context, &Message) -> bool + Send + Sync + 'static;
+pub type Check = Fn(&mut Context, &Message, &Arc<Command>) -> bool + Send + Sync + 'static;
pub type Exec = Fn(&mut Context, &Message, Vec<String>) -> Result<(), String> + Send + Sync + 'static;
pub type Help = Fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, &[String]) -> Result<(), String> + Send + Sync + 'static;
pub type BeforeHook = Fn(&mut Context, &Message, &String) -> bool + Send + Sync + 'static;
diff --git a/src/framework/create_command.rs b/src/framework/create_command.rs
index abed3ea..804b7c3 100644
--- a/src/framework/create_command.rs
+++ b/src/framework/create_command.rs
@@ -62,7 +62,7 @@ impl CreateCommand {
/// }
/// ```
pub fn check<F>(mut self, check: F) -> Self
- where F: Fn(&mut Context, &Message) -> bool + Send + Sync + 'static {
+ where F: Fn(&mut Context, &Message, &Arc<Command>) -> bool + Send + Sync + 'static {
self.0.checks.push(Box::new(check));
self
diff --git a/src/framework/mod.rs b/src/framework/mod.rs
index c3b683e..cb65682 100644
--- a/src/framework/mod.rs
+++ b/src/framework/mod.rs
@@ -498,7 +498,7 @@ impl Framework {
if command.owners_only {
Some(DispatchError::OnlyForOwners)
- } else if !command.checks.iter().all(|check| (check)(&mut context, message)) {
+ } else if !command.checks.iter().all(|check| (check)(&mut context, message, command)) {
Some(DispatchError::CheckFailed)
} else if self.configuration.blocked_users.contains(&message.author.id) {
Some(DispatchError::BlockedUser)