Calling a count and editing it--for Regulars or Everyone?

So, I recently made a pair of commands, one that displays a counter variable, the other that updates the other command to add a count, a la:

!addcom !falls $(query)
!addcom !addfall edit !falls -ul=moderator -a=!commands Jane fell in the pit $(count) times!

However, I actually want to know if it’s possible to make an !addfall command available to all users, as well as whether it’s possible to make one available to just regulars. I don’t want this to be restricted to moderators.

I initially tried creating the !addfall command without the -ul flag:
!addcom !addfall edit !falls -a=!commands Jane fell in the pit $(count) times!

and while it did work properly when I used it, it did not work for any viewers.

So then I thought maybe the permission needed to be set explicitly; I tried creating !addfall with ul=everyone and ul=regular and neither one of those worked.

I’m wondering if this is because in general, no one except mods or owners have the rights to edit any commands? And if so, is there any way around this? To summarize, I would really like for all viewers to be able to:

  1. view total number of falls without adding to fall count
  2. add to fall count when needed
1 Like

@see_jane_play

!addfall is an alias of !commands edit (!addfall’s function rides off of !commands edit), and any alias of !commands edit is mod-only by default. This cannot be changed to allow for users below mods to use !addfall.


That said, a workaround does exist, although it’s a bit more complex than what you currently have and will take some work on your end to set up. This workaround uses 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 a special ‘count variable’. What you want is two commands: A command that displays the current count and a command that increases the count by 1. The former command is !falls and the latter is !addfall. First, delete your current !falls and !addfall commands. Then either copy and paste these new 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 !falls Jane fell into the pit $(eval '$(urlfetch http://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)'.split('.').length-1) times!
!addcom -cd=5 !addfall $(eval a='$(urlfetch http://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=e)';' ') Jane just fell into the pit!

Feel free to change the command responses just as long as the $(eval) variables remain untouched. Basically the $(eval) variable in !addfall is what adds 1 to the special count variable. The $(eval) variable in !falls is the value of the special count variable itself.

Lastly, if you want to change the userlevels required to trigger the commands, add the userlevel parameters between !addcom and -cd=5:

For everyone: -ul=everyone (you don’t really need to put this in, this is set by default)
For regulars: -ul=regular
For subscribers: -ul=subscriber
For mods: -ul=moderator
For owner (presumably you): -ul=owner

1 Like

Oh my goodness, thank you SO MUCH for your detailed and incredibly helpful response, Roketto! I appreciate you!

You’re right, the workaround looks a bit complicated, and it’s going to take me some time to attempt it. But it’s great to know that one exists, and how to implement it!

Hopefully i won’t have issues with pulling this off, but if I do I’ll post here again.

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