If $(1) exists, > don't do anything, else -> writes a chat message

Forgive me if I’m slighty mad, but it’s a week Im having headaches because of this extremely basic thing. It is literally driving me insane. I have to add like 20-30 manual checks to Nightbot so it can autoreply when someone uses commands in a wrong way, for example !gamble instead of !gamble 100, this is a VERY common one that leaves the user in silence, without a single reply, and I NEED to explain him that he needs to add the amount after the command.
So since I can’t reply manually to every person, I thought about a bot, but I cannot find a way to do it properly. This is the closest I got so far:

$(eval if (!$(1)){‘Incorrect’})

As you can see, if $(1) doesn’t exists, it prints “Incorrect” in chat. But what if $(1) exists? Like someone that actually writes the command in the right way . This is the result:

chatuser1: !gamble 100
Nightbot: undefined
gamblebot: chatuser1 gambled 100 and won 200!

I cannot get rid of that “undefined” in chat, how do I tell Nightbot to just ignore and dont write anything if the argument exists? I tried with return, 1=1, void(0) and other dummy things but it ALWAYS writes some error in chat.

I know about 5-6 different programming languages and I never went so crazy over a simple IF ELSE statement.

Any help would be appreciated

Thanks, have a good day

Try this:

if(`$(1)`==`null`){`incorrect`}else{`correct`}

Hey thanks for the help! Just by looking at it I already see it won’t work. I mean yes technically speaking, it replies “correct” if the command is correct (and viceversa), but it shouldn’t give ANY reply at all if the command is written correctly.
It is supposed to trigger only when the command is wrong (without arguments).
When the user type !gamble 150 (example), the Nightbot should completely ignore the message, and not write “correct”, it has almost 0 sense it just spams the chat, again this should only correct if the chat has some Syntax anomaly, if everything is alright no need to write a reply.
Hope you understand what I mean :slight_smile:

Just replace correct with a single space. Like this:

` `

The bot won’t say anything if you do this.

2 Likes

Ohh Im so glad you helped me! It seems working nice! I think I tried the exact code days ago but instead of {’ ‘} I used {’’} (without blank space). In every programming language that I know I always did “” or ‘’, the white space thing idea didnt even cross my mind. Thank you! I hope someone find this post and your reply helpful. Thanks again sir :slight_smile:

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