Nightbot - How to setup Death command & How it works?

I’m trying to setup the death command for nightbot but I’m a little confused on how it would essentially count my deaths in a game?

I’m looking to have nightbot track deaths in the game I play. Now I rotate games (so I would need the game to be replaceable in the command so nightbot could track different stream deaths based on what game I was playing. Sort of like:

Nightbot: enjoythesilence2123 has died 8 times in Assassin’s Creed Odyssey since the stream has started (or something like that)

But I’m assuming I can adjust what game is listed by changing the message Nightbot says.

My problem is what is the command I use to ensure nightbot tracks the deaths in the game?

Also… is there a way of setting the command so if a user or even myself just says "How many times have you died? … Died being the trigger word, nightbot will automatically prompt with the death count message?

Thanks.

@enjoythesilence2123

This is possible using ehsankia’s quote list API and cykotiq’s Twitch info API.

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!

I’ve set up 4 commands: !adddeath and !adddeathp2 which work in tandem to add 1 to the death counter for the current game you’re playing (both are mod-only and only !adddeath is meant to be used directly), !deaths which shows the counter for the current game you’re playing, and !resetdeaths which clears all deaths (mod-only). Either copy and paste these 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 -ul=mod !adddeath -a=!adddeathp2 PRIVATE_TOKEN&data=-$(urlfetch https://twitch.api.scorpstuff.com/game.php?user=$(channel))-
!addcom -ul=mod !adddeathp2 $(eval a=`$(urlfetch http://twitch.center/customapi/addquote?token=$(query))`;b=`$(query)`.split(`&data=`)[1];c=b.slice(1,b.length-1);`$(query)`.includes(`PRIVATE_TOKEN`)?`$(channel) has just died in `+c+`!`:`Use !adddeath`)
!addcom -cd=5 !deaths $(eval a=`-$(urlfetch https://twitch.api.scorpstuff.com/game.php?user=$(channel))-`;b=new RegExp(a,`gi`);c=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.match(b);d=c!=null?c.length:0;`$(channel) has died in `+a.slice(1,a.length-1)+` `+d+` times.`)
!addcom -ul=mod !resetdeaths $(eval a=`$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`;`$(user) has reset the death counters!`)

Ok, I see how I am supposed to place the tokens in the Public and Private locations in the code. I’m a little confused on what exactly is the Command and what section is the Message portion?

I am reviewing this on mobile so it may be my screen looking funky, but am I correct, there should be 4 lines of code.

Sorry. I’m just having trouble determining where the break/start-stop is for the command vs the message. But this is insanely awesome, thanks for going to all this effort! Your help is extremely appreciated!

The commands I set up are meant to be copied and pasted as they are in chat. It’s much easier that way but like I said, you must make sure no one else is in chat.

If you’re looking to add them through the dashboard:
For commands that aren’t aliases of other commands (where the setup doesn’t have -a=), everything that comes after the command name is the message. For setups for commands that are aliases, e.g. !adddeath, the message is after -a=!adddeathp2, and you must put !adddeathp2 in the Alias field for !adddeath

Ok… if I’m understanding right, they should look like this correct?

Command:!adddeath
Message:-a=!adddeathp2 privateTokenHere&data=-$(urlfetch https://twitch.api.scorpstuff.com/game.php?user=$(channel))-
Mod-only
Alias: -a=!adddeathp2

Command:!adddeathp2
Message:$(eval a=$(urlfetch http://twitch.center/customapi/addquote?token=$(query));b=$(query).split(&data=)[1];c=b.slice(1,b.length-1);$(query).includes(privateTokenHere)?$(channel) has just died in+c+!:Use !adddeath)
Mod-only
Alias: N/A

Command:!deaths
Message:$(eval a=-$(urlfetch https://twitch.api.scorpstuff.com/game.php?user=$(channel))-;b=new RegExp(a,gi);c=$(urlfetch json https://twitch.center/customapi/quote/list?token=publicTokenHere).match(b);d=c!=null?c.length:0;$(channel) has died in+a.slice(1,a.length-1)++d+times.)
Access Everyone
Alias: N/A

Command:!resetdeaths
Message:$(eval a=$(urlfetch https://twitch.center/customapi/delquote?token=privateTokenHere&clear=1);$(user) has reset the death counters!)
Mod-only
Alias: N/A

Command: !adddeath 
Message: privateTokenHere&data=-$(urlfetch https://twitch.api.scorpstuff.com/game.php?user=$(channel))-
Userlevel: Mods
Alias: !adddeathp2

Command: !adddeathp2 
Message: $(eval a=`$(urlfetch http://twitch.center/customapi/addquote?token=$(query))`;b=`$(query)`.split(`&data=`)[1];c=b.slice(1,b.length-1);`$(query)`.includes(`privateTokenHere`)?`$(channel) has just died in `+c+`!`:`Use !adddeath`)
Userlevel: Mods
Alias: N/A

Command: !deaths 
Message: $(eval a=`-$(urlfetch https://twitch.api.scorpstuff.com/game.php?user=$(channel))-`;b=new RegExp(a,`gi`);c=`$(urlfetch json https://twitch.center/customapi/quote/list?token=publicTokenHere)`.match(b);d=c!=null?c.length:0;`$(channel) has died in `+a.slice(1,a.length-1)+` `+d+` times.`)
Userlevel: Everyone
Alias: N/A

Command: !resetdeaths 
Message: $(eval a=`$(urlfetch https://twitch.center/customapi/delquote?token=privateTokenHere&clear=1)`;`$(user) has reset the death counters!`)
Userlevel: Mods
Alias: N/A

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