aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2018-06-16 19:52:56 +0200
committeracdenisSK <[email protected]>2018-06-16 19:52:56 +0200
commit8114a7ace3ad51b9903a6017993aa526742bd72d (patch)
tree2494b08072cef85664e56eac61d1ea11ca8305f0 /src/framework
parentNeaten debug once more (diff)
downloadserenity-8114a7ace3ad51b9903a6017993aa526742bd72d.tar.xz
serenity-8114a7ace3ad51b9903a6017993aa526742bd72d.zip
Reorganise the order of the ifs
Additionally, make the bucket check cleaner.
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/standard/mod.rs54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs
index 4b5584d..8f24a85 100644
--- a/src/framework/standard/mod.rs
+++ b/src/framework/standard/mod.rs
@@ -492,36 +492,11 @@ impl StandardFramework {
to_check: &str,
built: &str)
-> Option<DispatchError> {
- if self.configuration.ignore_bots && message.author.bot {
+ if self.configuration.ignore_bots || message.author.bot {
Some(DispatchError::IgnoredBot)
} else if self.configuration.ignore_webhooks && message.webhook_id.is_some() {
Some(DispatchError::WebhookAuthor)
- } else if self.configuration.owners.contains(&message.author.id) {
- None
} else {
- if let Some(ref bucket) = command.bucket {
- if let Some(ref mut bucket) = self.buckets.get_mut(bucket) {
- let rate_limit = bucket.take(message.author.id.0);
- match bucket.check {
- Some(ref check) => {
- let apply = feature_cache! {{
- let guild_id = message.guild_id();
- (check)(context, guild_id, message.channel_id, message.author.id)
- } else {
- (check)(context, message.channel_id, message.author.id)
- }};
-
- if apply && rate_limit > 0i64 {
- return Some(DispatchError::RateLimited(rate_limit));
- }
- },
- None => if rate_limit > 0i64 {
- return Some(DispatchError::RateLimited(rate_limit));
- },
- }
- }
- }
-
let len = args.len();
if let Some(x) = command.min_args {
@@ -542,6 +517,33 @@ impl StandardFramework {
}
}
+ if self.configuration.owners.contains(&message.author.id) {
+ return None;
+ }
+
+ if let Some(ref bucket) = command.bucket {
+ if let Some(ref mut bucket) = self.buckets.get_mut(bucket) {
+ let rate_limit = bucket.take(message.author.id.0);
+
+ // Is there a custom check for when this bucket applies?
+ // If not, assert that it does always.
+ let apply = bucket.check.as_ref().map_or(true, |check| {
+ let apply = feature_cache! {{
+ let guild_id = message.guild_id();
+ (check)(context, guild_id, message.channel_id, message.author.id)
+ } else {
+ (check)(context, message.channel_id, message.author.id)
+ }};
+
+ apply
+ });
+
+ if apply && rate_limit > 0i64 {
+ return Some(DispatchError::RateLimited(rate_limit));
+ }
+ }
+ }
+
#[cfg(feature = "cache")]
{
if self.is_blocked_guild(message) {