Correct spam bug

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2023-03-31 21:24:57 -05:00
parent 459b8865b6
commit d4a3f2f5e7

11
main.ts
View File

@ -104,10 +104,12 @@ client.on('messageCreate', message => {
var matchMessageArray = message.content.toLowerCase().split(/[ ,!@#$%^&*()]+/);
console.log(matchMessageArray);
var correctedMessage = message.content;
let correctedMessage = message.content;
let matchDetected = false;
for (let i = 0; i < matchMessageArray.length; ++i) {
console.log("Corrected Message: " + correctedMessage);
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
matchDetected = true;
//Return key
var phrase = abbreviationKey.target_phrases[matchMessageArray[i]];
var abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase];
@ -136,6 +138,9 @@ client.on('messageCreate', message => {
//break;
}
}
replyMessage(message, correctedMessage);
if (matchDetected) {
replyMessage(message, correctedMessage);
}
}
);