diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 3b0cd62..e27ee69 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -4,8 +4,7 @@
 import close from "../actions/tickets/delete.js";
 import createTranscript from "../premium/createTranscript.js";
 
-import type { ButtonInteraction, Interaction } from "discord.js";
-import type Discord from "discord.js";
+import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, Interaction, InteractionEditReplyOptions, ModalBuilder, ModalSubmitInteraction, TextInputBuilder, TextInputStyle } from "discord.js";
 import type { NucleusClient } from "../utils/client.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 
@@ -14,6 +13,7 @@
 import { callback as muteCallback, check as muteCheck } from "../commands/mod/mute.js";
 import { callback as nicknameCallback, check as nicknameCheck } from "../commands/mod/nick.js";
 import { callback as warnCallback, check as warnCheck } from "../commands/mod/warn.js";
+import client from "../utils/client.js";
 
 export const event = "interactionCreate";
 
@@ -27,6 +27,10 @@
 
 async function interactionCreate(interaction: Interaction) {
     if (interaction.isButton()) {
+        if (interaction.customId.endsWith(":Suggestion")) {
+            const value = interaction.customId.startsWith("accept") || interaction.customId.startsWith("implement") ? true : false
+            return await modifySuggestion(interaction, value);
+        }
         switch (interaction.customId) {
             case "rolemenu": {
                 return await roleMenu(interaction);
@@ -43,12 +47,6 @@
             case "createtranscript": {
                 return await createTranscript(interaction);
             }
-            case "suggestionAccept": {
-                return await modifySuggestion(interaction, true);
-            }
-            case "suggestionDeny": {
-                return await modifySuggestion(interaction, false);
-            }
         }
         // Mod actions
         if (interaction.customId.startsWith("mod:")) {
@@ -57,27 +55,27 @@
             const member = await interaction.guild?.members.fetch(memberId!);
             switch (action) {
                 case "kick": {
-                    const check = await kickCheck(interaction, false, member);
+                    const check = kickCheck(interaction, false, member);
                     if (check !== true) return await errorMessage(interaction, check!);
                     return await kickCallback(interaction, member);
                 }
                 case "ban": {
-                    const check = await banCheck(interaction, false, member);
+                    const check = banCheck(interaction, false, member);
                     if (check !== true) return await errorMessage(interaction, check!);
                     return await banCallback(interaction, member);
                 }
                 case "mute": {
-                    const check = await muteCheck(interaction, false, member);
+                    const check = muteCheck(interaction, false, member);
                     if (check !== true) return await errorMessage(interaction, check!);
                     return await muteCallback(interaction, member);
                 }
                 case "nickname": {
-                    const check = await nicknameCheck(interaction, false, member);
+                    const check = nicknameCheck(interaction, false, member);
                     if (check !== true) return await errorMessage(interaction, check || "Something went wrong");
                     return await nicknameCallback(interaction, member);
                 }
                 case "warn": {
-                    const check = await warnCheck(interaction, false, member);
+                    const check = warnCheck(interaction, false, member);
                     if (check !== true) return await errorMessage(interaction, check!);
                     return await warnCallback(interaction, member);
                 }
@@ -86,24 +84,120 @@
     }
 }
 
-async function modifySuggestion(interaction: Discord.MessageComponentInteraction, accept: boolean) {
-    const message = await interaction.message;
+const getReason = async (buttonInteraction: ButtonInteraction, prompt: string) => {
+    const modal = new ModalBuilder()
+        .addComponents(
+            new ActionRowBuilder<TextInputBuilder>().addComponents(
+                new TextInputBuilder()
+                    .setStyle(TextInputStyle.Paragraph)
+                    .setLabel(prompt)
+                    .setCustomId("typed")
+            )
+        )
+        .setTitle("Reason")
+        .setCustomId("modal");
+    await buttonInteraction.showModal(modal);
+    let out: ModalSubmitInteraction;
+    try {
+        out = await buttonInteraction.awaitModalSubmit({
+            filter: (i) => i.customId === "modal" && i.user.id === buttonInteraction.user.id,
+            time: 300000
+        });
+    } catch {
+        return null;
+    }
+    await out.deferUpdate();
+    return out.fields.getTextInputValue("typed");
+}
+
+async function modifySuggestion(interaction: ButtonInteraction, accept: boolean) {
+    const message = interaction.message;
     await message.fetch();
     if (message.embeds.length === 0) return;
-    const embed = message.embeds[0];
+    const embed = message.embeds[0]!;
+    const issueNum = embed.footer!.text
+    if(!issueNum) return;
+    const issue = {
+        owner: "ClicksMinutePer",
+        repo: "Nucleus",
+        issue_number: parseInt(issueNum)
+    }
+    let name = "Unknown";
+    const components: InteractionEditReplyOptions["components"] = [];
+    switch(interaction.customId) {
+        case "accept:Suggestion": {
+            name = "Accepted";
+            await interaction.deferUpdate();
+            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion accepted by " + interaction.user.tag});
+            components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
+                new ButtonBuilder().setCustomId("close:Suggestion").setLabel("Close").setStyle(ButtonStyle.Secondary),
+                new ButtonBuilder().setCustomId("implemented:Suggestion").setLabel("Implemented").setStyle(ButtonStyle.Secondary)
+            ))
+            break;
+        }
+        case "deny:Suggestion": {
+            name = "Denied";
+            const reason = await getReason(interaction, "Reason for denial");
+            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion denied by " + interaction.user.tag + " for reason:\n>" + reason});
+            await client.GitHub.rest.issues.update({...issue, state: "closed", state_reason: "not_planned"});
+            // await client.GitHub.rest.issues.lock({...issue, lock_reason: "resolved"})
+            components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
+                new ButtonBuilder().setCustomId("lock:Suggestion").setLabel("Lock").setStyle(ButtonStyle.Danger)
+            ))
+            break;
+        }
+        case "close:Suggestion": {
+            name = "Closed";
+            const reason = await getReason(interaction, "Reason for closing");
+            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion closed by " + interaction.user.tag + " for reason:\n>" + reason});
+            await client.GitHub.rest.issues.update({...issue, state: "closed"});
+            // await client.GitHub.rest.issues.lock({...issue})
+            components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
+                new ButtonBuilder().setCustomId("lock:Suggestion").setLabel("Lock").setStyle(ButtonStyle.Danger)
+            ))
+            break;
+        }
+        case "implement:Suggestion": {
+            name = "Implemented";
+            await interaction.deferUpdate();
+            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion implemented"});
+            await client.GitHub.rest.issues.update({...issue, state: "closed", state_reason: "completed"});
+            await client.GitHub.rest.issues.lock({...issue, lock_reason: "resolved"})
+            break;
+        }
+        case "lock:Suggestion": {
+            name = "Locked";
+            await interaction.deferUpdate();
+            await client.GitHub.rest.issues.lock({...issue});
+            break;
+        }
+        case "spam:Suggestion": {
+            name = "Marked as Spam";
+            await interaction.deferUpdate();
+            await client.GitHub.rest.issues.update({...issue, state: "closed", state_reason: "not_planned"});
+            await client.GitHub.rest.issues.lock({...issue, lock_reason: "spam"})
+            break;
+        }
+    }
+
     const newcolor = accept ? "Success" : "Danger";
-    const footer = {
-        text: `Suggestion ${accept ? "accepted" : "denied"} by ${interaction.user.tag}`,
-        iconURL: interaction.user.displayAvatarURL()
-    };
+    const newEmoji = accept ? "ICONS.ADD" : "ICONS.OPP.ADD";
 
     const newEmbed = new EmojiEmbed()
-        .setTitle(embed!.title!)
+        .setEmoji(newEmoji)
+        .setTitle(embed!.title!.replace(/.+> /, ""))
         .setDescription(embed!.description!)
-        .setFooter(footer)
-        .setStatus(newcolor);
+        .setFields({
+            name: name + " by",
+            value: interaction.user.tag,
+        })
+        .setStatus(newcolor)
+        .setFooter(embed!.footer);
 
-    await interaction.update({ embeds: [newEmbed], components: [] });
+    await interaction.editReply({
+        embeds: [newEmbed],
+        components: components
+    });
 }
 
 export async function callback(_client: NucleusClient, interaction: Interaction) {
