From bcdd4f125d029c6d4c8a3ca79ba3ebecdb9515ab Mon Sep 17 00:00:00 2001 From: Austin Hellyer Date: Mon, 7 Nov 2016 13:52:50 -0800 Subject: Add arguments to framework commands --- src/ext/framework/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ext/framework/mod.rs') diff --git a/src/ext/framework/mod.rs b/src/ext/framework/mod.rs index c504d53..1949e24 100644 --- a/src/ext/framework/mod.rs +++ b/src/ext/framework/mod.rs @@ -113,7 +113,12 @@ impl Framework { let command = command.clone(); thread::spawn(move || { - (command)(context, message) + let args = message.content[built.len() + 1..] + .split_whitespace() + .map(|arg| arg.to_owned()) + .collect::>(); + + (command)(context, message, args) }); return; @@ -123,7 +128,7 @@ impl Framework { } pub fn on(mut self, command_name: S, f: F) -> Self - where F: Fn(Context, Message) + Send + Sync + 'static, + where F: Fn(Context, Message, Vec) + Send + Sync + 'static, S: Into { self.commands.insert(command_name.into(), Arc::new(f)); self.initialized = true; -- cgit v1.2.3