【发布时间】:2021-12-18 23:38:10
【问题描述】:
所以我正在尝试向我的不和谐机器人添加一个帮助检测器,它会自动响应某些内容。例如,如果有人输入 I want help with login 它应该自动响应,但如果有人说 I want help 它应该什么都不做,所以它只在检测到句子包含帮助和登录时才会响应,并且我已经尝试为此编写代码但它根本没有响应,这是代码:
let help_words2 = ["help", "problems", "problem", "error", "issue"]
let help_words = ["psutil", "pyinstaller"]
if (message.content.toLowerCase().includes(help_words) && message.content.toLowerCase().includes(help_words2)) {
const embed = new MessageEmbed()
.setAuthor(`I'm here to help ${message.author.tag}!`,'https://img.icons8.com/fluency/48/000000/help.png',`${client.config.links.website}`)
.setDescription(`**I think you need help with python and before asking more questions make sure to check out these pages/channels**\n\n> <#905804981368664075>\n> <#905224439736705087>`)
message.channel.send(embed)
}
我也尝试使用 .indexOf() 而不是 .includes() 但当我使用它时,它会响应每条输入的消息,这不是我想要的。我在控制台中也没有收到任何错误或任何内容。所以问题是,我如何让不和谐机器人响应句子中的特定单词
【问题讨论】:
-
您是否在控制台中遇到任何错误?还是没有错误?
-
哦,没有错误,控制台中没有任何内容
标签: javascript discord discord.js