Merge branch 'master' of ssh://gitea.calebfontenot.com:25566/CCF_100/NoMoreAcronyms

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2023-04-04 13:00:51 -05:00
commit 1b145f8953

33
main.ts
View File

@ -131,17 +131,8 @@ function checkMessage(message) {
//console.log("Corrected Message: " + correctedMessage); //console.log("Corrected Message: " + correctedMessage);
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) { if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
console.log("Has role? " + message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")); if (checkIfExempt(message)) {
if (!message.author.bot) { return;
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;
}
} }
matchDetected = true; matchDetected = true;
abbrsUsed++; abbrsUsed++;
@ -157,9 +148,9 @@ function checkMessage(message) {
console.log("rebuildMessageArray: " + rebuildMessageArray); console.log("rebuildMessageArray: " + rebuildMessageArray);
} 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; return;
} }
//https://gitea.calebfontenot.com/CCF_100/NoMoreAcronyms/issues/1
arrayRotate(rebuildMessageArray, true, 1); arrayRotate(rebuildMessageArray, true, 1);
rebuildMessageArray.unshift("`" + phrase + "`"); rebuildMessageArray.unshift("`" + phrase + "`");
arrayRotate(rebuildMessageArray, true, 2); 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) { function checkInsult(message) {
if (!message.author.bot) { 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 == "Exempt from NoMoreAcronyms")) {