Are 2-in-1 commands possible?

Hi. I’m trying to create a count command that does two things at once. I want chat to be able to reveal the count without adding to it, but I want mods to be able to reveal it and add to it with the same command. Basically, I want to merge the following two methods:

Method 1
!commands add !deaths 0
!commands add !rip -a=!commands -ul=mod edit !deaths Bodhi died $(count) times

Method 2
!commands add !rip -ul=mod Bodhi died $(count) times

The problem is that !rip in Method 1 returns ‘The command “!deaths” has been edited successfully’ without actually revealing the count, while chat can’t use Method 2 to see the current count (without adding to it).

I’d like !rip to return ‘Bodhi died $(count) times’ as in Method 2, while still updating !deaths. Or for !deaths to call !rip without updating it.

I suspect this isn’t possible, but if it is then I’d be grateful for the help.


You can’t access Nightbot’s $(count) without incrementing the count. Therefore, to get what you want, the count must be stored externally.

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

$(eval quotes = `$(urlfetch json`; deaths = quotes == "There are no quotes added" ? 0 : quotes.length; `Bodhi died ${deaths} time${deaths == 1 ? "" : "s"}`)

!rip (userlevel moderator)
$(eval match = `$(urlfetch json`.match(/^Successfully added entry #(\d+)$/); match ? `Death added: Bodhi died ${match[1]} time${match[1] == 1 ? "" : "s"}` : "Failed to reach API")

!resetdeaths (userlevel moderator)
$(eval `$(urlfetch` == "There are no quotes added" ? "There are already 0 deaths" : (`$(urlfetch`, "The death counter was reset"))

If you add the commands through chat, you might have to use !resetdeaths right after, because some bot was automatically visiting the link in the !rip command when I was adding it, causing the counter to start off at 2. I recommend adding the commands here anyways, so your tokens aren’t publicly visible.

1 Like

Thank you so much! That works perfectly :smiley:

I have to ask - what’s the worst that can happen if someone sees the tokens? They could potentially insert abuse into the commands, etc? And presumably anyone that reads this page can use them for their channel, too?

If someone sees your second token, then they can change the counter anytime without you knowing.

1 Like

Hmmm. Can I request to have this page deleted then, I wonder?

Thanks again for the help :slight_smile:

Nobody can see your tokens unless you post them. They are randomly generated whenever you visit

1 Like

Ah, great! Okay, I’m done now :smile:

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