diff options
| author | Lakelezz <[email protected]> | 2018-07-15 16:48:06 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-07-15 16:48:06 +0200 |
| commit | 29480e5eeccc12afc0e9020373647786736aabc7 (patch) | |
| tree | 347ade11861894d95de87274e5c534d6795b282b /src/framework/standard/create_group.rs | |
| parent | typos (diff) | |
| download | serenity-29480e5eeccc12afc0e9020373647786736aabc7.tar.xz serenity-29480e5eeccc12afc0e9020373647786736aabc7.zip | |
Add checks for groups (#349)
Diffstat (limited to 'src/framework/standard/create_group.rs')
| -rw-r--r-- | src/framework/standard/create_group.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/framework/standard/create_group.rs b/src/framework/standard/create_group.rs index 18f6402..c99b829 100644 --- a/src/framework/standard/create_group.rs +++ b/src/framework/standard/create_group.rs @@ -8,7 +8,8 @@ pub(crate) use super::command::CommandOrAlias; pub use super::{ create_help_command::CreateHelpCommand, create_command::{CreateCommand, FnOrCommand}, - Args + Args, + Check, }; use client::Context; @@ -161,4 +162,18 @@ impl CreateGroup { self } + + /// Adds a "check" to a group, which checks whether or not the groups's + /// commands should be called. + /// + /// **Note**: These checks are bypassed for commands sent by the application owner. + pub fn check<F>(mut self, check: F) -> Self + where F: Fn(&mut Context, &Message, &mut Args, &CommandOptions) -> bool + + Send + + Sync + + 'static { + self.0.checks.push(Check::new(check)); + + self + } } |