aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-14 17:11:16 -0400
committerRapptz <[email protected]>2019-04-14 17:33:56 -0400
commit7a1102ccf0034827eed3d4088b96dd0dd29caf92 (patch)
tree1de6fc982607fd3154c3c2f3fdab60ea0921a01a
parent[commands] Allow passing reference time to update_rate_limit (diff)
downloaddiscord.py-7a1102ccf0034827eed3d4088b96dd0dd29caf92.tar.xz
discord.py-7a1102ccf0034827eed3d4088b96dd0dd29caf92.zip
[commands] Use message creation as the reference time in cooldowns
-rw-r--r--discord/ext/commands/core.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 8475be85..bde1869f 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -28,6 +28,7 @@ import asyncio
import functools
import inspect
import typing
+import datetime
import discord
@@ -639,7 +640,8 @@ class Command(_BaseCommand):
def _prepare_cooldowns(self, ctx):
if self._buckets.valid:
bucket = self._buckets.get_bucket(ctx.message)
- retry_after = bucket.update_rate_limit()
+ current = ctx.message.created_at.replace(tzinfo=datetime.timezone.utc).timestamp()
+ retry_after = bucket.update_rate_limit(current)
if retry_after:
raise CommandOnCooldown(bucket, retry_after)