Individual counting system

Hi there. I currently have setup a !slap command which does what you’d expect, and I’m trying to keep count on how many times a certain person has been slapped. I managed to add a counter but it was global, so the slaps increased each the time someone ran the command, and not when an individual was slapped.

I hope I was clear and thanks for the help :slight_smile:

Sorry but this isn’t possible with native Nightbot, this would require an Custom API that tracks the command use.

Thank you for your answer :slight_smile: I guess I’ll just keep track of the global amount of times the command was used :slight_smile:

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.

!slap (alias to !slapadder)
$(eval query = `$(query)`.replace(/[@,]/g, ""); if (query) {if (query.toLowerCase() == `$(user)`.toLowerCase()){"$SLAPPEDMYSELF$"}else{"addquote?token=SECONDTOKEN&data=" + encodeURIComponent(query + ",")}} else {"$NOUSER$"})

!slapadder
$(eval if (`$(urlfetch http://twitch.center/customapi/$(query))`.startsWith("Successfully added entry ")){match = `$(query)`.match(/data=(.*)%2C$/); match == null ? "!slap is misconfigured" : `$(user) slapped ${decodeURIComponent(match[1])}`} else if (`$(query)` == "$SLAPPEDMYSELF$"){"You cannot slap yourself!"} else if (`$(query)` == "$NOUSER$"){"No user specified!"} else {"Use !slap"})

!slaps
$(eval query = `$(query)`.replace(/[@,]/g, ""); query = query ? query : `$(user)`; slaps = `$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`.split(","); querySlaps = 0; slaps.forEach(slap => {if (query.toLowerCase() == slap.toLowerCase()){querySlaps++}}); `${query} has been slapped ${querySlaps} time${querySlaps == 1 ? "" : "s"}`)
1 Like

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