I was wondering if it was possible to make one variable that works for more than one command.
Currently, I am looking to make a variable that will keep count of the number of mistakes made. One command will be used to add to the variable, and another variable will be used to output the value of the same variable.
@undermywheel Currently there’s no variable that works across multiple commands. A workaround is possible using ehsankia’s quote list custom API - read more about it here.
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!
We can use this custom API to create this special ‘count variable’. I assume what you want uses two commands: A command that adds to this count variable and a second command that gives the current value of this count variable. I’m going to call the former !mistake and the latter !mistakecount. 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 (which is used to edit the list)! Replace
PUBLIC_TOKEN with your public token and
PRIVATE_TOKEN with your private token.
!addcom -cd=5 !mistake $(eval a='$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=e)';' ') $(user) has just made a mistake!
!addcom -cd=5 !mistakecount $(eval '$(urlfetch http://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)'.split('.').length-1) mistakes have been made.
Feel free to change the command names and their responses just as long as you remain the $(eval) variables untouched. Basically the $(eval) variable in !mistake is what adds +1 to the special count variable. The $(eval) variable in !mistakecount is the value of the special count variable itself.
Awesome; thanks so much! Is it possible to create a command that resets the mistakes count too?
!addcom -cd=5 !mistakereset $(eval a='$(urlfetch http://twitch.center/customapi/delquote?token=privateTokenHere&clear=1)';' ') You have been forgiven for your mistakes.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.