How to do "add" counters

For example, if I want to keep track of times my dog barks, users in chat could type +bark and have nightbot say “Dog has barked 1 time”, “Dog has barked 2 time”, etc

Ty

Hey @lannyhoang!

Use the $(count) variable.

!addcom !bark Dog has barked $(count) times.

Oh great thank you!

And if I wanted someone to type +2 instead of just adding 1 to the count, how could I handle that? Right now I set it up with the $(count), but when they type !bark in chat, it just adds 1. Not sure how to make it like !bark 2 or +2 in chat

Timers are only going up by 1 every time.
If you want to double that amount permanently here’s the solution:

!editcom !bark $(eval a=`$(count)`; `Dog has barked $(count) times.`)

If however you’d like people to be able to add more than 1 only sometimes, you’ll have to create another command, and people will have to look up how many barks there already are to edit the correct amount in.

!addcom !setbark -a=!editcom !bark \-c=$(1)

So to add 5 barks, they’d have to do !bark, see the current amount, let’s say it’s 8, then they would have to call !setbark 12, since by calling !bark first they already added 1, which mean the amount was 7, and 7+5=12, and then they’ll add another bark if they want to check if it was added properly, so maybe they should do !setbark 11. And if by mistake they would do !setbark 5, well, you’d be back to 5…

Anyway, with this simple example I’m sure you understand how this kind of command isn’t a good idea to leave in the ends of people who don’t understand how the command works, so I suggest making it mod only if you really want it.

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