diff --git a/main.ts b/main.ts index 5c3cfe5..145acb7 100644 --- a/main.ts +++ b/main.ts @@ -131,17 +131,8 @@ function checkMessage(message) { //console.log("Corrected Message: " + correctedMessage); if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) { - console.log("Has role? " + message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")); - if (!message.author.bot) { - if (message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) { - if (!message.member.roles.cache.some(role => role.name == "NoReactions")) { - message.react('🇵'); - message.react('🇴'); - message.react('🇬'); - return; - } - return; - } + if (checkIfExempt(message)) { + return; } matchDetected = true; abbrsUsed++; @@ -157,9 +148,9 @@ function checkMessage(message) { console.log("rebuildMessageArray: " + rebuildMessageArray); } else { message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this..."); - break; + return; } - + //https://gitea.calebfontenot.com/CCF_100/NoMoreAcronyms/issues/1 arrayRotate(rebuildMessageArray, true, 1); rebuildMessageArray.unshift("`" + phrase + "`"); arrayRotate(rebuildMessageArray, true, 2); @@ -179,6 +170,22 @@ function checkMessage(message) { } } +function checkIfExempt(message) { + console.log("Has role? " + message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")); + if (!message.author.bot) { + if (message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) { + if (!message.member.roles.cache.some(role => role.name == "NoReactions")) { + message.react('🇵'); + message.react('🇴'); + message.react('🇬'); + return true; + } + return true; + } + } + return false; +} + function checkInsult(message) { if (!message.author.bot) { if (!message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) {