Looking to make a command that tracks which user it has been used on and track that

[user] Has grounded [touser] [count] times! something like this. But the problem is this just counts the total command usage. Any idea how to fix this would be wonderful.

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.

!ground (alias to _!ground)
$(eval d=decodeURIComponent;e=encodeURIComponent;q=d("$(querystring)").replace(/^@/,"");u=d("$(querystring $(user))");if(q){if(q.toLowerCase()==u.toLowerCase()){"$MYSELF$"}else{"http://twitch.center/customapi/addquote?token=SECONDTOKEN&data="+e(e(u)+"|"+e(q)+",")}}else{"$NOUSER$"})

$(eval d=decodeURIComponent;q=d("$(querystring)");r=`$(urlfetch $(query))`;if(r.startsWith("Successfully ")){m=q.match(/data=(.*)%7C(.*)%2C$/);m?d(d(m[1]))+" grounded "+d(d(m[2])):"!ground is misconfigured"}else if(q=="$MYSELF$"){"You cannot ground yourself!"}else if(q=="$NOUSER$"){"No user specified!"}else{r=="[Error Connecting To WebProxy Service]"?"Use !ground":`Error connecting to quote system: ${r}`.substr(0,400)})

$(eval d=decodeURIComponent;q=d("$(querystring)").replace(/^@/,"");u=d("$(querystring $(user))");e=(f,s)=>f.toLowerCase()==s.toLowerCase();n=d("$(querystring $(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1))").split(",").reduce((a,c)=>a+(m=c.match(/^(.*)\|(.*)$/),m?(e(u,d(m[1]))&&(q?e(q,d(m[2])):1)):0),0);u+` has ${q?"grounded "+q:"used !ground"} ${n} time${n==1?"":"s"}!`)

!ground lets you “ground” another user.
_!ground is a utility command for !ground.
!grounds displays the number of times the user has used !ground, or, if a name is specified, the number of times the user has “grounded” that name.

1 Like

Alright I will try this when I get home later today. Hopefully it works and thanks so much already for the help!

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