Correct spam bug
This commit is contained in:
parent
7b3f6af93f
commit
43b1e84409
10
main.ts
10
main.ts
@ -104,19 +104,19 @@ client.on('messageCreate', message => {
|
||||
var matchMessageArray = message.content.toLowerCase().split(/[ ,!@#$%^&*()]+/);
|
||||
|
||||
console.log(matchMessageArray);
|
||||
var correctedMessage = message.content;
|
||||
|
||||
for (let i = 0; i < matchMessageArray.length; ++i) {
|
||||
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
|
||||
//Return key
|
||||
var phrase = abbreviationKey.target_phrases[matchMessageArray[i]];
|
||||
|
||||
var abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase];
|
||||
console.log(typeof(abbr));
|
||||
|
||||
console.log("Found abbreviation: " + abbr);
|
||||
console.log("Phrase that matches used acronym: " + phrase);
|
||||
if (abbr !== "") {
|
||||
var rebuildMessageArray = message.content.split(new RegExp(abbr, 'i'));
|
||||
var rebuildMessageArray = correctedMessage.split(new RegExp(abbr, 'i'));
|
||||
} else {
|
||||
message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this...");
|
||||
break;
|
||||
@ -127,15 +127,15 @@ client.on('messageCreate', message => {
|
||||
arrayRotate(rebuildMessageArray, true, 2);
|
||||
console.log(rebuildMessageArray);
|
||||
// Build into string and set to variable!
|
||||
var correctedMessage = "";
|
||||
|
||||
for (let j = 0; j < rebuildMessageArray.length; j++) {
|
||||
correctedMessage += rebuildMessageArray[j];
|
||||
}
|
||||
console.log(correctedMessage);
|
||||
replyMessage(message, correctedMessage);
|
||||
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
replyMessage(message, correctedMessage);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user