diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ext/framework/command.rs | 2 | ||||
| -rw-r--r-- | src/ext/framework/mod.rs | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/ext/framework/command.rs b/src/ext/framework/command.rs index 31b2520..43d3c9a 100644 --- a/src/ext/framework/command.rs +++ b/src/ext/framework/command.rs @@ -2,6 +2,6 @@ use std::sync::Arc; use ::client::Context; use ::model::Message; -pub type Command = Fn(Context, Message) + Send + Sync; +pub type Command = Fn(Context, Message, Vec<String>) + Send + Sync; #[doc(hidden)] pub type InternalCommand = Arc<Command>; 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; |