Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Making a constantly ticking counter is inefficient and inconvenient.
It's better to just save the current time to a variable when starting the bot.
When you are asked for uptime (i.e. in the !uptime command handler), subtract the value stored in the variable from the current time - you will get the time interval between them. This will be the uptime. It remains only to format it beautifully.
See the datetime module , datetime and timedelta data types for details.
Start a timer when the script is launched in a separate thread and add one to the counter every second. Well, output when requested.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question