diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index f374edd..25b7375 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -1,133 +1,135 @@
 import humanizeDuration from 'humanize-duration';
-import readConfig from '../utils/readConfig.js'
 import getEmojiByName from '../utils/getEmojiByName.js';
 
 export const event = 'channelUpdate';
 
 export async function callback(client, oc, nc) {
-	let config = await readConfig(nc.guild.id);
-	const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
+    try {
+        let config = await client.memory.readGuildInfo(nc.guild.id);
+        const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
 
-	if (nc.parent && (nc.parent.id == config.tickets.category)) return
+        if (nc.parent && (nc.parent.id == config.tickets.category)) return
 
-	let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
-	let audit = auditLog.entries.filter(entry => entry.target.id == nc.id).first();
-    if (audit.executor.id == client.user.id) return;
+        let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
+        let audit = auditLog.entries.filter(entry => entry.target.id == nc.id).first();
+        if (audit.executor.id == client.user.id) return;
 
-	let emoji:string;
-	let readableType:string;
-	let displayName:string ;
-	let changes = {
-		id: entry(nc.id, `\`${nc.id}\``),
-		channel: entry(nc.id, renderChannel(nc)),
-		edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
-		editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
-	}
-	if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
-	if (oc.position != nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
+        let emoji:string;
+        let readableType:string;
+        let displayName:string ;
+        let changes = {
+            id: entry(nc.id, `\`${nc.id}\``),
+            channel: entry(nc.id, renderChannel(nc)),
+            edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+            editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
+        }
+        if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+        if (oc.position != nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
 
-	switch (nc.type) {
-		case 'GUILD_TEXT': {
-			emoji = "CHANNEL.TEXT.EDIT";
-			readableType = "Text";
-			displayName = "Text Channel"
-			let oldTopic = oc.topic, newTopic = nc.topic;
-			if (oldTopic) {
-				if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-				else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-			} else { oldTopic = "None"; }
-			if (newTopic) {
-				if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-				else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-			} else { newTopic = "None"; }
-			let nsfw = ["", ""]
-			nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-			nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
-			if (oc.topic != nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
-			if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
-			if (oc.rateLimitPerUser != nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
-				[oc.rateLimitPerUser, nc.rateLimitPerUser],
-				`${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
-			);
-			break;
-		}
-		case 'GUILD_NEWS': {
-			emoji = "CHANNEL.TEXT.EDIT";
-			readableType = "News";
-			displayName = "News Channel"
-			let oldTopic = oc.topic, newTopic = nc.topic;
-			if (oldTopic) {
-				if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-				else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-			} else { oldTopic = "None"; }
-			if (newTopic) {
-				if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-				else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-			} else { newTopic = "None"; }
-			if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
-			break;
-		}
-		case 'GUILD_VOICE': {
-			emoji = "CHANNEL.VOICE.EDIT";
-			readableType = "Voice";
-			displayName = "Voice Channel"
-			if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
-			if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
-			if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
-				[oc.rtcRegion, nc.rtcRegion],
-				`${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
-			);
-			break;
-		}
-		case 'GUILD_STAGE': {
-			emoji = "CHANNEL.VOICE.EDIT";
-			readableType = "Stage";
-			displayName = "Stage Channel"
-			let oldTopic = oc.topic, newTopic = nc.topic;
-			if (oldTopic) {
-				if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-				else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
-			} else { oldTopic = "None"; }
-			if (newTopic) {
-				if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
-				else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
-			} else { newTopic = "None"; }
-			if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
-			if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
-			if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
-				[oc.rtcRegion, nc.rtcRegion],
-				`${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
-			);
-			break;
-		}
-		case 'GUILD_CATEGORY': {
-			emoji = "CHANNEL.CATEGORY.EDIT";
-			readableType = "Category";
-			displayName = "Category"
-			break;
-		}
-		default: {
-			emoji = "CHANNEL.TEXT.EDIT";
-			readableType = "Channel";
-			displayName = "Channel"
-		}
-	}
-	let t = oc.type.split("_")[1];
-	if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
-	if (!(Object.values(changes).length - 4)) return
-	let data = {
-		meta:{
-			type: 'channelUpdate',
-			displayName: displayName + ' Edited',
-			calculateType: 'channelUpdate',
-			color: NucleusColors.yellow,
-			emoji: emoji,
-			timestamp: audit.createdTimestamp
-		},
-		list: changes,
-		hidden: {
-			guild: nc.guild.id
-		}
-	}
-	log(data, client);
+        switch (nc.type) {
+            case 'GUILD_TEXT': {
+                emoji = "CHANNEL.TEXT.EDIT";
+                readableType = "Text";
+                displayName = "Text Channel"
+                let oldTopic = oc.topic, newTopic = nc.topic;
+                if (oldTopic) {
+                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
+                } else { oldTopic = "None"; }
+                if (newTopic) {
+                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
+                } else { newTopic = "None"; }
+                let nsfw = ["", ""]
+                nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+                nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+                if (oc.topic != nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+                if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
+                if (oc.rateLimitPerUser != nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
+                    [oc.rateLimitPerUser, nc.rateLimitPerUser],
+                    `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
+                );
+
+                break;
+            }
+            case 'GUILD_NEWS': {
+                emoji = "CHANNEL.TEXT.EDIT";
+                readableType = "News";
+                displayName = "News Channel"
+                let oldTopic = oc.topic, newTopic = nc.topic;
+                if (oldTopic) {
+                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
+                } else { oldTopic = "None"; }
+                if (newTopic) {
+                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
+                } else { newTopic = "None"; }
+                if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
+                break;
+            }
+            case 'GUILD_VOICE': {
+                emoji = "CHANNEL.VOICE.EDIT";
+                readableType = "Voice";
+                displayName = "Voice Channel"
+                if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+                if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+                if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+                    [oc.rtcRegion, nc.rtcRegion],
+                    `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+                );
+                break;
+            }
+            case 'GUILD_STAGE': {
+                emoji = "CHANNEL.VOICE.EDIT";
+                readableType = "Stage";
+                displayName = "Stage Channel"
+                let oldTopic = oc.topic, newTopic = nc.topic;
+                if (oldTopic) {
+                    if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+                    else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
+                } else { oldTopic = "None"; }
+                if (newTopic) {
+                    if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+                    else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
+                } else { newTopic = "None"; }
+                if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+                if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+                if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+                    [oc.rtcRegion, nc.rtcRegion],
+                    `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+                );
+                break;
+            }
+            case 'GUILD_CATEGORY': {
+                emoji = "CHANNEL.CATEGORY.EDIT";
+                readableType = "Category";
+                displayName = "Category"
+                break;
+            }
+            default: {
+                emoji = "CHANNEL.TEXT.EDIT";
+                readableType = "Channel";
+                displayName = "Channel"
+            }
+        }
+        let t = oc.type.split("_")[1];
+        if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
+        if (!(Object.values(changes).length - 4)) return
+        let data = {
+            meta:{
+                type: 'channelUpdate',
+                displayName: displayName + ' Edited',
+                calculateType: 'channelUpdate',
+                color: NucleusColors.yellow,
+                emoji: emoji,
+                timestamp: audit.createdTimestamp
+            },
+            list: changes,
+            hidden: {
+                guild: nc.guild.id
+            }
+        }
+        log(data, client);
+    } catch {}
 }
\ No newline at end of file
