aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-10-08 07:57:58 -0400
committerRapptz <[email protected]>2017-10-08 07:57:58 -0400
commit9b4a2dc7cb073ab76a3f62cfb0176f4f8b99bc94 (patch)
tree4084d35158b1c225c0fb1f4840d9afff681f46b9
parent[commands] Make CooldownMapping.get_bucket take Message instead. (diff)
downloaddiscord.py-9b4a2dc7cb073ab76a3f62cfb0176f4f8b99bc94.tar.xz
discord.py-9b4a2dc7cb073ab76a3f62cfb0176f4f8b99bc94.zip
[commands] Minor speed-up for the BucketType.guild case.
None case: 344ns ± 24.4ns -> 49.9ns ± 1.39ns Valid case: 128ns ± 2.76ns -> 42.7ns ± 0.459ns
-rw-r--r--discord/ext/commands/cooldowns.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py
index 81184e4b..e39e3034 100644
--- a/discord/ext/commands/cooldowns.py
+++ b/discord/ext/commands/cooldowns.py
@@ -108,7 +108,7 @@ class CooldownMapping:
if bucket_type is BucketType.user:
return msg.author.id
elif bucket_type is BucketType.guild:
- return getattr(msg.guild, 'id', msg.author.id)
+ return (msg.guild or msg.author).id
elif bucket_type is BucketType.channel:
return msg.channel.id