diff options
| author | acdenisSK <[email protected]> | 2017-11-14 15:02:10 +0100 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-11-15 21:09:16 +0100 |
| commit | f10b9d77f0b94864fa20688e3c99de6cec7ca6f9 (patch) | |
| tree | cb7bcd4244ce9813f07cf5eabaa95c71f8c9bb81 /src/framework/standard/create_group.rs | |
| parent | Use the threadpool for framework command execution (diff) | |
| download | serenity-f10b9d77f0b94864fa20688e3c99de6cec7ca6f9.tar.xz serenity-f10b9d77f0b94864fa20688e3c99de6cec7ca6f9.zip | |
Change most of the framework to use trait-based-commands
Diffstat (limited to 'src/framework/standard/create_group.rs')
| -rw-r--r-- | src/framework/standard/create_group.rs | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/src/framework/standard/create_group.rs b/src/framework/standard/create_group.rs index fb3ceb6..f9097e6 100644 --- a/src/framework/standard/create_group.rs +++ b/src/framework/standard/create_group.rs @@ -1,12 +1,11 @@ -pub use super::command::{Command, CommandGroup, CommandType, Error as CommandError}; +pub use super::command::{Command, CommandGroup, CommandOptions, Error as CommandError}; pub(crate) use super::command::CommandOrAlias; +pub(crate) use super::command::A; pub use super::create_command::CreateCommand; pub use super::Args; use client::Context; use model::{Message, Permissions}; -use std::collections::HashMap; -use std::default::Default; use std::sync::Arc; /// Used to create command groups @@ -28,7 +27,7 @@ pub struct CreateGroup(pub CommandGroup); impl CreateGroup { fn build_command(&self) -> CreateCommand { - let mut cmd = CreateCommand(Command::default()) + let mut cmd = CreateCommand(CommandOptions::default(), |_, _, _| Ok(())) .required_permissions(self.0.required_permissions) .dm_only(self.0.dm_only) .guild_only(self.0.guild_only) @@ -45,9 +44,9 @@ impl CreateGroup { /// Adds a command to group. pub fn command<F>(mut self, command_name: &str, f: F) -> Self where F: FnOnce(CreateCommand) -> CreateCommand { - let cmd = f(self.build_command()).0; + let cmd = f(self.build_command()).finish(); - for n in &cmd.aliases { + for n in &cmd.options().aliases { if let Some(ref prefix) = self.0.prefix { self.0.commands.insert( format!("{} {}", prefix, n.to_string()), @@ -63,7 +62,7 @@ impl CreateGroup { self.0.commands.insert( command_name.to_string(), - CommandOrAlias::Command(Arc::new(cmd)), + CommandOrAlias::Command(cmd), ); self @@ -73,7 +72,7 @@ impl CreateGroup { /// You can return Err(From::from(string)) if there's an error. pub fn on(mut self, name: &str, f: fn(&mut Context, &Message, Args) -> Result<(), CommandError>) -> Self { - let cmd = Arc::new(Command::new(f)); + let cmd = Arc::new(A(f)); self.0 .commands @@ -145,19 +144,3 @@ impl CreateGroup { self } } - -impl Default for CommandGroup { - fn default() -> CommandGroup { - CommandGroup { - prefix: None, - commands: HashMap::new(), - bucket: None, - required_permissions: Permissions::empty(), - dm_only: false, - guild_only: false, - help_available: true, - owners_only: false, - allowed_roles: Vec::new(), - } - } -} |