More commands fixed and purge to here
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index e9aa41a..6087890 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -1,4 +1,4 @@
-import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel, ButtonStyle } from "discord.js";
+import Discord, { CommandInteraction, GuildChannel, GuildMember, TextChannel, ButtonStyle, ButtonBuilder } from "discord.js";
 import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -26,7 +26,8 @@
         );
 
 const callback = async (interaction: CommandInteraction): Promise<unknown> => {
-    const user = (interaction.options.getMember("user") as GuildMember);
+    if (!interaction.guild) return;
+    const user = (interaction.options.getMember("user") as GuildMember | null);
     const channel = interaction.channel as GuildChannel;
     if (
         !["GUILD_TEXT", "GUILD_NEWS", "GUILD_NEWS_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_PRIVATE_THREAD"].includes(
@@ -46,7 +47,7 @@
         });
     }
     // TODO:[Modals] Replace this with a modal
-    if (!interaction.options.getInteger("amount")) {
+    if (!interaction.options.get("amount")) {
         await interaction.reply({
             embeds: [
                 new EmojiEmbed()
@@ -74,17 +75,17 @@
                         .setStatus("Danger")
                 ],
                 components: [
-                    new Discord.ActionRowBuilder().addComponents([
+                    new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
                         new Discord.ButtonBuilder().setCustomId("1").setLabel("1").setStyle(ButtonStyle.Secondary),
                         new Discord.ButtonBuilder().setCustomId("3").setLabel("3").setStyle(ButtonStyle.Secondary),
                         new Discord.ButtonBuilder().setCustomId("5").setLabel("5").setStyle(ButtonStyle.Secondary)
                     ]),
-                    new Discord.ActionRowBuilder().addComponents([
+                    new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
                         new Discord.ButtonBuilder().setCustomId("10").setLabel("10").setStyle(ButtonStyle.Secondary),
                         new Discord.ButtonBuilder().setCustomId("25").setLabel("25").setStyle(ButtonStyle.Secondary),
                         new Discord.ButtonBuilder().setCustomId("50").setLabel("50").setStyle(ButtonStyle.Secondary)
                     ]),
-                    new Discord.ActionRowBuilder().addComponents([
+                    new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
                         new Discord.ButtonBuilder()
                             .setCustomId("done")
                             .setLabel("Done")
@@ -110,16 +111,14 @@
             }
             const amount = parseInt((await component).customId);
 
-            let messages;
+            let messages: Discord.Message[] = [];
             await (interaction.channel as TextChannel).messages.fetch({ limit: amount }).then(async (ms) => {
                 if (user) {
                     ms = ms.filter((m) => m.author.id === user.id);
                 }
-                messages = await (channel as TextChannel).bulkDelete(ms, true);
+                messages = (await (channel as TextChannel).bulkDelete(ms, true)).map(m => m as Discord.Message);
             });
-            if (messages) {
-                deleted = deleted.concat(messages.map((m) => m));
-            }
+            deleted = deleted.concat(messages);
         }
         if (deleted.length === 0)
             return await interaction.editReply({
@@ -136,11 +135,12 @@
             await client.database.history.create(
                 "purge",
                 interaction.guild.id,
-                user,
-                interaction.options.getString("reason"),
+                user.user,
+                interaction.user,
+                (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
                 null,
                 null,
-                deleted.length
+                deleted.length.toString()
             );
         }
         const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
@@ -156,8 +156,8 @@
             list: {
                 memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
                 purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
-                messagesCleared: entry(deleted.length, deleted.length)
+                channel: entry(interaction.channel!.id, renderChannel(interaction.channel! as GuildChannel)),
+                messagesCleared: entry(deleted.length.toString(), deleted.length.toString())
             },
             hidden: {
                 guild: interaction.guild.id
@@ -189,7 +189,7 @@
                     .setStatus("Success")
             ],
             components: [
-                new Discord.ActionRowBuilder().addComponents([
+                new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
                     new Discord.ButtonBuilder()
                         .setCustomId("download")
                         .setLabel("Download transcript")
@@ -207,7 +207,7 @@
         } catch {
             return;
         }
-        if (component && component.customId === "download") {
+        if (component.customId === "download") {
             interaction.editReply({
                 embeds: [
                     new EmojiEmbed()
@@ -239,12 +239,8 @@
             .setDescription(
                 keyValueList({
                     channel: `<#${channel.id}>`,
-                    amount: interaction.options.getInteger("amount").toString(),
-                    reason: `\n> ${
-                        interaction.options.getString("reason")
-                            ? interaction.options.getString("reason")
-                            : "*No reason provided*"
-                    }`
+                    amount: (interaction.options.get("amount")?.value as number).toString(),
+                    reason: `\n> ${interaction.options.get("reason")?.value ? interaction.options.get("reason")?.value : "*No reason provided*"}`
                 })
             )
             .setColor("Danger")
@@ -255,7 +251,7 @@
             try {
                 if (!user) {
                     const toDelete = await (interaction.channel as TextChannel).messages.fetch({
-                        limit: interaction.options.getInteger("amount")
+                        limit: interaction.options.get("amount")?.value as number
                     });
                     messages = await (channel as TextChannel).bulkDelete(toDelete, true);
                 } else {
@@ -265,7 +261,7 @@
                                 limit: 100
                             })
                         ).filter((m) => m.author.id === user.id)
-                    ).first(interaction.options.getInteger("amount"));
+                    ).first(interaction.options.get("amount")?.value as number);
                     messages = await (channel as TextChannel).bulkDelete(toDelete, true);
                 }
             } catch (e) {
@@ -280,15 +276,29 @@
                     components: []
                 });
             }
+            if (!messages) {
+                await interaction.editReply({
+                    embeds: [
+                        new EmojiEmbed()
+                            .setEmoji("CHANNEL.PURGE.RED")
+                            .setTitle("Purge")
+                            .setDescription("No messages could be deleted")
+                            .setStatus("Danger")
+                    ],
+                    components: []
+                });
+                return;
+            }
             if (user) {
                 await client.database.history.create(
                     "purge",
                     interaction.guild.id,
-                    user,
-                    interaction.options.getString("reason"),
+                    user.user,
+                    interaction.user,
+                    (interaction.options.get("reason")?.value as (string | null)) ?? "*No reason provided*",
                     null,
                     null,
-                    messages.size
+                    messages.size.toString()
                 );
             }
             const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
@@ -304,8 +314,8 @@
                 list: {
                     memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
                     purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
-                    channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
-                    messagesCleared: entry(messages.size, messages.size)
+                    channel: entry(interaction.channel!.id, renderChannel(interaction.channel! as GuildChannel)),
+                    messagesCleared: entry(messages.size.toString(), messages.size.toString())
                 },
                 hidden: {
                     guild: interaction.guild.id
@@ -314,14 +324,26 @@
             log(data);
             let out = "";
             messages.reverse().forEach((message) => {
-                out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(
-                    message.createdTimestamp
-                ).toISOString()}]\n`;
-                const lines = message.content.split("\n");
-                lines.forEach((line) => {
-                    out += `> ${line}\n`;
-                });
-                out += "\n\n";
+                if (!message) {
+                    out += "Unknown message\n\n"
+                } else {
+                    const author = message.author ?? { username: "Unknown", discriminator: "0000", id: "Unknown" };
+                    out += `${author.username}#${author.discriminator} (${author.id}) [${new Date(
+                        message.createdTimestamp
+                    ).toISOString()}]\n`;
+                    if (message.content) {
+                        const lines = message.content.split("\n");
+                        lines.forEach((line) => {
+                            out += `> ${line}\n`;
+                        });
+                    }
+                    if (message.attachments.size > 0) {
+                        message.attachments.forEach((attachment) => {
+                            out += `Attachment > ${attachment.url}\n`;
+                        });
+                    }
+                    out += "\n\n";
+                }
             });
             const attachmentObject = {
                 attachment: Buffer.from(out),
@@ -337,7 +359,7 @@
                         .setStatus("Success")
                 ],
                 components: [
-                    new Discord.ActionRowBuilder().addComponents([
+                    new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
                         new Discord.ButtonBuilder()
                             .setCustomId("download")
                             .setLabel("Download transcript")
@@ -355,7 +377,7 @@
             } catch {
                 return;
             }
-            if (component && component.customId === "download") {
+            if (component.customId === "download") {
                 interaction.editReply({
                     embeds: [
                         new EmojiEmbed()
@@ -395,14 +417,15 @@
 };
 
 const check = (interaction: CommandInteraction) => {
+    if (!interaction.guild) return false;
     const member = interaction.member as GuildMember;
-    const me = interaction.guild.me!;
+    const me = interaction.guild.members.me!;
     // Check if nucleus has the manage_messages permission
-    if (!me.permissions.has("MANAGE_MESSAGES")) throw new Error("I do not have the *Manage Messages* permission");
+    if (!me.permissions.has("ManageMessages")) throw new Error("I do not have the *Manage Messages* permission");
     // Allow the owner to purge
     if (member.id === interaction.guild.ownerId) return true;
     // Check if the user has manage_messages permission
-    if (!member.permissions.has("MANAGE_MESSAGES")) throw new Error("You do not have the *Manage Messages* permission");
+    if (!member.permissions.has("ManageMessages")) throw new Error("You do not have the *Manage Messages* permission");
     // Allow purge
     return true;
 };