How to print second argument if it is a specific word

Asked Nov 16, 2022·6 replies·Last activity 3 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.

I have basic knowledge in programming but not in this language. So can someone help me to program a command where if the argument next to the command is e.g. "NAME", I output "Hello NAME". But NAME can be something different than the author of the message?

6 replies

Or can someone give me a link where I can see how to do this? I could not find instructions or a helpful explanation in the documents or anywhere else?

Hey @Stellar Fox!

Nightbot uses JavaScript, but for simple commands like yours text is more than enough!
With the description you've given, I think what you're looking for is the $(touser) variable.

With a command like this one:

!addcom !hello Hello $(touser)!

The bot will answer like this:

a
User1: !hello
Nightbot: Hello User1!
User1: !hello User2
Nightbot: Hello User2!

I already know that, thanks, but that's not what I want. I want that if the first argument after the command (which is not a person) is a certain string, to insert this in the sentence that is returned. And yes i will need some JS but I only know Java. That's where I need some help

Thats almost what i wanted. Thanks a lot
I tried replacing the $(query) with $(1) and the includes() method with the equals() method, but there is an error saying that "some_string".toLowerCase(...).equals() is not a function. Isn't there an "equals check" function?

Simply do the following:

'$(1)'.toLowerCase() === 'WORD_IN_LOWERCASE' ? ...

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

Ask on Discord