Quotation marks interfering with code

Asked Jun 20, 2020·1 reply·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 with some js code but whenever someone types a " in the word after the command, Nightbot gives a "Right-hand side of 'instanceof' is not an object" error. I know where the issues is situated (eval a="$(query)"; so the double quotation mark in the word messes with the code) but changing the double quotation marks to single one gives the same problem when a ' used in that word. Is there any way to fix this?

1 reply

Hey @Upbeat Koala!

Using `` `` (backticks), $(querystring) instead of $(query), as well as decodeURIComponent()` should prevent most issues in the future:

a=decodeURIComponent(`$(querystring)`)