|
@ -103,8 +103,7 @@ class CooldownMapping: |
|
|
def from_cooldown(cls, rate, per, type): |
|
|
def from_cooldown(cls, rate, per, type): |
|
|
return cls(Cooldown(rate, per, type)) |
|
|
return cls(Cooldown(rate, per, type)) |
|
|
|
|
|
|
|
|
def _bucket_key(self, ctx): |
|
|
def _bucket_key(self, msg): |
|
|
msg = ctx.message |
|
|
|
|
|
bucket_type = self._cooldown.type |
|
|
bucket_type = self._cooldown.type |
|
|
if bucket_type is BucketType.user: |
|
|
if bucket_type is BucketType.user: |
|
|
return msg.author.id |
|
|
return msg.author.id |
|
@ -122,12 +121,12 @@ class CooldownMapping: |
|
|
for k in dead_keys: |
|
|
for k in dead_keys: |
|
|
del self._cache[k] |
|
|
del self._cache[k] |
|
|
|
|
|
|
|
|
def get_bucket(self, ctx): |
|
|
def get_bucket(self, message): |
|
|
if self._cooldown.type is BucketType.default: |
|
|
if self._cooldown.type is BucketType.default: |
|
|
return self._cooldown |
|
|
return self._cooldown |
|
|
|
|
|
|
|
|
self._verify_cache_integrity() |
|
|
self._verify_cache_integrity() |
|
|
key = self._bucket_key(ctx) |
|
|
key = self._bucket_key(message) |
|
|
if key not in self._cache: |
|
|
if key not in self._cache: |
|
|
bucket = self._cooldown.copy() |
|
|
bucket = self._cooldown.copy() |
|
|
self._cache[key] = bucket |
|
|
self._cache[key] = bucket |
|
|