Pick Command w/ No Output

Asked Jul 16, 2020·9 replies·Last activity 6 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

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.

9 replies

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)])

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 ';'

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.

Deft Penguin said:
$(eval a=[choice 1,choice 2,etc];!decodeURIComponent($(querystring))?a[Math.floor(Math.random()*a.length)]: )

What do you mean you flipped the condition?

Just means my code was off, should work now.

Didn't find your answer? The community is on Discord.

Ask on Discord