mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 00:07:51 +00:00
[commands] Added BucketType.members for cooldowns
This commit is contained in:
parent
95721da70e
commit
00a14a46f3
@ -31,8 +31,9 @@ __all__ = ['BucketType', 'Cooldown', 'CooldownMapping']
|
||||
class BucketType(enum.Enum):
|
||||
default = 0
|
||||
user = 1
|
||||
guild = 2
|
||||
guild = 2
|
||||
channel = 3
|
||||
member = 4
|
||||
|
||||
class Cooldown:
|
||||
__slots__ = ('rate', 'per', 'type', '_window', '_tokens', '_last')
|
||||
@ -111,6 +112,8 @@ class CooldownMapping:
|
||||
return (msg.guild or msg.author).id
|
||||
elif bucket_type is BucketType.channel:
|
||||
return msg.channel.id
|
||||
elif bucket_type is BucketType.member:
|
||||
return ((msg.guild and msg.guild.id), msg.author.id)
|
||||
|
||||
def _verify_cache_integrity(self):
|
||||
# we want to delete all cache objects that haven't been used
|
||||
|
@ -1321,6 +1321,7 @@ def cooldown(rate, per, type=BucketType.default):
|
||||
- ``BucketType.user`` for a per-user basis.
|
||||
- ``BucketType.guild`` for a per-guild basis.
|
||||
- ``BucketType.channel`` for a per-channel basis.
|
||||
- ``BucketType.member`` for a per-member basis.
|
||||
|
||||
If a cooldown is triggered, then :exc:`.CommandOnCooldown` is triggered in
|
||||
:func:`.on_command_error` and the local error handler.
|
||||
|
Loading…
x
Reference in New Issue
Block a user