I'm trying to create a !smelly command that replies $(query) is smelly and not cute unless the query contains "Nightbot" or "nightbot", to which it replies $(user) is smelly and not cute
Here is the code that I have so far: !addcom !smelly $(eval query=$(query) if(query.includes("Nightbot")) '$(user) is smelly and not cute'; else if(query.includes("nightbot")) '$(user) is smelly and not cute'; else '$(query) is smelly and not cute';)
but I keep getting a "right-hand side of 'instanceof' is not an object" error. Thanks for any help in advance!
P.S. All the 's that were used in my code are actually `s, but I couldn't fight you how to keep it from un-formatting it.
Another "Right-hand side of 'instanceof' is not an object" Error
2 replies
Hey @Opal Dog!
As xgerhard said, $(query) is a Nightbot variable, so to make it a string, put it between `` `` (backticks), then you forgot the ; (semicolon) after query=$(query)`. I think that's everything that was causing the error.
Then I improved your code a bit, first I said q is the input in lowercase with .toLowerCase(), this will save us a test, then I use the ternary operator ?:; to do the test, basically it works like this:(condition/test)?(if true):(if false);.
So I test if there's "nightbot" in q, since q is entirely in lower case thanks to .toLowerCase() we only need to test it once. If true, send "$(user) is smelly and not cute", if false, send "$(query) is smelly and not cute".
!addcom !smelly $(eval q=`$(query)`.toLowerCase();q.includes(`nightbot`)?`$(user) is smelly and not cute`:`$(query) is smelly and not cute`;)
And to format the command like I do in my post, put 4 spaces before typing the code, or you could also put 3 backticks at the beginning and the end of your code too, like this:

