Correct spam bug

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2023-03-31 21:14:12 -05:00
parent 7b3f6af93f
commit 43b1e84409

10
main.ts
View File

@ -104,19 +104,19 @@ client.on('messageCreate', message => {
var matchMessageArray = message.content.toLowerCase().split(/[ ,!@#$%^&*()]+/); var matchMessageArray = message.content.toLowerCase().split(/[ ,!@#$%^&*()]+/);
console.log(matchMessageArray); console.log(matchMessageArray);
var correctedMessage = message.content;
for (let i = 0; i < matchMessageArray.length; ++i) { for (let i = 0; i < matchMessageArray.length; ++i) {
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) { if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
//Return key //Return key
var phrase = abbreviationKey.target_phrases[matchMessageArray[i]]; var phrase = abbreviationKey.target_phrases[matchMessageArray[i]];
var abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase]; var abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase];
console.log(typeof(abbr)); console.log(typeof(abbr));
console.log("Found abbreviation: " + abbr); console.log("Found abbreviation: " + abbr);
console.log("Phrase that matches used acronym: " + phrase); console.log("Phrase that matches used acronym: " + phrase);
if (abbr !== "") { if (abbr !== "") {
var rebuildMessageArray = message.content.split(new RegExp(abbr, 'i')); var rebuildMessageArray = correctedMessage.split(new RegExp(abbr, 'i'));
} else { } else {
message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this..."); message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this...");
break; break;
@ -127,15 +127,15 @@ client.on('messageCreate', message => {
arrayRotate(rebuildMessageArray, true, 2); arrayRotate(rebuildMessageArray, true, 2);
console.log(rebuildMessageArray); console.log(rebuildMessageArray);
// Build into string and set to variable! // Build into string and set to variable!
var correctedMessage = "";
for (let j = 0; j < rebuildMessageArray.length; j++) { for (let j = 0; j < rebuildMessageArray.length; j++) {
correctedMessage += rebuildMessageArray[j]; correctedMessage += rebuildMessageArray[j];
} }
console.log(correctedMessage); console.log(correctedMessage);
replyMessage(message, correctedMessage);
//break; //break;
} }
} }
replyMessage(message, correctedMessage);
} }
); );