diff options
| author | Dice <[email protected]> | 2018-11-04 01:51:03 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2018-11-24 22:51:18 -0500 |
| commit | 5a585ebf20fdf346fdd46af35df11cfc3dd85665 (patch) | |
| tree | f1c9de21fec72b0d195e5122bea726bac46903db /discord/ext/commands/cooldowns.py | |
| parent | Outline the logic of `bool` converters (diff) | |
| download | discord.py-5a585ebf20fdf346fdd46af35df11cfc3dd85665.tar.xz discord.py-5a585ebf20fdf346fdd46af35df11cfc3dd85665.zip | |
Add channel category cooldown bucket type
Diffstat (limited to 'discord/ext/commands/cooldowns.py')
| -rw-r--r-- | discord/ext/commands/cooldowns.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py index 196d00fc..d44365b2 100644 --- a/discord/ext/commands/cooldowns.py +++ b/discord/ext/commands/cooldowns.py @@ -30,11 +30,12 @@ import time __all__ = ['BucketType', 'Cooldown', 'CooldownMapping'] class BucketType(enum.Enum): - default = 0 - user = 1 - guild = 2 - channel = 3 - member = 4 + default = 0 + user = 1 + guild = 2 + channel = 3 + member = 4 + category = 5 class Cooldown: __slots__ = ('rate', 'per', 'type', '_window', '_tokens', '_last') @@ -115,6 +116,8 @@ class CooldownMapping: return msg.channel.id elif bucket_type is BucketType.member: return ((msg.guild and msg.guild.id), msg.author.id) + elif bucket_type is BucketType.category: + return (msg.channel.category or msg.channel).id def _verify_cache_integrity(self): # we want to delete all cache objects that haven't been used |