diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index 517d7f4..640ec13 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -1,16 +1,15 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
-import { SelectMenuOption } from '@discordjs/builders';
+import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
+import { SelectMenuOption } from "@discordjs/builders";
 import Discord, { MessageActionRow, MessageButton } from "discord.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 import createPageIndicator from "../utils/createPageIndicator.js";
-import client from "../utils/client.js";
 
 class Embed {
     embed: Discord.MessageEmbed;
     title: string;
-    description: string = "";
-    pageId: number = 0;
+    description = "";
+    pageId = 0;
     setEmbed(embed: Discord.MessageEmbed) { this.embed = embed; return this; }
     setTitle(title: string) { this.title = title; return this; }
     setDescription(description: string) { this.description = description; return this; }
@@ -20,7 +19,7 @@
 export default async (guild, interaction?) => {
     let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
     c = c ? c : guild.channels.cache.find(ch => ch.type === "GUILD_TEXT" && ch.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES") && ch.permissionsFor(guild.me).has("EMBED_LINKS"));
-    let pages = [
+    const pages = [
         new Embed()
             .setEmbed(new EmojiEmbed()
                 .setTitle("Welcome to Nucleus")
@@ -62,8 +61,8 @@
                     `**${getEmojiByName("PUNISH.BAN.RED")} Ban:** The user is removed from the server, and they are unable to rejoin.\n` +
                     `**${getEmojiByName("PUNISH.BAN.GREEN")} Unban:** The user is able to rejoin the server.`
                 )
-            .setEmoji("PUNISH.BAN.RED")
-            .setStatus("Danger")
+                .setEmoji("PUNISH.BAN.RED")
+                .setStatus("Danger")
             ).setTitle("Moderation").setDescription("Basic moderation commands").setPageId(2),
         new Embed()
             .setEmbed(new EmojiEmbed()
@@ -124,53 +123,53 @@
                 )
                 .setEmoji("NUCLEUS.COMMANDS.LOCK")
                 .setStatus("Danger")
-            ).setTitle("Premium").setDescription("Premium features").setPageId(7),
-    ]
+            ).setTitle("Premium").setDescription("Premium features").setPageId(7)
+    ];
     let m;
     if (interaction) { m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true}); }
     else { m = await c.send({embeds: LoadingEmbed }); }
     let page = 0;
 
-    let f = async (component) => {
+    const f = async (component) => {
         return (component.member as Discord.GuildMember).permissions.has("MANAGE_GUILD");
-    }
+    };
 
     let selectPaneOpen = false;
 
     while (true) {
-        let selectPane = []
+        let selectPane = [];
 
         if (selectPaneOpen) {
-            let options = [];
+            const options = [];
             pages.forEach(embed => {
                 options.push(new SelectMenuOption({
                     label: embed.title,
                     value: embed.pageId.toString(),
-                    description: embed.description || "",
-                }))
-            })
+                    description: embed.description || ""
+                }));
+            });
             selectPane = [new MessageActionRow().addComponents([
                 new Discord.MessageSelectMenu()
                     .addOptions(options)
                     .setCustomId("page")
                     .setMaxValues(1)
                     .setPlaceholder("Choose a page...")
-            ])]
+            ])];
         }
-        let components = selectPane.concat([new MessageActionRow().addComponents([
+        const components = selectPane.concat([new MessageActionRow().addComponents([
             new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(page === 0),
             new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(false),
             new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setStyle("SECONDARY").setDisabled(page === pages.length - 1)
-        ])])
+        ])]);
         if (interaction) {
-            let em = new Discord.MessageEmbed(pages[page].embed)
+            const em = new Discord.MessageEmbed(pages[page].embed);
             em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
             await interaction.editReply({
                 embeds: [em],
                 components: components
             });
         } else {
-            let em = new Discord.MessageEmbed(pages[page].embed)
+            const em = new Discord.MessageEmbed(pages[page].embed);
             em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
             await m.edit({
                 embeds: [em],
@@ -178,11 +177,11 @@
                 fetchReply: true
             });
         }
