Don't try to check roles if message came from a bot (or webhook, they both return true for that flag)
This commit is contained in:
parent
dd9548cf18
commit
81bdab6bbc
30
main.ts
30
main.ts
@ -99,7 +99,7 @@ function replyMessage(message, correctedMessage, abbrsUsed) {
|
||||
} else {
|
||||
plural = abbrsUsed + " acronyms"
|
||||
}
|
||||
message.reply("Your message contains " + plural +"! Let me fix that for you: \n > " + correctedMessage);
|
||||
message.reply("Your message contains " + plural + "! Let me fix that for you: \n > " + correctedMessage);
|
||||
}
|
||||
|
||||
client.on('messageCreate', message => {
|
||||
@ -112,10 +112,10 @@ client.on('messageUpdate', (undefined, newMessage) => {
|
||||
|
||||
function checkMessage(message) {
|
||||
console.log(`${message.author.tag} in #${message.channel.name} sent: ${message.content}`);
|
||||
//console.log(message.author);
|
||||
if (message.author.id == "1091120267851485215") {
|
||||
return;
|
||||
}
|
||||
//console.log(message.author);
|
||||
if (message.author.id == "1091120267851485215") {
|
||||
return;
|
||||
}
|
||||
|
||||
var matchMessageArray = message.content.toLowerCase().split(/[ ,!@#$%^&*().;:|]+/);
|
||||
|
||||
@ -126,17 +126,17 @@ function checkMessage(message) {
|
||||
for (let i = 0; i < matchMessageArray.length; ++i) {
|
||||
var rebuildMessageArray = [];
|
||||
//console.log("Corrected Message: " + correctedMessage);
|
||||
if (!message.author.bot) {
|
||||
|
||||
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
|
||||
console.log("Has role? " + message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms"));
|
||||
if (message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) {
|
||||
message.react('🇵');
|
||||
message.react('🇴');
|
||||
message.react('🇬');
|
||||
return;
|
||||
if (!message.author.bot) {
|
||||
if (message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) {
|
||||
message.react('🇵');
|
||||
message.react('🇴');
|
||||
message.react('🇬');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
matchDetected = true;
|
||||
abbrsUsed++;
|
||||
//Return key
|
||||
@ -164,12 +164,12 @@ function checkMessage(message) {
|
||||
correctedMessage += rebuildMessageArray[j];
|
||||
}
|
||||
console.log(correctedMessage);
|
||||
|
||||
|
||||
//break;
|
||||
}
|
||||
}
|
||||
if (matchDetected) {
|
||||
replyMessage(message, correctedMessage, abbrsUsed);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user