mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 17:06:21 +00:00
[commands] Provide a way to retrieve time left for a cooldown
This commit is contained in:
@ -91,6 +91,15 @@ class Cooldown:
|
||||
tokens = self.rate
|
||||
return tokens
|
||||
|
||||
def get_retry_after(self, current=None):
|
||||
current = current or time.time()
|
||||
tokens = self.get_tokens(current)
|
||||
|
||||
if tokens == 0:
|
||||
return self.per - (current - self._window)
|
||||
|
||||
return 0.0
|
||||
|
||||
def update_rate_limit(self, current=None):
|
||||
current = current or time.time()
|
||||
self._last = current
|
||||
|
Reference in New Issue
Block a user