diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index cc69bf0..798678d 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -5,11 +5,19 @@
 import getEmojiByName from "../utils/getEmojiByName.js";
 import client from "../utils/client.js";
 import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
-import { ChannelType, Message, ThreadChannel } from "discord.js";
+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[] }) {
+    if (exceptions.users.includes(user.id)) return true;
+    for (const role of user.roles.cache.values()) {
+        if (exceptions.roles.includes(role.id)) return true;
+    }
+    return false;
+}
+
 export async function callback(_client: NucleusClient, message: Message) {
     if (!message.guild) return;
     const config = await client.memory.readGuildInfo(message.guild.id);
@@ -45,10 +53,7 @@
 
     const content = message.content.toLowerCase() || "";
     if (config.filters.clean.channels.includes(message.channel.id)) {
-        const memberRoles = message.member!.roles.cache.map((role) => role.id);
-        const roleAllow = config.filters.clean.allowed.roles.some((role) => memberRoles.includes(role));
-        const userAllow = config.filters.clean.allowed.users.includes(message.author.id);
-        if (!roleAllow && !userAllow) return await message.delete();
+        if (!checkUserForExceptions(message.member!, config.filters.clean.allowed)) return await message.delete();
     }
 
     const filter = getEmojiByName("ICONS.FILTER");
@@ -72,7 +77,10 @@
     };
 
     if (config.filters.invite.enabled) {
-        if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
+        if (
+            !config.filters.invite.allowed.channels.includes(message.channel.id) ||
+            !checkUserForExceptions(message.member!, config.filters.invite.allowed)
+        ) {
             if (/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content)) {
                 messageException(message.guild.id, message.channel.id, message.id);
                 await message.delete();
@@ -149,7 +157,11 @@
                         config.filters.wordFilter.words.loose,
                         config.filters.wordFilter.words.strict
                     );
-                    if (check !== null) {
+                    if (
+                        check !== null &&
+                        (!checkUserForExceptions(message.member!, config.filters.wordFilter.allowed) ||
+                            !config.filters.wordFilter.allowed.channels.includes(message.channel.id))
+                    ) {
                         messageException(message.guild.id, message.channel.id, message.id);
                         await message.delete();
                         const data = {
@@ -264,7 +276,11 @@
         return log(data);
     }
 
-    if (config.filters.wordFilter.enabled) {
+    if (
+        config.filters.wordFilter.enabled &&
+        (!checkUserForExceptions(message.member!, config.filters.wordFilter.allowed) ||
+            !config.filters.wordFilter.allowed.channels.includes(message.channel.id))
+    ) {
         const check = TestString(
             content,
             config.filters.wordFilter.words.loose,
@@ -297,7 +313,11 @@
         }
     }
 
-    if (config.filters.pings.everyone && message.mentions.everyone) {
+    if (
+        config.filters.pings.everyone &&
+        message.mentions.everyone &&
+        !checkUserForExceptions(message.member!, config.filters.pings.allowed)
+    ) {
         if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
         const data = {
             meta: {
@@ -318,7 +338,7 @@
         };
         return log(data);
     }
-    if (config.filters.pings.roles) {
+    if (config.filters.pings.roles && !checkUserForExceptions(message.member!, config.filters.pings.allowed)) {
         for (const roleId in message.mentions.roles) {
             if (!config.filters.pings.allowed.roles.includes(roleId)) {
                 messageException(message.guild.id, message.channel.id, message.id);
@@ -347,7 +367,11 @@
             }
         }
     }
-    if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
+    if (
+        message.mentions.users.size >= config.filters.pings.mass &&
+        config.filters.pings.mass &&
+        !checkUserForExceptions(message.member!, config.filters.pings.allowed)
+    ) {
         messageException(message.guild.id, message.channel.id, message.id);
         await message.delete();
         if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
