refactor(core): tweak cooldown calculation
Should prevent issues where cooldown is 0 when formatted.
This commit is contained in:
parent
c7658f84dc
commit
ea09f291e5
7
core.py
7
core.py
@ -48,12 +48,11 @@ async def on_message(message, edited=False):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if (cooldowns := command_cooldowns.get(message.author.id)) and not edited:
|
if (cooldowns := command_cooldowns.get(message.author.id)) and not edited:
|
||||||
if (end_time := cooldowns.get(matched)) and int(time.time()) < int(
|
cur_time = time.time()
|
||||||
end_time
|
if (end_time := cooldowns.get(matched)) and round(end_time - cur_time) > 0:
|
||||||
):
|
|
||||||
await utils.reply(
|
await utils.reply(
|
||||||
message,
|
message,
|
||||||
f"please wait **{utils.format_duration(int(end_time - time.time()), natural=True)}** before using this command again!",
|
f"please wait **{utils.format_duration(round(end_time - cur_time), natural=True)}** before using this command again!",
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user