Counter increasing value every x minutes

Is it possible to create a counter that will increase the value e.g. every 20 minutes? For example, I run the command with the value 5 and if someone uses the !lap command 60 minutes later, the nightbot returns “We did 8 laps”, 20 minutes later “We did 9 laps” and so on. I don’t want the nightbot to chat every 20 minutes, but to respond to a user-written command.

I’ve set up a !laps command below that outputs the value of a counter that increases by 1 every 20 minutes. Replace TIMESTAMP with the unix time (in seconds) that you want the command to start counting from. Visit Epoch Converter to grab the current unix time or the unix time from a particular date.

!addcom -cd=5 !laps We did $(eval Math.floor((Date.parse(Date())/1e3-TIMESTAMP)/1200)) laps

For anyone who’d like to set up a similar command that counts up from a particular date, this is the general setup for such a command. Replace TIMESTAMP with the unix time (in seconds) and INTERVAL with the amount of time (in seconds) that should pass before the counter increases by 1.

$(eval Math.floor((Date.parse(Date())/1e3-TIMESTAMP)/INTERVAL))
1 Like

Thank you very much, works perfectly, best regards :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.