D
D
Dream2021-06-22 15:54:23
Python
Dream, 2021-06-22 15:54:23

How to make cooldown display besides seconds?

I have commands, somewhere cooldown for a few seconds, and somewhere for hours, days (only with the help of seconds, because I don’t know how to make it more convenient). How to make cooldown display time in seconds, minutes, hours and days?
Example: 1 hour 30 minutes left, 1 day 20 hours left, 20 seconds left, etc.

cooldown:

@commands.cooldown(1, 10, commands.BucketType.user)

message:
elif isinstance(error, commands.CommandOnCooldown):
        await ctx.reply(f"Команду можно будет использовать повторно через `{error.retry_after :.0f} секунд`")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-06-22
@dreameddd

from datetime import timedelta
str(timedelta(seconds=error.retry_after))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question