aboutsummaryrefslogtreecommitdiff
path: root/src/framework/standard/create_group.rs
diff options
context:
space:
mode:
authorLakelezz <[email protected]>2017-11-20 15:06:17 +0100
committeralex <[email protected]>2017-11-20 15:06:17 +0100
commit39a1435be57335e99039ddea731032221eb6d96e (patch)
treee6f0daf1df21988ec59d9f507ef075b2c2308785 /src/framework/standard/create_group.rs
parentHave `on`'s docs actually use itself (diff)
downloadserenity-39a1435be57335e99039ddea731032221eb6d96e.tar.xz
serenity-39a1435be57335e99039ddea731032221eb6d96e.zip
Add `help()` to `CreateGroup`. (#225)
Diffstat (limited to 'src/framework/standard/create_group.rs')
-rw-r--r--src/framework/standard/create_group.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/framework/standard/create_group.rs b/src/framework/standard/create_group.rs
index 4aadffc..abdfdc8 100644
--- a/src/framework/standard/create_group.rs
+++ b/src/framework/standard/create_group.rs
@@ -1,5 +1,6 @@
pub use super::command::{Command, CommandGroup, CommandOptions, Error as CommandError};
pub(crate) use super::command::CommandOrAlias;
+pub(crate) use super::command::{Help, HelpFunction};
pub use super::create_command::{CreateCommand, FnOrCommand};
pub use super::Args;
@@ -73,13 +74,13 @@ impl CreateGroup {
f: fn(&mut Context, &Message, Args) -> Result<(), CommandError>) -> Self {
self.cmd(name, f)
}
-
+
/// Like [`on`], but accepts a `Command` directly.
///
/// [`on`]: #method.on
pub fn cmd<C: Command + 'static>(mut self, name: &str, c: C) -> Self {
let cmd = Arc::new(c);
-
+
self.0
.commands
.insert(name.to_string(), CommandOrAlias::Command(cmd));
@@ -87,6 +88,13 @@ impl CreateGroup {
self
}
+ /// Sets what code should be execute when a user requests for `(prefix)help`.
+ pub fn help(mut self, f: HelpFunction) -> Self {
+ self.0.help = Some(Arc::new(Help(f)));
+
+ self
+ }
+
/// If prefix is set, it will be required before all command names.
/// For example, if bot prefix is "~" and group prefix is "image"
/// we'd call a subcommand named "hibiki" by sending "~image hibiki".