Trying to Create a count command


#1

Ok, So i am fairly new to nightbot but have been doing a lot of research and tinkering. However I still cant get my counter to work.

Essentially, I need a counter with 3 commands.

First command should simply display a string with the current count amount.
ex. Gravity has killed x amount of players.

Second command should apply the $(count) variable to increase count.
ex. Gravity has killed x+1 amount of players.

Third command would be a mod command to reset current count to 0.

The main issue I am having is that once I run command 2, It correctly displays the string and correct count, but the command 1 is not getting the updated count info. It always sits at 1. Is there any way to add the count, edit command one correctly, AND display the correct text in command 2?

I was currently using this setup:

Command 1: !noflyzone Gravity has downed 0 aircraft this stream.

Command 2: !commands add !AA -ul=mod -a=!commands edit !noflyzone Gravity has downed $(count) aircraft this stream.

Command 3: !aareset edit !aa -c=0

What am I doing wrong?


#2

This is how I would fix your commands. Just copy and paste each of these into your chat. I am assuming you still have the commands set up, otherwise just change !editcom to !addcom:

For Command 1: !editcom !noflyzone Gravity has downed 0 aircraft this stream.

For Command 2: !editcom !aa -a=!editcom !noflyzone Gravity has downed $(count) aircraft this stream.

For Command 3: !editcom !aareset -a=!editcom !aa \-c=-1

I assume you are going to reset the number in !noflyzone by doing !aareset then !aa. The reason I put -1 in !aareset is because whenever you run !aa it will increment the counter before editing !noflyzone. If you use 0 in !aareset then the number in !noflyzone will be reset to 1. So setting the !aa counter to -1 will make sure the number in !noflyzone is reset to 0.

Side note: !editcom is mod only by default, and this userlevel cannot be set any lower. This means that aliases of !editcom (custom commands that use !editcom) are also mod only by default, so there is no need to include -ul=mod for commands like !aa


#3

Ok, i think that is working properly. But for command 2, is there a way to show the string (Gravity has downed 0 aircraft this stream.) once a mod runs it? In the chat it just confirms that Command 1 was edited. Or is this not possible?


#4

Sorry, as far as I know, you cannot change the output of any command that uses !editcom


#5

Alright. Thanks, i appreciate your help!


#6

It is possible to modify a count while showing user-friendly messages, but you won’t be able to use Nightbot’s $(count) variable.

These commands use this quote system to store and modify a count. Because these commands contain private tokens, you should add them through the Nightbot web interface: https://beta.nightbot.tv/commands/custom.

Go to https://twitch.center/customapi/quote/generate. You will see three lines. Your first token is after token= and before &data= on the first line. Your second token is after token= and before &data= on the second and third lines. Replace FIRSTTOKEN and SECONDTOKEN with these before you add the following commands.

!noflyzone
$(eval quotes=decodeURIComponent("$(querystring $(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1))");/^(?:1+|There are no quotes added)$/.test(quotes)?`Gravity has downed ${quotes=="There are no quotes added"?0:quotes.length} aircraft this stream.`:`Failed to reach quote system: ${quotes}`.substr(0,400))

!aa
$(eval addResponse=decodeURIComponent("$(querystring $(urlfetch json http://twitch.center/customapi/addquote?token=SECONDTOKEN&data=1))");(match=addResponse.match(/^Successfully added entry #(\d+)$/))?`Gravity has now downed ${match[1]} aircraft this stream.`:`Failed to reach quote system: ${addResponse}`.substr(0,400))

!aareset
$(eval (clearResponse=decodeURIComponent("$(querystring $(urlfetch http://twitch.center/customapi/delquote?token=SECONDTOKEN&clear=1))"))=="All entries have been deleted"?"The downed aircraft counter has been reset.":`Failed to reach quote system: ${clearResponse}`.substr(0,400))

#7

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