-        let i
+        let i;
         try {
-            i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, time: 300000});
-        } catch(e) { break }
-        i.deferUpdate()
+            i = await m.awaitMessageComponent({filter: interaction ? () => { return true; } : f, time: 300000});
+        } catch(e) { break; }
+        i.deferUpdate();
         if (i.component.customId === "left") {
             if (page > 0) page--;
             selectPaneOpen = false;
@@ -196,9 +195,9 @@
             selectPaneOpen = false;
         } else {
             if (interaction) {
-                let em = new Discord.MessageEmbed(pages[page].embed)
+                const em = new Discord.MessageEmbed(pages[page].embed);
                 em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
-                em.setFooter({text: "Message closed"})
+                em.setFooter({text: "Message closed"});
                 interaction.editReply({embeds: [em], components: [new MessageActionRow().addComponents([
                     new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setStyle("SECONDARY").setDisabled(true),
                     new MessageButton().setCustomId("select").setEmoji(getEmojiByName("CONTROL.MENU", "id")).setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY").setDisabled(true),
@@ -211,7 +210,7 @@
         }
     }
     if (interaction) {
-        let em = new Discord.MessageEmbed(pages[page].embed)
+        const em = new Discord.MessageEmbed(pages[page].embed);
         em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
         await interaction.editReply({
             embeds: [em],
@@ -222,7 +221,7 @@
             ])]
         });
     } else {
-        let em = new Discord.MessageEmbed(pages[page].embed)
+        const em = new Discord.MessageEmbed(pages[page].embed);
         em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({text: "Message timed out"});
         await m.edit({
             embeds: [em],
@@ -233,4 +232,4 @@
             ])]
         });
     }
-}
+};
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index 3b80816..435ce4c 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -1,33 +1,36 @@
-import * as us from 'unscan'
-import fetch from 'node-fetch'
-import { writeFileSync } from 'fs'
-import generateFileName from '../utils/temp/generateFileName.js'
-import Tesseract from 'node-tesseract-ocr';
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import * as us from "unscan";
+import fetch from "node-fetch";
+import { writeFileSync } from "fs";
+import generateFileName from "../utils/temp/generateFileName.js";
+import Tesseract from "node-tesseract-ocr";
+import type Discord from "discord.js";
 
 interface NSFWSchema { nsfw: boolean }
 interface MalwareSchema { safe: boolean }
 
 export async function testNSFW(link: string): Promise<NSFWSchema> {
-    let p = await saveAttachment(link)
-    let result = await us.nsfw.file(p)
-    return result
+    const p = await saveAttachment(link);
+    const result = await us.nsfw.file(p);
+    return result;
 }
 
 export async function testMalware(link: string): Promise<MalwareSchema> {
-    let p = await saveAttachment(link)
-    let result = await us.malware.file(p)
-    return result
+    const p = await saveAttachment(link);
+    const result = await us.malware.file(p);
+    return result;
 }
 
-export async function saveAttachment(link): Promise<string> {
-    const image = (await (await fetch(link)).buffer()).toString('base64')
-    let fileName = generateFileName(link.split('/').pop().split('.').pop())
-    writeFileSync(fileName, image, 'base64')
-    return fileName
+export async function saveAttachment(link: string): Promise<string> {
+    const image = (await (await fetch(link)).buffer()).toString("base64");
+    const fileName = generateFileName((link.split("/").pop() as string).split(".").pop() as string);
+    writeFileSync(fileName, image, "base64");
+    return fileName;
 }
 
-export async function testLink(link: string): Promise<unknown> {
-    return await us.link.scan(link)
+export async function testLink(link: string): Promise<{safe: boolean, tags: string[]}> {
+    return await us.link.scan(link);
 }
 
 
@@ -49,71 +52,76 @@
     "SCAMS": "Sites which are designed to trick you into doing something.",
     "TORRENT": "Websites that download torrent files.",
     "HATE": "Websites that spread hate towards groups or individuals.",
-    "JUNK": "Websites that are designed to make you waste time.",
-}
+    "JUNK": "Websites that are designed to make you waste time."
+};
 export { linkTypes };
 
 
