mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Core] Fix infinite typing for commands with cooldown (#2987)
* fix(core): cooldown error can't reinvoke command (infinite typing issue) * chore(changelog): add towncrier entry
This commit is contained in:
parent
0be3b1acd7
commit
cdb7a02cb8
1
changelog.d/2985.bugfix.rst
Normal file
1
changelog.d/2985.bugfix.rst
Normal file
@ -0,0 +1 @@
|
||||
Bot no longer types infinitely when command with cooldown is called within last second of cooldown.
|
||||
@ -232,21 +232,9 @@ def init_events(bot, cli_flags):
|
||||
elif isinstance(error, commands.NoPrivateMessage):
|
||||
await ctx.send("That command is not available in DMs.")
|
||||
elif isinstance(error, commands.CommandOnCooldown):
|
||||
if error.retry_after < 1:
|
||||
async with ctx.typing():
|
||||
# the sleep here is so that commands using this for ratelimit purposes
|
||||
# are not made more lenient than intended, while still being
|
||||
# more convienient for the user than redoing it less than a second later.
|
||||
await asyncio.sleep(error.retry_after)
|
||||
await ctx.bot.invoke(ctx)
|
||||
# done this way so checks still occur if there are other
|
||||
# failures possible than just cooldown.
|
||||
# do not change to ctx.reinvoke()
|
||||
return
|
||||
|
||||
await ctx.send(
|
||||
"This command is on cooldown. Try again in {}.".format(
|
||||
humanize_timedelta(seconds=error.retry_after)
|
||||
humanize_timedelta(seconds=error.retry_after) or "1 second"
|
||||
),
|
||||
delete_after=error.retry_after,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user