我正在尝试制作我的不和谐机器人,以便每当用户输入某些单词时它都会在控制台中进行标记。如果第一个单词包含设置为标记的单词,则代码完全可以正常工作,但是如果有人输入“You are an****”,它不会检测到,但只有“n****”会标记,因为它当说出多个应该标记的单词时,标记也有问题。
client.flags = new Discord.Collection();
const flagFiles = fs.readdirSync('./flag/').filter(file => file.endsWith('.js'));
for(const file of flagFiles){
const flag = require(`./flag/${file}`);
client.flags.set(flag.name, flag);
}
client.on("message", function(message){
console.log("Channel:" + color.blue(message.channel) + " " + "Author:" + color.blue(message.author) + " " + "Message:" + color.blue(message.content))
if (message.author.bot) return;
const flagwords = ["spam","Spam","Nig", "nig", "N19", "n19"];
const args1 = message.content.slice(flagwords).split(/ +/);
const msg = args1.shift().toLowerCase();
if (msg.includes("spam") || msg == "spam" || msg == "spam" || msg.includes("spam")) {
client.flags.get("spam").execute(message, args1);
}
if (msg.includes("nig") || msg == "nig" || msg == "nig" || msg.includes("nig")) {
client.flags.get("nigga").execute(message, args1);
}
if (msg.includes("n19") || msg == "n19" || msg == "n19" || msg.includes("n19")) {
client.flags.get("nigga").execute(message, args1);
}
});