-export async function LinkCheck(message): Promise<string[]> {
-    let links = message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []
-    let detections = []
-    const promises = links.map(async element => {
+export async function LinkCheck(message: Discord.Message): Promise<string[]> {
+    const links = message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi) ?? [];
+    const detections: {tags: string[], safe: boolean}[] = [];
+    const promises: Promise<void>[] = links.map(async element => {
+        let returned;
         try {
-            if (element.match(/https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/)) return // Also matches discord.net, not enough of a bug
-            element = await testLink(element)
-        } catch {}
-        detections.push({tags: element.tags || [], safe: element.safe})
+            if (element.match(/https?:\/\/[a-zA-Z]+\.?discord(app)?\.(com|net)\/?/)) return; // Also matches discord.net, not enough of a bug
+            returned = await testLink(element);
+        } catch {
+            detections.push({tags: [], safe: true});
+            return;
+        }
+        if (returned) { detections.push({tags: returned.tags || [], safe: returned.safe}); }
+        else { detections.push({tags: [], safe: true}); }
     });
     await Promise.all(promises);
-    let detectionsTypes = detections.map(element => {
-        let type = Object.keys(linkTypes).find(type => element.tags.includes(type))
-        if (type) return type
+    const detectionsTypes = detections.map(element => {
+        const type = Object.keys(linkTypes).find(type => element.tags.includes(type));
+        if (type) return type;
         // if (!element.safe) return "UNSAFE"
-        return undefined
-    }).filter(element => element !== undefined)
-    return detectionsTypes
+        return undefined;
+    }).filter(element => element !== undefined);
+    return detectionsTypes as string[];
 }
 
-export async function NSFWCheck(element): Promise<boolean> {
+export async function NSFWCheck(element: string): Promise<boolean> {
     try {
-        let test = (await testNSFW(element))
-        return test.nsfw
+        const test = (await testNSFW(element));
+        return test.nsfw;
     } catch {
-        return false
+        return false;
     }
 }
 
-export async function SizeCheck(element): Promise<boolean> {
-    if (element.height === undefined || element.width === undefined) return true
-    if (element.height < 20 || element.width < 20) return false
-    return true
+export async function SizeCheck(element: {height: number | null, width: number | null}): Promise<boolean> {
+    if (element.height === null || element.width === null) return true;
+    if (element.height < 20 || element.width < 20) return false;
+    return true;
 }
 
-export async function MalwareCheck(element): Promise<boolean> {
+export async function MalwareCheck(element: string): Promise<boolean> {
     try {
-        return (await testMalware(element)).safe
+        return (await testMalware(element)).safe;
     } catch {
-        return true
+        return true;
     }
 }
 
-export function TestString(string, soft, strict): object | null {
-    for(let word of strict || []) {
+export function TestString(string: string, soft: string[], strict: string[]): object | null {
+    for(const word of strict || []) {
         if (string.toLowerCase().includes(word)) {
-            return {word: word, type: "strict"}
+            return {word: word, type: "strict"};
         }
     }
-    for(let word of soft) {
-        for(let word2 of string.match(/[a-z]+/gi) || []) {
+    for(const word of soft) {
+        for(const word2 of string.match(/[a-z]+/gi) || []) {
             if (word2 === word) {
-                return {word: word, type: "strict"}
+                return {word: word, type: "strict"};
             }
         }
     }
-    return null
+    return null;
 }
 
-export async function TestImage(url): Promise<string | null> {
-    let text = await Tesseract.recognize(url, {lang: "eng", oem: 1, psm: 3})
+export async function TestImage(url: string): Promise<string | null> {
+    const text = await Tesseract.recognize(url, {lang: "eng", oem: 1, psm: 3});
     return text;
 }
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index b306ecc..7301a60 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -1,38 +1,38 @@
-import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
-import singleNotify from '../utils/singleNotify.js';
-import client from '../utils/client.js';
+import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
+import singleNotify from "../utils/singleNotify.js";
+import client from "../utils/client.js";
 
 interface PropSchema { enabled: boolean, name: string }
 
 export async function callback(_, member) {
-    let guild = await client.guilds.fetch(member.guild.id)
-    let config = await client.database.guilds.read(guild.id);
+    const guild = await client.guilds.fetch(member.guild.id);
+    const config = await client.database.guilds.read(guild.id);
     Object.entries(config.getKey("stats")).forEach(async ([channel, props]) => {
         if ((props as PropSchema).enabled) {
-            let string = (props as PropSchema).name
-            if (!string) return
-            string = await convertCurlyBracketString(string, member.id, member.displayName, guild.name, guild.members)
+            let string = (props as PropSchema).name;
+            if (!string) return;
+            string = await convertCurlyBracketString(string, member.id, member.displayName, guild.name, guild.members);
             let fetchedChannel;
             try {
-                fetchedChannel = await guild.channels.fetch(channel)
-            } catch (e) { fetchedChannel = null }
+                fetchedChannel = await guild.channels.fetch(channel);
+            } catch (e) { fetchedChannel = null; }
             if (!fetchedChannel) {
-                let deleted = config.getKey("stats")[channel]
-                console.log(`stats.${channel}`)
-                console.log(guild.id)
-                await client.database.guilds.write(guild.id, null, `stats.${channel}`)
+                const deleted = config.getKey("stats")[channel];
+                console.log(`stats.${channel}`);
+                console.log(guild.id);
+                await client.database.guilds.write(guild.id, null, `stats.${channel}`);
                 return singleNotify(
                     "statsChannelDeleted",
                     guild.id,
                     "One or more of your stats channels have been deleted. Please use `/settings stats` if you wish to add the channel again.\n" +
                     `The channels name was: ${deleted.name}`,
                     "Critical"
-                )
+                );
             }
             try {
-                await fetchedChannel.setName(string.slice(0, 100))
+                await fetchedChannel.setName(string.slice(0, 100));
             } catch (e) {
-                console.error(e)
+                console.error(e);
             }
         }
     });
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index bc7aa4f..d9fab66 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
 import Discord, { GuildMember } from "discord.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import fetch from "node-fetch";
@@ -11,12 +11,12 @@
 }
 
 export default async function(interaction) {
-    let verify = client.verify
+    const verify = client.verify;
     await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
-    let config = await client.database.guilds.read(interaction.guild.id);
+    const config = await client.database.guilds.read(interaction.guild.id);
     if ((!config.verify.enabled ) || (!config.verify.role)) return interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`Verify is not enabled on this server`)
+        .setDescription("Verify is not enabled on this server")
         .setFooter({text: interaction.member.permissions.has("MANAGE_GUILD") ? "You can enable it by running /settings verify" : ""})
         .setStatus("Danger")
         .setEmoji("CONTROL.BLOCKCROSS")
@@ -31,16 +31,16 @@
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`Checking our servers are up` + step(0))
+        .setDescription("Checking our servers are up" + step(0))
         .setStatus("Warning")
         .setEmoji("NUCLEUS.LOADING")
     ]});
     try {
-        let status = await fetch(client.config.baseUrl).then(res => res.status);
+        const status = await fetch(client.config.baseUrl).then(res => res.status);
         if (status !== 200) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify")
-                .setDescription(`Our servers appear to be down, please try again later` + step(0))
+                .setDescription("Our servers appear to be down, please try again later" + step(0))
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
             ]});
@@ -48,7 +48,7 @@
     } catch {
         return await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify")
-            .setDescription(`Our servers appear to be down, please try again later` + step(0))
+            .setDescription("Our servers appear to be down, please try again later" + step(0))
             .setStatus("Danger")
             .setEmoji("CONTROL.BLOCKCROSS")
         ], components: [new Discord.MessageActionRow().addComponents([
@@ -65,14 +65,14 @@
     if (config.filters.images.NSFW) {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify")
-            .setDescription(`Checking your avatar is safe for work` + step(1))
+            .setDescription("Checking your avatar is safe for work" + step(1))
             .setStatus("Warning")
             .setEmoji("NUCLEUS.LOADING")
         ]});
         if (await NSFWCheck((interaction.member as GuildMember).user.avatarURL({format: "png"}))) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify")
-                .setDescription(`Your avatar was detected as NSFW, which we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake` + step(1))
+                .setDescription("Your avatar was detected as NSFW, which we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake" + step(1))
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
             ]});
