diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index c5cbe63..6edfeed 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -3,34 +3,36 @@
 export const event = 'roleDelete'
 
 export async function callback(client, role) {
-	const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
-    if (role.managed) return;
-    let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
-    let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
-    if (audit.executor.id == client.user.id) return;
-    let data = {
-        meta: {
-            type: 'roleDelete',
-            displayName: 'Role Deleted',
-            calculateType: 'guildRoleUpdate',
-            color: NucleusColors.red,
-            emoji: "GUILD.ROLES.DELETE",
-            timestamp: audit.createdTimestamp,
-        },
-        list: {
-            id: entry(role.id, `\`${role.id}\``),
-            role: entry(role.name, role.name),
-            color: entry(role.hexColor, `\`${role.hexColor}\``),
-            showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
-            mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
-            members: entry(role.members.size, `${role.members.size}`),
-            deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
-            created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
-            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
-        },
-        hidden: {
-            guild: role.guild.id
+    try {
+        const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
+        if (role.managed) return;
+        let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
+        let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
+        if (audit.executor.id == client.user.id) return;
+        let data = {
+            meta: {
+                type: 'roleDelete',
+                displayName: 'Role Deleted',
+                calculateType: 'guildRoleUpdate',
+                color: NucleusColors.red,
+                emoji: "GUILD.ROLES.DELETE",
+                timestamp: audit.createdTimestamp,
+            },
+            list: {
+                id: entry(role.id, `\`${role.id}\``),
+                role: entry(role.name, role.name),
+                color: entry(role.hexColor, `\`${role.hexColor}\``),
+                showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+                mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+                members: entry(role.members.size, `${role.members.size}`),
+                deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+                created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
+                deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+            },
+            hidden: {
+                guild: role.guild.id
+            }
         }
-    }
-    log(data, client);
+        log(data, client);
+    } catch {}
 }
