Trick or Treat Command? (50/50 Command Help)

Hi everyone!

Sorry to be a pest but I am newer to the world of streaming and am extremely new to Nightbot and have spent hours trying to understand the Eval side of Nightbot commands whether it is using the docs or trying to scour the internet for help.

I had the idea of trying to do a command for a trick or treat kind of command, and I thought maybe doing it as a 50/50 draw would work but I just don’t seem to know how to get it to filter through both options instead of just the ‘Trick’ option. The logic I had was that it is out of two options, but I just don’t understand the latter half of the coding (which I think is messing me up).

With my crude knowledge of Nightbot, this was the coding I came up with and I feel like I did something wrong. Any help would be wonderful and I appreciate you all greatly for any assistance you have. :slight_smile:

$(eval Math.floor(Math.random() * 2) == 0 ? “Treat! No Twix up our sleeves this time!” :candy:: “Trick! Make sure the Jack-O-Lantern doesn’t take a nibble out of you ~ :jack_o_lantern:”)

EDIT: Forgot one particular emoji in the command sorry!

What problems are you having? That command works for me with a few tiny changes: I replaced the smart quotes with plain quotes, and I moved the candy emoji inside the quote that it’s next to:

!addcom !trickortreat $(eval Math.floor(Math.random() * 2) == 0 ? "Treat! No Twix up our sleeves this time! 🍬 " : "Trick! Make sure the Jack-O-Lantern doesn’t take a nibble out of you ~ 🎃 ")

Sometimes I get a trick out of that, and sometimes a treat.

1 Like

Hey there! Thank you for replying to this! For some reason when I tested out the coding in the original post, I just kept getting Trick and I know it should be 50/50 but I highly doubt it would be trick every time. I wouldn’t get any of them that said treat for some reason.

Maybe it was the fact I forgot to add the candy emoji into the first link and therefore it couldn’t read it? I am really new to this coding stuff so I apologize if the question sounds dumb. :slight_smile: