Is it possible to set permanent variables to call up later?

@octojay

All variables within an $(eval) will be newly declared each time the command is used, so setting variables that Nightbot will keep track of between command uses is impossible (outside of $(eval) there is $(count) but that’s useless for what you need). You would have to make use of an API, specifically ehsankia’s quote list API.


Click this link. It will generate three links and two tokens, a public token (8 characters long) and a private token (16 characters long). The public token is located within the first generated link. The private token is located within both the second and third generated links. The tokens are found after token= and before &data=$(querystring) Copy them and keep them somewhere safe!

I’ve set up 2 commands below, !disaster and !disasterp2 which work in tandem to output a response depending on whether the input is reset. Although this setup creates 2 commands, you are only supposed to use !disaster, and I’ve set it up such that directly using !disasterp2 won’t work. Either copy and paste these commands into chat or add them through the Nightbot dashboard. Add the commands through chat only if you are sure no one else is there, otherwise they might see your private token. Replace PUBLIC_TOKEN with your public token and PRIVATE_TOKEN with your private token.

!addcom -cd=5 !disaster -a=!disasterp2 $(eval decodeURIComponent(`$(querystring)`).toLowerCase()==`reset`?`PRIVATE_TOKEN&data=$(time EST "MMM D Y HH:mm:ss z")`:`PRIVATE_TOKEN COUNTUP`)
!addcom -cd=5 !disasterp2 $(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;if(`$(query)`.includes(`PRIVATE_TOKEN`)){`$(2)`==`COUNTUP`?`It has been $(countup $(urlfetch http://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=0&no_id=1)) since the last disaster.`:`$(user) has reset the disaster counter.`;}else{`Use !disaster`;})

When using !disaster for the first time, enter the “reset” argument so Nightbot will have a time to start counting up from. From there you can use !disaster without the “reset” argument.

1 Like