[commands] Provide a way to retrieve time left for a cooldown

This commit is contained in:
Dan Hess authored and GitHub committed 2020-08-05 21:37:08 -04:00
1 parent 09f432016c
commit 3a9fd00a1a
2 files changed
+34 -1

No files matched your search

+9
View File
@@ -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