diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index ac29238..e8c888a 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -3,69 +3,71 @@
 export const event = 'channelDelete'
 
 export async function callback(client, channel) {
-	const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
+    try{
+        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
 
-	let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
-	let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
-    if (audit.executor.id == client.user.id) return;
+        let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
+        let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
+        if (audit.executor.id == client.user.id) return;
 
-	let emoji;
-	let readableType;
-	let displayName;
-	switch (channel.type) {
-		case 'GUILD_TEXT': {
-			emoji = "CHANNEL.TEXT.DELETE";
-			readableType = "Text";
-			displayName = "Text Channel"
-			break;
-		}
-		case 'GUILD_VOICE': {
-			emoji = "CHANNEL.VOICE.DELETE";
-			readableType = "Voice";
-			displayName = "Voice Channel"
-			break;
-		}
-		case 'GUILD_CATEGORY': {
-			emoji = "CHANNEL.CATEGORY.DELETE";
-			readableType = "Category";
-			displayName = "Category"
-			break;
-		}
-		default: {
-			emoji = "CHANNEL.TEXT.DELETE";
-			readableType = "Channel";
-			displayName = "Channel"
-		}
-	}
-	let list = {
-		id: entry(channel.id, `\`${channel.id}\``),
-		name: entry(channel.id, `${channel.name}`),
-		topic: null,
-		type: entry(channel.type, readableType),
-		category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
-		nsfw: null,
-		created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
-		deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-		deletedBy: entry(audit.executor.id, renderUser(audit.executor))
-	}
-	if (channel.topic != null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
-	else delete list.topic;
-	if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
-	else delete list.nsfw;
+        let emoji;
+        let readableType;
+        let displayName;
+        switch (channel.type) {
+            case 'GUILD_TEXT': {
+                emoji = "CHANNEL.TEXT.DELETE";
+                readableType = "Text";
+                displayName = "Text Channel"
+                break;
+            }
+            case 'GUILD_VOICE': {
+                emoji = "CHANNEL.VOICE.DELETE";
+                readableType = "Voice";
+                displayName = "Voice Channel"
+                break;
+            }
+            case 'GUILD_CATEGORY': {
+                emoji = "CHANNEL.CATEGORY.DELETE";
+                readableType = "Category";
+                displayName = "Category"
+                break;
+            }
+            default: {
+                emoji = "CHANNEL.TEXT.DELETE";
+                readableType = "Channel";
+                displayName = "Channel"
+            }
+        }
+        let list = {
+            id: entry(channel.id, `\`${channel.id}\``),
+            name: entry(channel.id, `${channel.name}`),
+            topic: null,
+            type: entry(channel.type, readableType),
+            category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+            nsfw: null,
+            created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+            deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+            deletedBy: entry(audit.executor.id, renderUser(audit.executor))
+        }
+        if (channel.topic != null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
+        else delete list.topic;
+        if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
+        else delete list.nsfw;
 
-	let data = {
-		meta:{
-			type: 'channelDelete',
-			displayName: displayName + ' Deleted',
-			calculateType: 'channelUpdate',
-			color: NucleusColors.red,
-			emoji: emoji,
-			timestamp: audit.createdTimestamp
-		},
-		list: list,
-		hidden: {
-			guild: channel.guild.id
-		}
-	}
-	log(data, channel.client);
+        let data = {
+            meta:{
+                type: 'channelDelete',
+                displayName: displayName + ' Deleted',
+                calculateType: 'channelUpdate',
+                color: NucleusColors.red,
+                emoji: emoji,
+                timestamp: audit.createdTimestamp
+            },
+            list: list,
+            hidden: {
+                guild: channel.guild.id
+            }
+        }
+        log(data, channel.client);
+    } catch {}
 }
