aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands/cooldowns.py
diff options
context:
space:
mode:
authorDan Hess <[email protected]>2020-08-05 20:37:08 -0500
committerGitHub <[email protected]>2020-08-05 21:37:08 -0400
commit3a9fd00a1adea76c0821b958b56dbf83e6f19b36 (patch)
tree5b373e4c9759884f221e5746d79f20cfb0f297a6 /discord/ext/commands/cooldowns.py
parent[commands] Restart subcommand_passed chain on invoke (diff)
downloaddiscord.py-3a9fd00a1adea76c0821b958b56dbf83e6f19b36.tar.xz
discord.py-3a9fd00a1adea76c0821b958b56dbf83e6f19b36.zip
[commands] Provide a way to retrieve time left for a cooldown
Diffstat (limited to 'discord/ext/commands/cooldowns.py')
-rw-r--r--discord/ext/commands/cooldowns.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py
index 08f36b60..c530bb12 100644
--- a/discord/ext/commands/cooldowns.py
+++ b/discord/ext/commands/cooldowns.py
@@ -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