From f96b6cc5e1e0383fd2de826c8ffd95565d5ca4fb Mon Sep 17 00:00:00 2001 From: taavi? Date: Thu, 29 Dec 2016 23:21:57 +0300 Subject: Add command alias support and command.example --- src/ext/framework/command.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/ext/framework/command.rs') diff --git a/src/ext/framework/command.rs b/src/ext/framework/command.rs index acddca9..92e6e93 100644 --- a/src/ext/framework/command.rs +++ b/src/ext/framework/command.rs @@ -14,6 +14,12 @@ pub type AfterHook = Fn(&Context, &Message, &String, Result<(), String>) + Send pub type InternalCommand = Arc; pub type PrefixCheck = Fn(&Context) -> Option + Send + Sync + 'static; +#[doc(hidden)] +pub enum CommandOrAlias { + Alias(String), + Command(InternalCommand), +} + /// Command function type. Allows to access internal framework things inside /// your commands. pub enum CommandType { @@ -25,7 +31,7 @@ pub enum CommandType { #[derive(Default)] pub struct CommandGroup { pub prefix: Option, - pub commands: HashMap, + pub commands: HashMap, } /// Command struct used to store commands internally. @@ -39,6 +45,8 @@ pub struct Command { pub bucket: Option, /// Command description, used by other commands. pub desc: Option, + /// Example arguments, used by other commands. + pub example: Option, /// Command usage schema, used by other commands. pub usage: Option, /// Whether arguments should be parsed using quote parser or not. @@ -57,16 +65,20 @@ pub struct Command { pub guild_only: bool, /// Whether command can only be used by owners or not. pub owners_only: bool, + #[doc(hidden)] + pub aliases: Vec, } impl Command { pub fn new(f: F) -> Self where F: Fn(&Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static { Command { + aliases: Vec::new(), checks: Vec::default(), exec: CommandType::Basic(Box::new(f)), desc: None, usage: None, + example: None, use_quotes: false, dm_only: false, bucket: None, @@ -74,8 +86,8 @@ impl Command { help_available: true, min_args: None, max_args: None, - required_permissions: Permissions::empty(), owners_only: false, + required_permissions: Permissions::empty(), } } } -- cgit v1.2.3