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

Asked Feb 29, 2020·5 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.

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...

5 replies

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`)
Deft Penguin said:
/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.

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

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.

Didn't find your answer? The community is on Discord.

Ask on Discord