diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index ddc143b..1796146 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -3,71 +3,15 @@
 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 type { AutocompleteInteraction, Interaction, MessageComponentInteraction } from "discord.js";
+
+import type { Interaction, MessageComponentInteraction } from "discord.js";
 import type { NucleusClient } from "../utils/client.js";
 
 export const event = "interactionCreate";
 
-function getAutocomplete(typed: string, options: string[]): { name: string; value: string }[] {
-    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: string) {
-    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: string) {
-    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: Interaction) {
-    if (
-        interaction.type === "MESSAGE_COMPONENT" &&
-        (interaction as MessageComponentInteraction).componentType === "BUTTON"
-    ) {
+    if (interaction.isButton()) {
         const int = interaction as MessageComponentInteraction;
         switch (int.customId) {
             case "rolemenu": {
@@ -86,19 +30,19 @@
                 return createTranscript(int);
             }
         }
-    } else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
-        const int = interaction as AutocompleteInteraction;
-        switch (`${int.commandName} ${int.options.getSubcommandGroup(false)} ${int.options.getSubcommand(false)}`) {
-            case "tag null null": {
-                return int.respond(getAutocomplete(int.options.getString("tag") ?? "", await tagAutocomplete(int)));
-            }
-            case "settings null stats": {
-                return int.respond(generateStatsChannelAutocomplete(int.options.getString("name") ?? ""));
-            }
-            case "settings null welcome": {
-                return int.respond(generateWelcomeMessageAutocomplete(int.options.getString("message") ?? ""));
-            }
-        }
+    // } else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
+    //     const int = interaction as AutocompleteInteraction;
+    //     switch (`${int.commandName} ${int.options.getSubcommandGroup(false)} ${int.options.getSubcommand(false)}`) {
+    //         case "tag null null": {
+    //             return int.respond(getAutocomplete(int.options.getString("tag") ?? "", await tagAutocomplete(int)));
+    //         }
+    //         case "settings null stats": {
+    //             return int.respond(generateStatsChannelAutocomplete(int.options.getString("name") ?? ""));
+    //         }
+    //         case "settings null welcome": {
+    //             return int.respond(generateWelcomeMessageAutocomplete(int.options.getString("message") ?? ""));
+    //         }
+    //     }
     }
 }
 
