Nightbot Command not working

I’m building a fun Twitch chat mini-game called Hot Potato to keep my community engaged during streams. The concept is simple: viewers toss a virtual hot potato to one another using chat commands. If they hold onto it too long, it explodes. The game works almost how I want it to—but I’m having trouble implementing a critical feature: a 10-second timer that causes the hot potato to explode if not tossed in time.
The Goal:

A player starts the game using !hotpotato to toss it to someone.
That player then has 10 seconds to use !toss to pass it on, or the potato explodes in their hands.
There’s also a 20% chance the potato explodes instantly upon using !toss—this part is working well and adds excitement.
If it explodes (either by chance or delay), a message should display:
:collision: The hot potato EXPLODED in @(chatter)'s hands! Use !hotpotato to start again.”

Current Implementation:

These are the two commands I currently use:

!hotpotato:
@(me) tosses the HOT POTATO to @(chatter)! Use !toss someone before it explodes!
!toss:
@(me) tosses the hot potato to @(chatter)! Hurry, or it'll explode!...

And this is the eval command ChatGPT gave me for the explosion chance logic:

$(eval u=“$(user)”;t=“$(touser)”;e=“:potato:”;t==“”||t.toLowerCase()==u.toLowerCase() ? e+" You can’t toss it to yourself, @“+u+”!" : Math.random()<0.2 ? “:collision: The hot potato EXPLODED in @”+u+“'s hands! RIP.” : e+" @“+u+” tosses the hot potato to @“+t+”! Hurry, or it’ll explode!")

What Works:

The 20% chance explosion on toss is working great—thanks to this script.

What Doesn’t Work:

There’s no actual 10-second timer. If someone receives the hot potato and does nothing, the game just stalls.
The game doesn’t remember who currently holds the hot potato.
There’s no system in place to track time or game state between tosses.

The Challenge: I’m not a coder, and I’m currently relying on mods to help me tweak commands manually, which is time-consuming and not ideal for fast iteration. I’d love a solution that just works or can be managed with a bot interface.

What I’m Looking For:

A way to track who currently holds the hot potato.
A 10-second timer that starts after each toss, causing an automatic explosion if !toss isn’t used in time.
A message to be sent in chat when the potato explodes from the timer.
Prevent users from tossing it to themselves.
Bonus: maybe add a cooldown to prevent spam/chain toss abuse.

Hiya, cant think of way to solve this simply with nightbot commands. Most likely will require some external code to store the timer and user with the potato. Then use the $(urlfetch ) variable to fetch that information.

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