From d9e585f008c26f1908982e75b0cdece73d1ade2c Mon Sep 17 00:00:00 2001 From: Austin Hellyer Date: Wed, 14 Dec 2016 08:54:41 -0800 Subject: Slightly rework framework buckets --- src/ext/framework/create_group.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/ext/framework/create_group.rs') 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(mut self, command_name: S, f: F) -> Self - where F: FnOnce(CreateCommand) -> CreateCommand, - S: Into { + pub fn command(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(mut self, command_name: S, f: F) -> Self - where F: Fn(&Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static, - S: Into { - self.0.commands.insert(command_name.into(), Arc::new(Command::new(f))); + pub fn on(mut self, command_name: &str, f: F) -> Self + where F: Fn(&Context, &Message, Vec) -> 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 } -- cgit v1.2.3