aboutsummaryrefslogtreecommitdiff
path: root/src/ext/framework/create_command.rs
diff options
context:
space:
mode:
authortaavi? <[email protected]>2016-12-29 23:21:57 +0300
committerzeyla <[email protected]>2016-12-29 12:21:57 -0800
commitf96b6cc5e1e0383fd2de826c8ffd95565d5ca4fb (patch)
treee49ca34f9a6ce8bda865bed82c8bd2519c4cbcc4 /src/ext/framework/create_command.rs
parentRemove use of struct pattern match (diff)
downloadserenity-f96b6cc5e1e0383fd2de826c8ffd95565d5ca4fb.tar.xz
serenity-f96b6cc5e1e0383fd2de826c8ffd95565d5ca4fb.zip
Add command alias support and command.example
Diffstat (limited to 'src/ext/framework/create_command.rs')
-rw-r--r--src/ext/framework/create_command.rs27
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,
}
}
}