[commands] Added BucketType.members for cooldowns
This commit is contained in:
parent
95721da70e
commit
00a14a46f3
@ -33,6 +33,7 @@ class BucketType(enum.Enum):
|
|||||||
user = 1
|
user = 1
|
||||||
guild = 2
|
guild = 2
|
||||||
channel = 3
|
channel = 3
|
||||||
|
member = 4
|
||||||
|
|
||||||
class Cooldown:
|
class Cooldown:
|
||||||
__slots__ = ('rate', 'per', 'type', '_window', '_tokens', '_last')
|
__slots__ = ('rate', 'per', 'type', '_window', '_tokens', '_last')
|
||||||
@ -111,6 +112,8 @@ class CooldownMapping:
|
|||||||
return (msg.guild or msg.author).id
|
return (msg.guild or msg.author).id
|
||||||
elif bucket_type is BucketType.channel:
|
elif bucket_type is BucketType.channel:
|
||||||
return msg.channel.id
|
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):
|
def _verify_cache_integrity(self):
|
||||||
# we want to delete all cache objects that haven't been used
|
# 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.user`` for a per-user basis.
|
||||||
- ``BucketType.guild`` for a per-guild basis.
|
- ``BucketType.guild`` for a per-guild basis.
|
||||||
- ``BucketType.channel`` for a per-channel 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
|
If a cooldown is triggered, then :exc:`.CommandOnCooldown` is triggered in
|
||||||
:func:`.on_command_error` and the local error handler.
|
:func:`.on_command_error` and the local error handler.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user