Right-hand side of 'instanceof' is not an object

So im trying to make a !hug command, where if the command is referred to a specific used the results will be different, but i keep getting hit with this error msg. Been wrecking my brain with it for some time now and i got no idea how to solve it (tried multiple iterations on this one already)

/me $(eval if( $(touser) == ed_be) {"hugs Ed around the neck with a spiked wire";} else {$(user); "gives" $(touser); "the biggest of hugs";})

Could use the help…

I’ve ironed out the main code issues.

/me $(eval a=decodeURIComponent(`$(querystring $(touser))`);a==`ed_be`?`hugs Ed around the neck with a spiked wire`:`$(user) gives ${a} the biggest of hugs`)

Care to explain the piece of code for future understanding?

The main bit of code is the ternary operator, a relatively fast way to evaluate between two choices of expressions based on whether a given condition is truthy or falsy.

Alright. so the ‘:’ is a separator between the options?
also, is it possible to use the same format for more than 2 options? (suppose i give it more options where a=“a different name”)

Yes, the colon (:) separates the if true option from the if false one.

If you want to have more options, you can do so like this:

$(eval a=decodeURIComponent(`$(querystring $(touser))`);a==`USERNAME_1`?`OUTPUT_FOR_USERNAME_1`:a==`USERNAME_2`?`OUTPUT_FOR_USERNAME_2`:a==`USERNAME_3`?`OUTPUT_FOR_USERNAME_3`:`DEFAULT_OUTPUT`)

etc, you get the idea.

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