Nightbot select a choice

Asked Feb 2, 2020·4 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.

Hello people! Im looking for something easy (I guess) but I have no lucky. I just want a command for to get a response with 1 option of all given (would be good if @ can be used for easier write usernames)

For example, !name @member @member Sergio Maria
Nightbot: The person selected is Sergio! Congratulations!

Thats all... you just need to write the names you want and the nightbot select one random of them.

4 replies

!addcom -cd=5 !name $(eval a=decodeURIComponent(`$(querystring)`).replace(/@/g,``).trim().split(` `);a[0]?`The person selected is ${a[Math.floor(Math.random()*a.length)]}! Congratulations!`:`Missing input!`)

I love YOUUU!!!! hahahaha. Long time ago, Im looking for information about eval function. In the docs, there is some info but this function have a lot of more things. I see there are "$(eval const" "$(eval var" "$(eval a=".... and a lot of more, but where can I found all this information?

$(eval) executes JavaScript code. You'd use it to write commands that require more complex logic. Any JavaScript references/tutorials you can find online will help.

Thanks again!!! I will check it out!!!! 😍 😍

heart_eyes.png