diff options
| author | Austin Hellyer <[email protected]> | 2016-12-14 08:54:41 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-12-14 08:54:41 -0800 |
| commit | d9e585f008c26f1908982e75b0cdece73d1ade2c (patch) | |
| tree | 9298a1f34ee9d7ab6c96123f48ec40e213eedbee /src/ext/framework/create_group.rs | |
| parent | Don't mutate token for bots on profile change (diff) | |
| download | serenity-d9e585f008c26f1908982e75b0cdece73d1ade2c.tar.xz serenity-d9e585f008c26f1908982e75b0cdece73d1ade2c.zip | |
Slightly rework framework buckets
Diffstat (limited to 'src/ext/framework/create_group.rs')
| -rw-r--r-- | src/ext/framework/create_group.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/ext/framework/create_group.rs b/src/ext/framework/create_group.rs index db2832b..8374e8b 100644 --- a/src/ext/framework/create_group.rs +++ b/src/ext/framework/create_group.rs @@ -24,34 +24,34 @@ pub struct CreateGroup(pub CommandGroup); /// .exec_str("meew0"))) /// ``` impl CreateGroup { - /// 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". - /// - /// **Note**: serenity automatically puts a space after group prefix. - pub fn prefix(mut self, desc: &str) -> Self { - self.0.prefix = Some(desc.to_owned()); - - self - } - /// Adds a command to group. - pub fn command<F, S>(mut self, command_name: S, f: F) -> Self - where F: FnOnce(CreateCommand) -> CreateCommand, - S: Into<String> { + pub fn command<F>(mut self, command_name: &str, f: F) -> Self + where F: FnOnce(CreateCommand) -> CreateCommand { let cmd = f(CreateCommand(Command::default())).0; - self.0.commands.insert(command_name.into(), Arc::new(cmd)); + self.0.commands.insert(command_name.to_owned(), Arc::new(cmd)); self } /// Adds a command to group with simplified API. /// You can return Err(string) if there's an error. - pub fn on<F, S>(mut self, command_name: S, f: F) -> Self - where F: Fn(&Context, &Message, Vec<String>) -> Result<(), String> + Send + Sync + 'static, - S: Into<String> { - self.0.commands.insert(command_name.into(), Arc::new(Command::new(f))); + pub fn on<F>(mut self, command_name: &str, f: F) -> Self + where F: Fn(&Context, &Message, Vec<String>) -> Result<(), String> + Send + Sync + 'static { + let cmd = Arc::new(Command::new(f)); + + self.0.commands.insert(command_name.to_owned(), cmd); + + 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". + /// + /// **Note**: serenity automatically puts a space after group prefix. + pub fn prefix(mut self, desc: &str) -> Self { + self.0.prefix = Some(desc.to_owned()); self } |