Pick Command w/ No Output

How can I setup a command with a few possible outputs, via an array or something. I want this to include NO output and thus not post a blank message into chat.

2 Likes

Set one of the outputs to a single space. Nightbot doesn’t actually post a message if eval returns a space.

$(eval a=[`choice 1`,`choice 2`,`etc`,` `];a[Math.floor(Math.random()*a.length)])
1 Like

Thank you sir!

I am trying to combine that with a check to ensure no additional arguments have been passed.

$(eval decodeURIComponent($(querystring)).split( )[0].length==0?a=[ ,message, ]; a[Math.floor(Math.random()*a.length)])

But it is failing.

3:46![Moderator][Verified]Nightbot: Unexpected token ';'

1 Like

I don’t know what this code is supposed to do. Can you provide a cleaner version or screenshot? Are you simply checking for empty input?

I am trying to build a command (for example : hi).

I am then checking to ensure that nothing was said after hi.

If that is true, I want to provide an array of possible outputs.

I rewrote the code to check that

!addcom -cd=5 hi $(eval a=[`choice 1`,`choice 2`,`etc`];!decodeURIComponent(`$(querystring)`)?a[Math.floor(Math.random()*a.length)]:` `)

Not getting an error from this code. Not getting a response either.

I flipped the condition, it should work now.

What do you mean you flipped the condition?

Just means my code was off, should work now.

1 Like

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