Hey this should be an easy question I was wondering how and if i could possibly make this if statement check for "hello" regardless if it's written hello, HELLO, heLLO ect. this is my code here don't worry all the other variables are being taken care of by another library (discord's to be exact) Thanks
bot.on('message', function(message){
if(message.content == "hello")
{
message.reply("hello");
}
in javascript you can use .toUpperCase()
at the end of any string variable or litteral
or same goes for .toLowerCase()
so first you need to convert to upper case or lower case then compare
if (message.content.toUpperCase()==="HELLO")
or
if (message.content.toLowerCase()==="hello")
this is the full code
bot.on('message', function(message){
if(message.content.toLowerCase() === "hello")
{
message.reply("hello");
}
You can use .toUpperCase()
bot.on('message', function(message){
if(message.content.toUpperCase() == "HELLO")
{
message.reply("hello");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.