diff options
| author | Illia <[email protected]> | 2017-04-20 00:51:34 +0300 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-04-19 14:51:34 -0700 |
| commit | 31aae7d12763f94a7a08ea9fd0102921e8402241 (patch) | |
| tree | 76e0b54954ee02140ad6bd409a73e16943bda5f8 /src/ext/framework/configuration.rs | |
| parent | Fix example in README (diff) | |
| download | serenity-31aae7d12763f94a7a08ea9fd0102921e8402241.tar.xz serenity-31aae7d12763f94a7a08ea9fd0102921e8402241.zip | |
Update the way errors are handled in dispatch
Diffstat (limited to 'src/ext/framework/configuration.rs')
| -rw-r--r-- | src/ext/framework/configuration.rs | 149 |
1 files changed, 7 insertions, 142 deletions
diff --git a/src/ext/framework/configuration.rs b/src/ext/framework/configuration.rs index b5c58c9..46174b4 100644 --- a/src/ext/framework/configuration.rs +++ b/src/ext/framework/configuration.rs @@ -4,29 +4,6 @@ use super::command::PrefixCheck; use ::client::{Context, rest}; use ::model::{GuildId, UserId}; -/// The account type used when setting the framework [`Configuration`]. -/// -/// [`Configuration`]: struct.Configuration.html -pub enum AccountType { - /// The current user will only react to [`Message`]s sent by itself. - /// - /// [`Message`]: ../../model/struct.Message.html - Selfbot, - /// The current user will only react to [`Message`]s sent by [`User`]s which - /// are _not_ [bot][`User::bot`]s. - /// - /// [`Message`]: ../../model/struct.Message.html - /// [`User`]: ../../model/struct.User.html - /// [`User::bot`]: ../../model/struct.User.html#structfield.bot - Bot, - /// The current user will react to all [`Message`]s. - /// - /// [`Message`]: ../../model/struct.Message.html - Any, - #[doc(hidden)] - Automatic, -} - /// The configuration to use for a [`Framework`] associated with a [`Client`] /// instance. /// @@ -61,27 +38,7 @@ pub struct Configuration { #[doc(hidden)] pub dynamic_prefix: Option<Box<PrefixCheck>>, #[doc(hidden)] - pub rate_limit_message: Option<String>, - #[doc(hidden)] - pub invalid_permission_message: Option<String>, - #[doc(hidden)] - pub invalid_check_message: Option<String>, - #[doc(hidden)] - pub no_dm_message: Option<String>, - #[doc(hidden)] - pub no_guild_message: Option<String>, - #[doc(hidden)] - pub blocked_user_message: Option<String>, - #[doc(hidden)] - pub blocked_guild_message: Option<String>, - #[doc(hidden)] - pub too_many_args_message: Option<String>, - #[doc(hidden)] - pub not_enough_args_message: Option<String>, - #[doc(hidden)] - pub command_disabled_message: Option<String>, - #[doc(hidden)] - pub account_type: AccountType, + pub ignore_bots: bool, #[doc(hidden)] pub blocked_users: HashSet<UserId>, #[doc(hidden)] @@ -97,9 +54,11 @@ pub struct Configuration { } impl Configuration { - /// Allows you to change what accounts to ignore. - pub fn account_type(mut self, account_type: AccountType) -> Self { - self.account_type = account_type; + /// Whether the bot should respond to other bots. + /// + /// For example, if this is set to false, then the bot will respond to any other bots including itself. + pub fn ignore_bots(mut self, ignore_bots: bool) -> Self { + self.ignore_bots = ignore_bots; self } @@ -194,79 +153,6 @@ impl Configuration { self } - /// Message that's sent when one of a command's checks doesn't succeed. - pub fn invalid_check_message(mut self, content: &str) -> Self { - self.invalid_check_message = Some(content.to_owned()); - - self - } - - /// Message that's sent if a command is disabled. - /// - /// `%command%` will be replaced with command name. - pub fn command_disabled_message(mut self, content: &str) -> Self { - self.command_disabled_message = Some(content.to_owned()); - - self - } - - /// Message that's sent if a blocked user attempts to use a command. - pub fn blocked_user_message(mut self, content: &str) -> Self { - self.blocked_user_message = Some(content.to_owned()); - - self - } - - /// Message that's sent if a command issued within a guild owned by a - /// blocked user. - pub fn blocked_guild_message(mut self, content: &str) -> Self { - self.blocked_guild_message = Some(content.to_owned()); - - self - } - - /// Message that's sent when a user with wrong permissions calls a command. - pub fn invalid_permission_message(mut self, content: &str) -> Self { - self.invalid_permission_message = Some(content.to_owned()); - - self - } - - /// Message that's sent when a command is on cooldown. - /// See framework documentation to see where is this utilized. - /// - /// `%time%` will be replaced with waiting time in seconds. - pub fn rate_limit_message(mut self, content: &str) -> Self { - self.rate_limit_message = Some(content.to_owned()); - - self - } - - /// Message that's sent when a command isn't available in DM. - pub fn no_dm_message(mut self, content: &str) -> Self { - self.no_dm_message = Some(content.to_owned()); - - self - } - - /// Message that's sent when a command isn't available in guilds. - pub fn no_guild_message(mut self, content: &str) -> Self { - self.no_guild_message = Some(content.to_owned()); - - self - } - - /// Message that's sent when user sends too few arguments to a command. - /// - /// `%min%` will be replaced with minimum allowed amount of arguments. - /// - /// `%given%` will be replced with the given amount of arguments. - pub fn not_enough_args_message(mut self, content: &str) -> Self { - self.not_enough_args_message = Some(content.to_owned()); - - self - } - /// Whether or not to respond to commands initiated with a mention. Note /// that this can be used in conjunction with [`prefix`]. /// @@ -325,17 +211,6 @@ impl Configuration { self } - - /// Message that's sent when user sends too many arguments to a command. - /// - /// `%max%` will be replaced with maximum allowed amount of arguments. - /// - /// `%given%` will be replced with the given amount of arguments. - pub fn too_many_args_message(mut self, content: &str) -> Self { - self.too_many_args_message = Some(content.to_owned()); - - self - } } impl Default for Configuration { @@ -352,17 +227,7 @@ impl Default for Configuration { dynamic_prefix: None, allow_whitespace: false, prefixes: vec![], - no_dm_message: None, - no_guild_message: None, - rate_limit_message: None, - blocked_user_message: None, - too_many_args_message: None, - invalid_check_message: None, - blocked_guild_message: None, - not_enough_args_message: None, - command_disabled_message: None, - invalid_permission_message: None, - account_type: AccountType::Automatic, + ignore_bots: true, owners: HashSet::default(), blocked_users: HashSet::default(), blocked_guilds: HashSet::default(), |