Personal cooldown and counter

Hey,

is there a way to do a personal cooldown and a personal counter on a command?

A friend wants to do a !hey command to count how many times a person entered the chat.

Thanks in advance :slight_smile:

Unfortunately this isn’t possible with nightbot.

I could make a command where a user types !hey, and the command then says how many times that user has used !hey. I don’t think a cooldown per user is possible without making your own web server. Is this acceptable?

I figured out a way to have a !hey command with a cooldown. The default cooldown is 6 hours. Users can also type !heycount to see their own counts or the count of another user by typing that user’s name after !heycount.

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.

It is not recommended to add these commands through chat, because then anyone in your chat can see your tokens and use them to edit the counts. I recommend using https://beta.nightbot.tv/commands/custom to add the commands.

!hey (alias to !heyadder)
$(eval v=`$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`.split(",");l=0;for(i=0;i<v.length;i++){m=v[i].match(/^(\w+)\|(\d+)$/);if(m&&m[1].toLowerCase()==`$(user)`.toLowerCase()){l=parseInt(m[2])}}n=Date.now();(n-l>6*3600000)?("?token=SECONDTOKEN&data="+encodeURIComponent(`$(user)|${n},`)):"$TOORECENT$")

!heyadder
$(eval if(`$(urlfetch json http://twitch.center/customapi/addquote$(query))`.startsWith("Successfully added entry ")){v=`$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`.split(",");c=0;for(i=0;i<v.length;i++){m=v[i].match(/^(\w+)\|(\d+)$/);if(m&&m[1].toLowerCase()==`$(user)`.toLowerCase()){c++}}`$(user) says hey! (${c} times)`}else if(`$(query)`=="$TOORECENT$"){`You used !hey less than 6 hours ago, $(user)`}else{"Use !hey"})

!heycount
$(eval q=`$(query)`?`$(query)`:`$(user)`;v=`$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`.split(",");c=0;for(i=0;i<v.length;i++){m=v[i].match(/^(\w+)\|(\d+)$/);if(m&&m[1].toLowerCase()==q.toLowerCase()){c++}}`${q} has used !hey ${c} time${c==1?"":"s"}`)

How would you do that?

What are you having trouble with?

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