mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-10 05:35:06 +00:00
[commands] Use edited timestamp if provided for cooldown timing
This commit is contained in:
parent
6f211fa5ad
commit
4205b3f88a
@ -764,7 +764,8 @@ class Command(_BaseCommand):
|
|||||||
|
|
||||||
def _prepare_cooldowns(self, ctx):
|
def _prepare_cooldowns(self, ctx):
|
||||||
if self._buckets.valid:
|
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)
|
bucket = self._buckets.get_bucket(ctx.message, current)
|
||||||
retry_after = bucket.update_rate_limit(current)
|
retry_after = bucket.update_rate_limit(current)
|
||||||
if retry_after:
|
if retry_after:
|
||||||
@ -805,7 +806,8 @@ class Command(_BaseCommand):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
bucket = self._buckets.get_bucket(ctx.message)
|
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
|
return bucket.get_tokens(current) == 0
|
||||||
|
|
||||||
def reset_cooldown(self, ctx):
|
def reset_cooldown(self, ctx):
|
||||||
@ -838,7 +840,8 @@ class Command(_BaseCommand):
|
|||||||
"""
|
"""
|
||||||
if self._buckets.valid:
|
if self._buckets.valid:
|
||||||
bucket = self._buckets.get_bucket(ctx.message)
|
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 bucket.get_retry_after(current)
|
||||||
|
|
||||||
return 0.0
|
return 0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user