Refactor exemption checking
This commit is contained in:
parent
d498d663e2
commit
22e3be26db
29
main.ts
29
main.ts
@ -131,18 +131,9 @@ 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('🇬');
|
||||
if (checkIfExempt(message)) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
matchDetected = true;
|
||||
abbrsUsed++;
|
||||
//Return key
|
||||
@ -157,7 +148,7 @@ 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);
|
||||
@ -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")) {
|
||||
|
Loading…
Reference in New Issue
Block a user