@@ -81,14 +81,14 @@
     if (config.filters.wordFilter) {
         await interaction.editReply({embeds: [new EmojiEmbed()
             .setTitle("Verify")
-            .setDescription(`Checking your name is allowed` + step(2))
+            .setDescription("Checking your name is allowed" + step(2))
             .setStatus("Warning")
             .setEmoji("NUCLEUS.LOADING")
         ]});
         if (TestString((interaction.member as Discord.GuildMember).displayName, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict) !== null) {
             return await interaction.editReply({embeds: [new EmojiEmbed()
                 .setTitle("Verify")
-                .setDescription(`Your name contained a word we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake` + step(2))
+                .setDescription("Your name contained a word we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake" + step(2))
                 .setStatus("Danger")
                 .setEmoji("CONTROL.BLOCKCROSS")
             ]});
@@ -96,23 +96,23 @@
     }
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`One moment...` + step(3))
+        .setDescription("One moment..." + step(3))
         .setStatus("Warning")
         .setEmoji("NUCLEUS.LOADING")
     ]});
-    let code = ""
-    let length = 5
-    let itt = 0
+    let code = "";
+    let length = 5;
+    let itt = 0;
     const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
     while (true) {
-        itt += 1
-        code = ""
+        itt += 1;
+        code = "";
         for (let i = 0; i < length; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); }
         if (code in verify) continue;
         if (itt > 1000) {
-            itt = 0
-            length += 1
-            continue
+            itt = 0;
+            length += 1;
+            continue;
         }
         break;
     }
