diff --git a/src/actions/tickets/delete.ts b/src/actions/tickets/delete.ts
index a1f63d2..43e9dd2 100644
--- a/src/actions/tickets/delete.ts
+++ b/src/actions/tickets/delete.ts
@@ -9,7 +9,7 @@
     if (!interaction.guild) return;
     const config = await client.database.guilds.read(interaction.guild.id);
     const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
-
+    //FIXME
     const ticketChannel = config.tickets.category;
     if (!("parent" in interaction.channel!)) {
         return await interaction.reply({
diff --git a/src/commands/nucleus/premium.ts b/src/commands/nucleus/premium.ts
index 026984d..ed4f225 100644
--- a/src/commands/nucleus/premium.ts
+++ b/src/commands/nucleus/premium.ts
@@ -1,14 +1,73 @@
-import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction } from "discord.js";
+import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CommandInteraction, GuildMember, StringSelectMenuBuilder } from "discord.js";
 import type { SlashCommandSubcommandBuilder } from "discord.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
 import client from "../../utils/client.js";
 import { LoadingEmbed } from "../../utils/defaults.js";
 import getEmojiByName from "../../utils/getEmojiByName.js";
+import type { PremiumSchema } from "../../utils/database.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder.setName("premium").setDescription("Information about Nucleus Premium");
 //TODO: Allow User to remove Premium
+
+const dmcallback = async (interaction: CommandInteraction, member: GuildMember, dbUser: PremiumSchema | null, firstDescription: string): Promise<void> => {
+
+    if(!dbUser) {
+        await interaction.editReply({embeds: [
+            new EmojiEmbed()
+                .setTitle("Premium")
+                .setDescription(`*You do not have premium! You can't activate premium on any servers.*` + firstDescription)
+                .setEmoji("NUCLEUS.LOGO")
+                .setStatus("Danger")
+        ]});
+        return;
+    }
+    const premiumGuilds = dbUser.appliesTo.map((guildID) => {
+        const guild = client.guilds.cache.get(guildID);
+        if(!guild) return undefined;
+        return guild.name;
+    });
+
+    const options = premiumGuilds.filter((guild) => guild !== undefined) as string[];
+
+    const removeRow = new ActionRowBuilder<StringSelectMenuBuilder>()
+        .addComponents(
+            new StringSelectMenuBuilder()
+                .setCustomId("currentPremium")
+                .setPlaceholder("Select a server to remove premium from")
+                .setDisabled(premiumGuilds.length === 0)
+                .addOptions(options.map((guild) => {
+                    return {label: guild, value: guild}
+                }))
+        );
+    const removeButton = new ActionRowBuilder<ButtonBuilder>()
+        .addComponents(
+            new ButtonBuilder()
+                .setCustomId("removePremium")
+                .setLabel("Remove Premium")
+                .setStyle(ButtonStyle.Danger)
+                .setDisabled(premiumGuilds.length === 0)
+        );
+
+    await interaction.editReply(
+    {
+        embeds: [
+            new EmojiEmbed()
+                .setTitle("Premium")
+                .setDescription(`*You have premium on the following servers:*` + firstDescription)
+                .setEmoji("NUCLEUS.LOGO")
+                .setStatus("Success")
+        ],
+        components: [removeRow, removeButton]
+    });
+
+    //TODO Finish this.
+
+
+}
+
 const callback = async (interaction: CommandInteraction): Promise<void> => {
+
     await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
     const member = await (await interaction.client.guilds.fetch("684492926528651336")).members.fetch(interaction.user.id).catch(() => {
         interaction.editReply({ embeds: [
@@ -44,12 +103,14 @@
         premium = `**You can't give servers premium anymore because your subscription ended or was cancelled.** To get premium again please subscribe in the Clicks server`
         count = 0;
     }
+    if(!interaction.guild) return await dmcallback(interaction, member, dbMember, firstDescription);
     const hasPremium = await client.database.premium.hasPremium(interaction.guild!.id);
     let premiumGuild = ""
-    if (hasPremium) { //FIXME: Check how user applied premium
-        premiumGuild = `**This server has premium! It was ${hasPremium[2] === 3 ? `automatically applied by <@${hasPremium[1]}>` : `given by <@${hasPremium[1]}>`}**\n\n`
+    if (hasPremium) {
+        premiumGuild = `**This server has premium! It was ${hasPremium[2] === 3 && hasPremium[3] ? `automatically applied by <@${hasPremium[1]}>` : `given by <@${hasPremium[1]}>`}**\n\n`
     }
 
+
     const components: ActionRowBuilder<ButtonBuilder>[] = []
     if (level === 0 || dbMember?.expiresAt) {
         components.push(
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index 88a8e6e..acd641b 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -181,9 +181,11 @@
 
         if (message.stickers.size > 0) msg.stickerURLs = message.stickers.map(sticker => sticker.url);
         if (message.reference) msg.referencedMessage = [message.reference.guildId ?? "", message.reference.channelId, message.reference.messageId ?? ""];
-
+        newOut.messages.push(msg);
     });
 
+    console.log(newOut);
+
     const topic = interaction.channel.topic;
     let member: GuildMember | null = null;
     if (topic !== null) {
diff --git a/src/utils/database.ts b/src/utils/database.ts
index e7336d0..48d0077 100644
--- a/src/utils/database.ts
+++ b/src/utils/database.ts
@@ -246,12 +246,12 @@
         await this.premium.insertOne({ user: user, appliesTo: [], level: level });
     }
 
-    async hasPremium(guild: string): Promise<[boolean, string, number] | null> {
+    async hasPremium(guild: string): Promise<[boolean, string, number, boolean] | null> {
         const entries = await this.premium.find({}).toArray();
         const members = await (await client.guilds.fetch(guild)).members.fetch()
         for(const {user} of entries) {
             const member = members.get(user);
-            if(member) {
+            if(member) { //TODO: Notify user if they've given premium to a server that has since gotten premium via a mod.
                 const modPerms = //TODO: Create list in config for perms
                             member.permissions.has("Administrator") ||
                             member.permissions.has("ManageChannels") ||
@@ -265,7 +265,7 @@
                             member.permissions.has("ManageMessages") ||
                             member.permissions.has("ManageThreads")
                 const entry = entries.find(e => e.user === member.id);
-                if(entry && (entry.level === 3) && modPerms) return [true, member.id, entry.level];
+                if(entry && (entry.level === 3) && modPerms) return [true, member.id, entry.level, true];
             }
         }
         const entry = await this.premium.findOne({
@@ -275,7 +275,7 @@
                 }
             }
         });
-        return entry ? [true, entry.user, entry.level] : null;
+        return entry ? [true, entry.user, entry.level, false] : null;
     }
 
     async fetchUser(user: string): Promise<PremiumSchema | null> {
