aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-08-25 23:15:26 -0400
committerRapptz <[email protected]>2020-08-25 23:15:26 -0400
commit4203e7a5a830ee2a05e9642ef83721d05c9e21f6 (patch)
treeed854f0806091823182d3748e7339abb3e64aa75
parentFix issue with empty overwrites (diff)
downloaddiscord.py-4203e7a5a830ee2a05e9642ef83721d05c9e21f6.tar.xz
discord.py-4203e7a5a830ee2a05e9642ef83721d05c9e21f6.zip
[commands] Use edited timestamp if provided for cooldown timing
-rw-r--r--discord/ext/commands/core.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 5b0971ae..2153968c 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -764,7 +764,8 @@ class Command(_BaseCommand):
def _prepare_cooldowns(self, ctx):
if self._buckets.valid:
- current = ctx.message.created_at.replace(tzinfo=datetime.timezone.utc).timestamp()
+ dt = ctx.message.edited_at or ctx.message.created_at
+ current = dt.replace(tzinfo=datetime.timezone.utc).timestamp()
bucket = self._buckets.get_bucket(ctx.message, current)
retry_after = bucket.update_rate_limit(current)
if retry_after:
@@ -805,7 +806,8 @@ class Command(_BaseCommand):
return False
bucket = self._buckets.get_bucket(ctx.message)
- current = ctx.message.created_at.replace(tzinfo=datetime.timezone.utc).timestamp()
+ dt = ctx.message.edited_at or ctx.message.created_at
+ current = dt.replace(tzinfo=datetime.timezone.utc).timestamp()
return bucket.get_tokens(current) == 0
def reset_cooldown(self, ctx):
@@ -838,7 +840,8 @@ class Command(_BaseCommand):
"""
if self._buckets.valid:
bucket = self._buckets.get_bucket(ctx.message)
- current = ctx.message.created_at.replace(tzinfo=datetime.timezone.utc).timestamp()
+ dt = ctx.message.edited_at or ctx.message.created_at
+ current = dt.replace(tzinfo=datetime.timezone.utc).timestamp()
return bucket.get_retry_after(current)
return 0.0