From e44838f4339b90817b5eba5df16230b02487f0cc Mon Sep 17 00:00:00 2001 From: Illia Date: Sat, 10 Dec 2016 22:25:55 +0200 Subject: More config for CreateCommand, add various methods Adds multiple configurations to the command builder, and adds methods to various structs. Context::get_current_user is a shortcut to retrieve the current user from the cache. Message::get_member retrieves the member object of the message, if sent in a guild. Message::is_private checks if the message was sent in a Group or PrivateChannel. User::member retrieves the user's member object in a guild by Id; Adds 6 configurations to the command builder: - dm_only: whether the command can only be used in direct messages; - guild_only: whether the command can only be used in guilds; - help_available: whether the command should be displayed in the help list; - max_args: specify the maximum number of arguments a command must be given; - min_args: specify the minimum number of arguments a command must be given; - required_permissions: the permissions a member must have to be able to use the command; --- src/ext/framework/command.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/ext/framework/command.rs') diff --git a/src/ext/framework/command.rs b/src/ext/framework/command.rs index b7d5bb8..204c90c 100644 --- a/src/ext/framework/command.rs +++ b/src/ext/framework/command.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use super::Configuration; use ::client::Context; use ::model::Message; +use ::model::Permissions; use std::collections::HashMap; pub type Check = Fn(&Context, &Message) -> bool + Send + Sync + 'static; @@ -33,6 +34,18 @@ pub struct Command { pub usage: Option, /// Whether arguments should be parsed using quote parser or not. pub use_quotes: bool, + /// Minumum amount of arguments that should be passed. + pub min_args: Option, + /// Maximum amount of arguments that can be passed. + pub max_args: Option, + /// Permissions required to use this command. + pub required_permissions: Permissions, + /// Whether command should be displayed in help list or not, used by other commands. + pub help_available: bool, + /// Whether command can be used only privately or not. + pub dm_only: bool, + /// Whether command can be used only in guilds or not. + pub guild_only: bool, } pub fn positions(ctx: &Context, content: &str, conf: &Configuration) -> Option> { -- cgit v1.2.3