diff --git a/src/utils/log.ts b/src/utils/log.ts
index 14e9750..238b6f4 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -10,80 +10,82 @@
 
 
 export class Logger {
-	renderUser(user: Discord.User | string) {
-		if (typeof user == 'string') return `${user} [<@${user}>]`;
-		return `${user.username} [<@${user.id}>]`;
-	}
-	renderTime(t: number) {
-		t = Math.floor(t /= 1000)
-		return `<t:${t}:D> at <t:${t}:T>`;
-	}
-	renderDelta(t: number) {
-		t = Math.floor(t /= 1000)
-		return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
-	}
-	renderNumberDelta(num1, num2) {
-		let delta = num2 - num1;
-		return `${num1} -> ${num2} (${delta > 0 ? '+' : ''}${delta})`;
-	}
-	entry(value, displayValue) {
-		return { value: value, displayValue: displayValue }
-	}
-	renderChannel(channel: Discord.GuildChannel) {
-		return `${channel.name} [<#${channel.id}>]`;
-	}
-	renderRole(role: Discord.Role) {
-		return `${role.name} [<@&${role.id}>]`;
-	}
-	renderEmoji(emoji: Discord.GuildEmoji) {
-		return `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
-	}
+    renderUser(user: Discord.User | string) {
+        if (typeof user == 'string') return `${user} [<@${user}>]`;
+        return `${user.username} [<@${user.id}>]`;
+    }
+    renderTime(t: number) {
+        t = Math.floor(t /= 1000)
+        return `<t:${t}:D> at <t:${t}:T>`;
+    }
+    renderDelta(t: number) {
+        t = Math.floor(t /= 1000)
+        return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
+    }
+    renderNumberDelta(num1, num2) {
+        let delta = num2 - num1;
+        return `${num1} -> ${num2} (${delta > 0 ? '+' : ''}${delta})`;
+    }
+    entry(value, displayValue) {
+        return { value: value, displayValue: displayValue }
+    }
+    renderChannel(channel: Discord.GuildChannel | Discord.ThreadChannel | Discord.NewsChannel) {
+        return `${channel.name} [<#${channel.id}>]`;
+    }
+    renderRole(role: Discord.Role) {
+        return `${role.name} [<@&${role.id}>]`;
+    }
+    renderEmoji(emoji: Discord.GuildEmoji) {
+        return `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
+    }
 
-	public readonly NucleusColors = {
-		red: 0xF27878,
-		yellow: 0xF2D478,
-		green: 0x68D49E,
+    public readonly NucleusColors = {
+        red: 0xF27878,
+        yellow: 0xF2D478,
+        green: 0x68D49E,
 
-	}
+    }
 
-	async getAuditLog(guild: Discord.Guild, event) {
-		await wait(250)
-		let auditLog = await guild.fetchAuditLogs({type: event});
-		return auditLog;
-	}
+    async getAuditLog(guild: Discord.Guild, event) {
+        await wait(250)
+        let auditLog = await guild.fetchAuditLogs({type: event});
+        return auditLog;
+    }
 
-	async log(log: any, client): Promise<void> {
-		let config = await readConfig(log.hidden.guild);
-		if (!config.logging.logs.enabled) return;
-		if (!(log.meta.calculateType == true)) if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log('Not logging this type of event');
-		if (config.logging.logs.channel) {
-			let channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
-			let description = {};
-			Object.entries(log.list).map(entry => {
-				let key = entry[0];
-				let value:any = entry[1];
-				if(value.displayValue) {
-					description[key] = value.displayValue;
-				} else {
-					description[key] = value;
-				}
-			})
-			if (channel) {
-				log.separate = log.separate || {};
-				let embed = new Discord.MessageEmbed()
-					.setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
-					.setDescription(
-						(log.separate.start ? log.separate.start + "\n" : "") +
-						generateKeyValueList(description) +
-						(log.separate.end ? "\n" + log.separate.end : "")
-					)
-					.setTimestamp(log.meta.timestamp)
-					.setColor(log.meta.color);
-				channel.send({embeds: [embed]});
-			}
-		}
-		saveLog(log);
-	}
+    async log(log: any, client): Promise<void> {
+        let config = await readConfig(log.hidden.guild);
+        if (!config.logging.logs.enabled) return;
+        if (!(log.meta.calculateType == true)) {
+            if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log('Not logging this type of event');
+        }
+        if (config.logging.logs.channel) {
+            let channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
+            let description = {};
+            Object.entries(log.list).map(entry => {
+                let key = entry[0];
+                let value:any = entry[1];
+                if(value.displayValue) {
+                    description[key] = value.displayValue;
+                } else {
+                    description[key] = value;
+                }
+            })
+            if (channel) {
+                log.separate = log.separate || {};
+                let embed = new Discord.MessageEmbed()
+                    .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
+                    .setDescription(
+                        (log.separate.start ? log.separate.start + "\n" : "") +
+                        generateKeyValueList(description) +
+                        (log.separate.end ? "\n" + log.separate.end : "")
+                    )
+                    .setTimestamp(log.meta.timestamp)
+                    .setColor(log.meta.color);
+                channel.send({embeds: [embed]});
+            }
+        }
+        saveLog(log);
+    }
 }
 
 
@@ -93,9 +95,9 @@
 }
 
 export function readLogs(guild: string) {
-	
+    
 }
 
 export function readSpecificLog(guild: string, id: number) {
-	
+    
 }
