Help with $(eval) and using other variables in JavaScript

Is there a way to access a nightbot variable like $(query) inside JavaScript code so that the code can use the value for this variable?


You can nest $(query) inside $(eval) like so:

$(eval var foo = "$(query)";//some other code here...)

Note that if the user input contains quotation marks, this will break the script. One way to prevent that is to instead use the following code:

$(eval var foo = decodeURIComponent(`$(querystring)`);//some other code here...)
1 Like

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