Eval Conditional Output

Asked Jul 14, 2020·3 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.

I have a command that will respond, correctly, if the user uses the correct command in chat. It is using a regex to test for the existence of the command. But since Nightbot checks the first word ONLY, the command may not fire since the second word could be incorrect.

Example:
COMMAND : be
-- EVAL check for the word "cool" as the second word
IF TRUE, RESPONSE : message
IF FALSE, I want to exit but I get a "Nightbot: undefined" response.

How can I exit out gracefully?

Thanks

3 replies

No need for regex, just check the 1st input word.

!addcom -cd=5 be $(eval decodeURIComponent(`$(querystring)`).split(` `)[0].toLowerCase()==`cool`?`MESSAGE`:` `)

How can check the whole message for certain words?

Just don't split

$(eval q=decodeURIComponent(`$(querystring)`); // Write code here for all the tests you want to do on q)