NightDev Community Forums

Nightbot select a choice

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 @Pepe @Carlos 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.

!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!`)
1 Like

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.

1 Like

Thanks again!!! I will check it out!!! :heart_eyes: :heart_eyes:

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