Return last user of a command

Hello, I want to create a command that returns the last user of a command, for example, if the last user of the command was X, and the next user of it is Y, the command should return “Y has taken the ball from X”. Thanks.

Sorry this isn’t really possible as Nightbot doesn’t track this information. You’d need to use some sort of Custom API to track the last user.

Go to 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.

!takeball (alias to _!takeball)
$(eval e=encodeURIComponent;d=decodeURIComponent;u=d("$(querystring $(user))");r=d("$(querystring $(urlfetch json");(r=="There are no quotes added"?`addquote?token=SECONDTOKEN&data=${e(e(u))} /`:((r=d(r)).toLowerCase()==u.toLowerCase()?"$ALREADY$":`editquote?token=SECONDTOKEN&data=${e("1 "+e(u))} ${e(r)}`)).substr(0,400))

$(eval d=decodeURIComponent;u=d("$(querystring $(user))");r=`$(urlfetch json$(1))`;f=d("$(querystring $(2))");(r.startsWith("Successfully ")?`${u} has taken the ball ${f=="/"?"for the first time":"from "+d(f)}`:(d("$(querystring $(1))")=="$ALREADY$"?`${u} already has the ball`:(r=="[Error Connecting To WebProxy Service]"?"Use !takeball":`Failed to update record: ${r}`))).substr(0,400))

You should add these commands from the Nightbot web interface so chatters don’t see your tokens.


Your answer worked perfectly, I modified it to my need. Thank you so much!

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