[英]Javascript recognize sentence regardless of upper and lower case anywhere in the sentence
bot.on('message', message => {
if (message.content === 'This is a test') {
message.channel.send("Hello!");
}
});
So I want the bot to recognize the sentence even if it is spelled something like this: "THIs iS A tEsT"所以我希望机器人能够识别这个句子,即使它的拼写是这样的:“THIs iS A tEsT”
You can do:你可以做:
if (message.content.toLowerCase().includes('this is a test')) {
message.channel.send("Hello!");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.