@@ -125,10 +125,10 @@
         gName: interaction.guild.name,
         gIcon: interaction.guild.iconURL({format: "png"}),
         interaction: interaction
-    }
+    };
     await interaction.editReply({embeds: [new EmojiEmbed()
         .setTitle("Verify")
-        .setDescription(`Looking good!\nClick the button below to get verified` + step(4))
+        .setDescription("Looking good!\nClick the button below to get verified" + step(4))
         .setStatus("Success")
         .setEmoji("MEMBER.JOIN")
     ], components: [new Discord.MessageActionRow().addComponents([new Discord.MessageButton()
diff --git a/src/reflex/welcome.ts b/src/reflex/welcome.ts
index 9be71d5..b4bc374 100644
--- a/src/reflex/welcome.ts
+++ b/src/reflex/welcome.ts
@@ -1,39 +1,37 @@
-import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
-import client from '../utils/client.js';
-import EmojiEmbed from '../utils/generateEmojiEmbed.js';
+import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
+import client from "../utils/client.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 
 export async function callback(_, member) {
-    if (member.bot) return
-    let config = await client.database.guilds.read(member.guild.id);
-    if (!config.welcome.enabled) return
+    if (member.bot) return;
+    const config = await client.database.guilds.read(member.guild.id);
+    if (!config.welcome.enabled) return;
 
     if (config.welcome.channel) {
-        let string = config.welcome.message
+        let string = config.welcome.message;
         if (string) {
-            string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
-            if (config.welcome.channel === 'dm') {
-                try {
-                    await member.send({
-                        embeds: [new EmojiEmbed()
-                            .setDescription(string)
-                            .setStatus('Success')
-                        ]
-                    })
-                } catch {}
+            string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members);
+            if (config.welcome.channel === "dm") {
+                await member.send({
+                    embeds: [new EmojiEmbed()
+                        .setDescription(string)
+                        .setStatus("Success")
+                    ]
+                });
             } else {
-                let channel = await member.guild.channels.fetch(config.welcome.channel)
-                if (channel.guild.id !== member.guild.id) return
-                if (!channel) return
+                const channel = await member.guild.channels.fetch(config.welcome.channel);
+                if (channel.guild.id !== member.guild.id) return;
+                if (!channel) return;
                 try {
                     await channel.send({
                         embeds: [new EmojiEmbed()
                             .setDescription(string)
-                            .setStatus('Success')
+                            .setStatus("Success")
                         ],
-                        content: (config.welcome.ping ? `<@${config.welcome.ping}>` : '') + `<@${member.id}>`
-                    })
+                        content: (config.welcome.ping ? `<@${config.welcome.ping}>` : "") + `<@${member.id}>`
+                    });
                 } catch (err) {
-                    console.error(err) // SEN
+                    console.error(err); // TODO: SEN
                 }
             }
         }
