Help with a command please!

First, thank you to the devs & all the contributors here on the forum!

I am trying to make a response command, if a users post contains certain words, it says certain things. Example:
If the first word is “what” and contains “id” then the bot will post my game ID. After searching the forums, I made this:

!commands add what $(eval `$(query)`.toLowerCase().includes("id") ? "My iD is 123456" : " ")

Which works!! but for my usage, isnt quite what I need, only because this question is asked multiple ways, for example:

  • what is your id
  • what is your ign
  • what is your username

Question 1:

For this to work, I assume I need multiple entries be added to the “includes” code, something like so: includes("id","ign","username")
Is this correct? or is it possible?

Question 2:

As people may ask:

  • what is your steam name
  • what is your activision id
  • what is your blizzard account

Can it give dynamic responses? for example:

User: what is your activision?

Nightbot: @user its: 12345

User: what is your steam?

Nightbot: @user its: 54321

Question 3:

Finally, as someones first word could be “what” or “whats”, do I need to add the same command twice? (once to reply to “what” and once to reply to “whats”) or can I use a wildcard for matching words? something like !addcom what* CommandFuGoesHere where what* would match whats also?

Thank you for your time and effort!

To answer the last part you’ll have to make two commands
And secondly this is the format you’ll want the command code in:

$(eval Q=`$(query)`.toLowerCase();
Q.includes(`Key Word1`)?`Response1`;
Q.includes(`Key Word2`)?`Response2`;
Q.includes(`Key WordX`)?`ResponseX`;
`Response triggered of no keywords are said`)

Keep in mine the query will all be lowercase so keywords should be typed in all lowercase unless you know how to use regex with would be pretty helpful for adding s’s onto the end of keywords as a possibility without making an entire new check
You may want to use pastebin if you plan on adding a lot of possiblities
Also not 100% sure on this but if a query were to have two key words the key word earlier on in the command should be the response that shows

Also if you have multiple keywords with the same response try something like this:

Q.includes(`Keyword1`)||Q.includes(`Keyword2`)?`Response for both`

If you have any questions feel free to ask

1 Like

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