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/configuration.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/ext/framework/configuration.rs') diff --git a/src/ext/framework/configuration.rs b/src/ext/framework/configuration.rs index 9caa48b..e95faea 100644 --- a/src/ext/framework/configuration.rs +++ b/src/ext/framework/configuration.rs @@ -3,6 +3,18 @@ use super::command::PrefixCheck; use ::client::rest; use ::client::Context; +/// Account type used for configuration. +pub enum AccountType { + /// Connected client will only listen to itself. + Selfbot, + /// Connected client will ignore all bot accounts. + Bot, + /// Connected client will listen to everyone. + Any, + #[doc(hidden)] + Automatic +} + /// The configuration to use for a [`Framework`] associated with a [`Client`] /// instance. /// @@ -36,6 +48,8 @@ pub struct Configuration { pub prefixes: Vec, #[doc(hidden)] pub dynamic_prefix: Option>, + #[doc(hidden)] + pub account_type: AccountType } impl Configuration { @@ -136,6 +150,13 @@ impl Configuration { self } + /// Allows you to change what accounts to ignore. + pub fn account_type(mut self, account_type: AccountType) -> Self { + self.account_type = account_type; + + self + } + /// Sets the prefix to respond to. This can either be a single-char or /// multi-char string. pub fn dynamic_prefix(mut self, dynamic_prefix: F) -> Self @@ -159,7 +180,8 @@ impl Default for Configuration { on_mention: None, allow_whitespace: false, prefixes: vec![], - dynamic_prefix: None + dynamic_prefix: None, + account_type: AccountType::Automatic } } } -- cgit v1.2.3