diff options
| author | Lakelezz <[email protected]> | 2017-11-20 15:06:17 +0100 |
|---|---|---|
| committer | alex <[email protected]> | 2017-11-20 15:06:17 +0100 |
| commit | 39a1435be57335e99039ddea731032221eb6d96e (patch) | |
| tree | e6f0daf1df21988ec59d9f507ef075b2c2308785 /src/framework/standard/command.rs | |
| parent | Have `on`'s docs actually use itself (diff) | |
| download | serenity-39a1435be57335e99039ddea731032221eb6d96e.tar.xz serenity-39a1435be57335e99039ddea731032221eb6d96e.zip | |
Add `help()` to `CreateGroup`. (#225)
Diffstat (limited to 'src/framework/standard/command.rs')
| -rw-r--r-- | src/framework/standard/command.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index 6b90479..5633fd6 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -2,6 +2,7 @@ use client::Context; use model::{Message, Permissions}; use std::collections::HashMap; use std::fmt; +use std::fmt::{Debug, Formatter}; use std::sync::Arc; use super::{Args, Configuration}; @@ -9,8 +10,18 @@ pub type Check = Fn(&mut Context, &Message, &mut Args, &CommandOptions) -> bool + Send + Sync + 'static; -pub type Help = fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, Args) + +pub type HelpFunction = fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, Args) -> Result<(), Error>; + +pub struct Help(pub HelpFunction); + +impl Debug for Help { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "fn()") + } +} + pub type BeforeHook = Fn(&mut Context, &Message, &str) -> bool + Send + Sync + 'static; pub type AfterHook = Fn(&mut Context, &Message, &str, Result<(), Error>) + Send + Sync + 'static; pub(crate) type InternalCommand = Arc<Command>; @@ -53,6 +64,7 @@ pub struct CommandGroup { pub dm_only: bool, pub guild_only: bool, pub owners_only: bool, + pub help: Option<Arc<Help>>, } impl Default for CommandGroup { @@ -67,6 +79,7 @@ impl Default for CommandGroup { help_available: true, owners_only: false, allowed_roles: Vec::new(), + help: None, } } } |