I mean like if a person says "hi" it will respond hi but not if person says "hi anythingelse"
CodePudding user response:
here is the way you would check if a variable equals "hi" and print "hi" to the console.
var usrResponse = "hi"
if(usrResponse === "hi"){
console.log("hi")
}
CodePudding user response:
This is actually very easy and better method that i would recommend. You have to methods the message.content.match
or the message.content.startsWith
the 1st method is used for detecting the exact letter on any comment ex. hello i u
like the detected i want is u
anywhere on the comment is found the letter u
it will reply as for the second it only works if the first letter is in the beginning of the comment ex. u hi lol
it wont work if the letter is in the middle as for the 1st option.
//1st method
if(message.content.match("u") {
message.channel.send({ content: 'u hi?' })
}
//2nd method
if(message.content.startsWith("u") {
message.channel.send({ content: 'u hi?' })
}
// I would recommend you to add this to your message.js or your main/index.js
// or else this won't work i hope i helped you enough