Simplify and correct conditional in invite filtering
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index 126450f..23a7622 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -8,7 +8,6 @@
import { ChannelType, GuildMember, Message, ThreadChannel } from "discord.js";
import singleNotify from "../utils/singleNotify.js";
-
export const event = "messageCreate";
function checkUserForExceptions(user: GuildMember, exceptions: { roles: string[]; users: string[] }) {
@@ -58,7 +57,7 @@
const filter = getEmojiByName("ICONS.FILTER");
let attachmentJump = "";
- console.log(config.logging.attachments.saved)
+ console.log(config.logging.attachments.saved);
if (config.logging.attachments.saved[message.channel.id + message.id]) {
attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`;
}
@@ -79,34 +78,37 @@
if (config.filters.invite.enabled) {
if (
- !config.filters.invite.allowed.channels.includes(message.channel.id) ||
- !checkUserForExceptions(message.member!, config.filters.invite.allowed)
+ !(
+ config.filters.invite.allowed.channels.includes(message.channel.id) ||
+ checkUserForExceptions(message.member!, config.filters.invite.allowed)
+ ) &&
+ /(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(lowerCaseContent)
) {
- if (/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(lowerCaseContent)) {
- messageException(message.guild.id, message.channel.id, message.id);
- await message.delete();
- const data = {
- meta: {
- type: "messageDelete",
- displayName: "Message Deleted",
- calculateType: "autoModeratorDeleted",
- color: NucleusColors.red,
- emoji: "MESSAGE.DELETE",
- timestamp: Date.now()
- },
- separate: {
- start:
- filter +
- " Contained invite\n\n" +
- (lowerCaseContent ? `**Message:**\n\`\`\`${message.content}\`\`\`` : "**Message:** *Message had no content*")
- },
- list: list,
- hidden: {
- guild: message.channel.guild.id
- }
- };
- return log(data);
- }
+ messageException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
+ meta: {
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
+ color: NucleusColors.red,
+ emoji: "MESSAGE.DELETE",
+ timestamp: Date.now()
+ },
+ separate: {
+ start:
+ filter +
+ " Contained invite\n\n" +
+ (lowerCaseContent
+ ? `**Message:**\n\`\`\`${message.content}\`\`\``
+ : "**Message:** *Message had no content*")
+ },
+ list: list,
+ hidden: {
+ guild: message.channel.guild.id
+ }
+ };
+ return log(data);
}
}
@@ -238,7 +240,9 @@
start:
filter +
" File detected as malware\n\n" +
- (lowerCaseContent ? `**Message:**\n\`\`\`${message.content}\`\`\`` : "**Message:** *Message had no content*")
+ (lowerCaseContent
+ ? `**Message:**\n\`\`\`${message.content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -267,7 +271,9 @@
start:
filter +
` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` +
- (lowerCaseContent ? `**Message:**\n\`\`\`${message.content}\`\`\`` : "**Message:** *Message had no content*")
+ (lowerCaseContent
+ ? `**Message:**\n\`\`\`${message.content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -303,7 +309,9 @@
start:
filter +
" Message contained filtered word\n\n" +
- (lowerCaseContent ? `**Message:**\n\`\`\`${message.content}\`\`\`` : "**Message:** *Message had no content*")
+ (lowerCaseContent
+ ? `**Message:**\n\`\`\`${message.content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -330,7 +338,9 @@
timestamp: Date.now()
},
separate: {
- start: lowerCaseContent ? `**Message:**\n\`\`\`${message.content}\`\`\`` : "**Message:** *Message had no content*"
+ start: lowerCaseContent
+ ? `**Message:**\n\`\`\`${message.content}\`\`\``
+ : "**Message:** *Message had no content*"
},
list: list,
hidden: {
@@ -386,7 +396,9 @@
timestamp: Date.now()
},
separate: {
- start: lowerCaseContent ? `**Message:**\n\`\`\`${message.content}\`\`\`` : "**Message:** *Message had no content*"
+ start: lowerCaseContent
+ ? `**Message:**\n\`\`\`${message.content}\`\`\``
+ : "**Message:** *Message had no content*"
},
list: list,
hidden: {