From 18cc152769a35cd1705f045b9815cc90446034ef Mon Sep 17 00:00:00 2001 From: Taavi Date: Mon, 2 Jan 2017 03:38:36 +0300 Subject: Implement context message queueing Also the dreaded `ctx <<= "something"` which is actually a mistake. --- src/ext/framework/create_command.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ext/framework/create_command.rs') diff --git a/src/ext/framework/create_command.rs b/src/ext/framework/create_command.rs index c758f4a..4d1e1a5 100644 --- a/src/ext/framework/create_command.rs +++ b/src/ext/framework/create_command.rs @@ -54,19 +54,19 @@ impl CreateCommand { /// .desc("Replies to a ping with a pong") /// .exec(ping))); /// - /// fn ping(context: &Context, _message: &Message, _args: Vec) -> Result<(), String> { + /// fn ping(context: &mut Context, _message: &Message, _args: Vec) -> Result<(), String> { /// let _ = context.say("Pong!"); /// /// Ok(()) /// } /// - /// fn owner_check(_context: &Context, message: &Message) -> bool { + /// fn owner_check(_context: &mut Context, message: &Message) -> bool { /// // replace with your user ID /// message.author.id == 7 /// } /// ``` pub fn check(mut self, check: F) -> Self - where F: Fn(&Context, &Message) -> bool + Send + Sync + 'static { + where F: Fn(&mut Context, &Message) -> bool + Send + Sync + 'static { self.0.checks.push(Box::new(check)); self @@ -100,7 +100,7 @@ impl CreateCommand { /// /// [`exec_str`]: #method.exec_str pub fn exec(mut self, func: F) -> Self - where F: Fn(&Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static { + where F: Fn(&mut Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static { self.0.exec = CommandType::Basic(Box::new(func)); self @@ -112,7 +112,7 @@ impl CreateCommand { /// /// You can return Err(string) if there's an error. pub fn exec_help(mut self, f: F) -> Self - where F: Fn(&Context, &Message, HashMap>, Vec) -> Result<(), String> + Send + Sync + 'static { + where F: Fn(&mut Context, &Message, HashMap>, Vec) -> Result<(), String> + Send + Sync + 'static { self.0.exec = CommandType::WithCommands(Box::new(f)); self -- cgit v1.2.3