Help fixing eval command

So what I want is a command that has three responses to what the query is, its a fun little command i want to make for buds stream please help! Heres what I tried xd
$(eval a= $(query).toLowerCase() b="$(query)".toLowerCase(); a== Nightbot ? “YOU CAN’T BAN ME! YOU ARE NOW BANNED $(user)” : ‘The user $(query) is now banned.’; b==‘kevsuniverse’ || b==“hiyazcool” ? You can't ban $(query) they are too powerful!!! : “”)

**Please Note that i am trying to learn this im still new to it

@Hiyazcool

You could do this with ternary operators. Since you’re trying to learn JS, I’ll give a quick rundown on the relevant code.


A ternary operator is a variable assignment using a condition.

var someVariable = (condition) ? value to assign if condition is true : value to assign if condition is false;

The first value after the question mark gets assigned to someVariable if the condition is true, and the second value (after the colon) gets assigned to someVariable if the condition is false.

var foo = 1 < 2 ? `bar` : `car`;

1 is indeed less than 2, so bar will be assigned to foo.

var woo = `zoo`;
var foo = woo.length > 5 ? `bar` : `car`;

The length of woo is 3. It is not greater than 5, so car will be assigned to foo.


Note that ternary operators can be written to be more complex than the examples I’ve given above to account for additional conditions. For example…

var woo = `zoo`;
var foo = woo.length > 5 ? `bar` : (woo.length > 2 ? `car` : `tar`);

This command response achieves what you’re looking for:

$(eval a=decodeURIComponent(`$(querystring)`).toLowerCase();a?(a==`nightbot`?`YOU CAN'T BAN ME! YOU ARE NOW BANNED $(user)`:(a==`kensuniverse`||a==`hiyazcool`?`You can't ban ${a}, they are too powerful!`:`The user ${a} is now banned.`)):`Enter a user to ban!`;)

@RokettoJanpu Thank you for this this means a lot although i dont fully understand all of the stuff you mentioned but i will make sure I learn from it though <3

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