diff options
| author | Austin Hellyer <[email protected]> | 2016-11-07 13:52:50 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-07 13:52:50 -0800 |
| commit | bcdd4f125d029c6d4c8a3ca79ba3ebecdb9515ab (patch) | |
| tree | 77e6edee15c415ec176f507ba44a3a00068c17e1 /src/ext/framework/mod.rs | |
| parent | Re-order MessageType definition (diff) | |
| download | serenity-bcdd4f125d029c6d4c8a3ca79ba3ebecdb9515ab.tar.xz serenity-bcdd4f125d029c6d4c8a3ca79ba3ebecdb9515ab.zip | |
Add arguments to framework commands
Diffstat (limited to 'src/ext/framework/mod.rs')
| -rw-r--r-- | src/ext/framework/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
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::<Vec<String>>(); + + (command)(context, message, args) }); return; @@ -123,7 +128,7 @@ impl Framework { } pub fn on<F, S>(mut self, command_name: S, f: F) -> Self - where F: Fn(Context, Message) + Send + Sync + 'static, + where F: Fn(Context, Message, Vec<String>) + Send + Sync + 'static, S: Into<String> { self.commands.insert(command_name.into(), Arc::new(f)); self.initialized = true; |