Custom death counter

I’m not the one who came up with the idea of a death counter. I’ve researched the forum and didn’t find the things I need, only basics. It’s not a secret, that it’s not hard to do that, So far I have !death+, !deaths, !resetdeaths.
!commands add !death+ -ul=moderator -a=!commands edit !deaths Deaths so far: $(count).
!commands add !deaths Deaths so far: 0.
!commands add !resetdeaths-a=!commands edit !death+ -c=0

The thing is that I actually want tham to display a custom text saying “Death added [totalnumber]” and “deaths are reset” instead of long and completely unnecessary “the command “!commandname” has been edited successfully.”. (or just make nightbot reply nothing)
And the other thing is that I’d like !resetdeaths to do 2 things at once: clear the counter and clear the death number displayed in !deaths. So how do I do that?

It’s not possible to do that (change the edited text, modify multiple commands) with how nightbot’s command system works. A customapi would be needed

Go to https://twitch.center/customapi/quote/generate. You will see three lines. After token= on the first line, you will see your first token. After token= on the second and third lines, you will see your second token. Use these to replace FIRSTTOKEN and SECONDTOKEN before you add the following commands.

!deaths

$(eval quotes = `$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`; deaths = quotes == "There are no quotes added" ? 0 : quotes.length; `Deaths so far: ${deaths}`)

!death+

$(eval match = `$(urlfetch json http://twitch.center/customapi/addquote?token=SECONDTOKEN&data=1)`.match(/^Successfully added entry #(\d+)$/); match ? `Death added: ${match[1]} total death${match[1] == 1 ? "" : "s"}` : "Failed to reach API")

!resetdeath

$(eval `$(urlfetch http://twitch.center/customapi/quote/list?token=FIRSTTOKEN)` == "There are no quotes added" ? "There are already 0 deaths" : (`$(urlfetch http://twitch.center/customapi/delquote?token=SECONDTOKEN&clear=1)`, "Deaths have been reset"))

You might have to call !resetdeath right after you add the commands, because some bot was automatically clicking the link in the !death+ command when I was adding it, causing the number to start off at 2.

2 Likes

Are you a Jesus or something? Thank you so much!

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