diff options
Diffstat (limited to 'src/ext/framework/create_command.rs')
| -rw-r--r-- | src/ext/framework/create_command.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/ext/framework/create_command.rs b/src/ext/framework/create_command.rs index 06d412a..c758f4a 100644 --- a/src/ext/framework/create_command.rs +++ b/src/ext/framework/create_command.rs @@ -16,6 +16,22 @@ impl CreateCommand { self } + /// Adds an alias, allowing users to use the command under a different name. + pub fn known_as(mut self, name: &str) -> Self { + self.0.aliases.push(name.to_owned()); + + self + } + + /// Adds multiple aliases. + pub fn batch_known_as(mut self, names: Vec<&str>) -> Self { + for n in names { + self.0.aliases.push(n.to_owned()); + } + + self + } + /// Adds a "check" to a command, which checks whether or not the command's /// function should be called. /// @@ -70,6 +86,13 @@ impl CreateCommand { self } + /// Example arguments, used by other commands. + pub fn example(mut self, example: &str) -> Self { + self.0.example = Some(example.to_owned()); + + self + } + /// A function that can be called when a command is received. /// You can return Err(string) if there's an error. /// @@ -183,10 +206,12 @@ impl CreateCommand { impl Default for Command { fn default() -> Command { Command { + aliases: Vec::new(), checks: Vec::default(), exec: CommandType::Basic(Box::new(|_, _, _| Ok(()))), desc: None, usage: None, + example: None, use_quotes: false, min_args: None, bucket: None, @@ -195,7 +220,7 @@ impl Default for Command { dm_only: false, guild_only: false, help_available: true, - owners_only: false + owners_only: false, } } } |