diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index a4bb8c3..08fcc77 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -1,57 +1,56 @@
-import { callback as roleMenu } from "../actions/roleMenu.js"
+import { callback as roleMenu } from "../actions/roleMenu.js";
 import verify from "../reflex/verify.js";
 import create from "../actions/tickets/create.js";
 import close from "../actions/tickets/delete.js";
 import createTranscript from "../premium/createTranscript.js";
 import Fuse from "fuse.js";
-import { autocomplete as tagAutocomplete } from "../commands/tag.js"
+import { autocomplete as tagAutocomplete } from "../commands/tag.js";
 
-export const event = 'interactionCreate';
+export const event = "interactionCreate";
 
 
 function getAutocomplete(typed: string, options: string[]): object[] {
-    options = options.filter(option => option.length <= 100) // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
-    if (!typed) return options.slice(0, 25).sort().map(option => ({name: option, value: option}))
-    const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed)
-    return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}))
+    options = options.filter(option => option.length <= 100); // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
+    if (!typed) return options.slice(0, 25).sort().map(option => ({name: option, value: option}));
+    const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed);
+    return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}));
 }
 
 function generateStatsChannelAutocomplete(typed) {
-    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"]
-    let autocompletions = []
-    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
-    if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
-    else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
-    return getAutocomplete(typed, autocompletions)
+    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"];
+    const autocompletions = [];
+    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+    if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+    else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+    return getAutocomplete(typed, autocompletions);
 }
 function generateWelcomeMessageAutocomplete(typed) {
-    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"]
-    let autocompletions = []
-    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
-    if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
-    else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
-    return getAutocomplete(typed, autocompletions)
+    const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"];
+    const autocompletions = [];
+    const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+    if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+    else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+    return getAutocomplete(typed, autocompletions);
 }
 
 async function interactionCreate(interaction) {
     if (interaction.componentType === "BUTTON") {
         switch (interaction.customId) {
-            case "rolemenu": { return await roleMenu(interaction) }
-            case "verifybutton": { return verify(interaction) }
-            case "createticket": { return create(interaction) }
-            case "closeticket": { return close(interaction) }
-            case "createtranscript": { return createTranscript(interaction) }
+        case "rolemenu": { return await roleMenu(interaction); }
+        case "verifybutton": { return verify(interaction); }
+        case "createticket": { return create(interaction); }
+        case "closeticket": { return close(interaction); }
+        case "createtranscript": { return createTranscript(interaction); }
         }
-    } else if (interaction.componentType === "MESSAGE_COMPONENT") {
     } else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
         switch (`${interaction.commandName} ${interaction.options.getSubcommandGroup(false)} ${interaction.options.getSubcommand(false)}`) {
-            case `tag null null`: { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))) }
-            case `settings null stats`: { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))) }
-            case `settings null welcome`: { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))) }
+        case "tag null null": { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))); }
+        case "settings null stats": { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))); }
+        case "settings null welcome": { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))); }
         }
     }
 }
 
 export async function callback(client, interaction) {
-    await interactionCreate(interaction)
+    await interactionCreate(interaction);
 }
\ No newline at end of file
