editing messageEdit logs to be clearer.

Co-authored-by: PineappleFan <pineapplefanyt@gmail.com>
Co-authored-by: Skyler <skyler3665@gmail.com>
diff --git a/src/actions/logs/showDetails.ts b/src/actions/logs/showDetails.ts
new file mode 100644
index 0000000..9c72635
--- /dev/null
+++ b/src/actions/logs/showDetails.ts
@@ -0,0 +1,5 @@
+import { type ButtonInteraction } from "discord.js";
+
+export async function callback(interaction: ButtonInteraction) {
+    console.log(interaction);
+}
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 9d3dceb..6a79447 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -24,6 +24,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 { callback as logDetailsCallback } from "../actions/logs/showDetails.js";
 import client from "../utils/client.js";
 
 export const event = "interactionCreate";
@@ -61,6 +62,9 @@
             case "createtranscript": {
                 return await createTranscript(interaction);
             }
+            case "log:showDetails": {
+                return await logDetailsCallback(interaction);
+            }
         }
         // Mod actions
         if (interaction.customId.startsWith("mod:")) {
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index bca652e..6719cc3 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -1,5 +1,5 @@
 import type { NucleusClient } from "../utils/client.js";
-import type { Message, MessageReference } from "discord.js";
+import { AttachmentBuilder, Message, MessageReference } from "discord.js";
 import type Discord from "discord.js";
 import * as diff from "diff";
 
@@ -63,68 +63,88 @@
         return;
     }
     const differences = diff.diffChars(oldContent, newContent);
-    console.log(differences);
-    let contentEdit = "";
-    if (differences.map((d) => (d.added || d.removed ? 1 : 0)).filter((f) => f === 1).length > 0) {
-        const green = "\x1B[36m";
-        const red = "\x1B[41m";
-        const skipped = "\x1B[40;33m";
-        const reset = "\x1B[0m";
-        const bold = "\x1B[1m";
-        const cutoff = 20;
-        differences.forEach((part) => {
-            if (!part.added && !part.removed && part.value.length > cutoff) {
-                contentEdit +=
-                    reset +
-                    part.value.slice(0, cutoff / 2) +
-                    skipped +
-                    `(${part.value.length - cutoff} more)` +
-                    reset +
-                    part.value.slice(-(cutoff / 2));
-            } else {
-                if (part.added || part.removed) {
-                    part.value = part.value.replaceAll(" ", "▁");
-                }
-                contentEdit += (part.added ? green : part.removed ? red : "") + part.value + reset;
-            }
-        });
-        contentEdit = contentEdit.slice(0, 2000);
-        contentEdit += `\n\n${bold}Key:${reset} ${green}Added${reset} | ${red}Removed${reset} | ${skipped}Skipped${reset}`;
-        const data = {
-            meta: {
-                type: "messageUpdate",
-                displayName: "Message Edited",
-                calculateType: "messageUpdate",
-                color: NucleusColors.yellow,
-                emoji: "MESSAGE.EDIT",
-                timestamp: newMessage.editedTimestamp
-            },
-            separate: {
-                start: `\`\`\`ansi\n${contentEdit}\`\`\``,
-                end: `[[Jump to message]](${newMessage.url})`
-            },
-            list: {
-                messageId: entry(newMessage.id, `\`${newMessage.id}\``),
-                sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
-                sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel as Discord.GuildBasedChannel)),
-                sent: entry(newMessage.createdTimestamp, renderDelta(newMessage.createdTimestamp)),
-                edited: entry(newMessage.editedTimestamp, renderDelta(newMessage.editedTimestamp)),
-                mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
-                attachments: entry(
-                    renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
-                    renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
-                ),
-                repliedTo: entry(
-                    replyTo ? replyTo.messageId! : null,
-                    replyTo
-                        ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${replyTo.messageId})`
-                        : "None"
-                )
-            },
-            hidden: {
-                guild: newMessage.guild.id
-            }
-        };
-        await log(data);
-    }
+    const green = "\x1B[36m";
+    const red = "\x1B[41m";
+    const skipped = "\x1B[40;33m";
+    const reset = "\x1B[0m";
+    const bold = "\x1B[1m";
+    // console.log(differences);
+    // let contentAdd = "";
+    // let contentRemove = "";
+    // if (differences.map((d) => (d.added || d.removed ? 1 : 0)).filter((f) => f === 1).length > 0) {
+    //     const cutoff = 20;
+    //     differences.forEach((part) => {
+    //         if (!part.added && !part.removed && part.value.length > cutoff) {
+    //             contentAdd +=
+    //                 reset +
+    //                 part.value.slice(0, cutoff / 2) +
+    //                 skipped +
+    //                 `(${part.value.length - cutoff} more)` +
+    //                 reset +
+    //                 part.value.slice(-(cutoff / 2));
+    //             contentRemove +=
+    //                 reset +
+    //                 part.value.slice(0, cutoff / 2) +
+    //                 skipped +
+    //                 `(${part.value.length - cutoff} more)` +
+    //                 reset +
+    //                 part.value.slice(-(cutoff / 2));
+    //         } else {
+    //             if (part.added || part.removed) {
+    //                 part.value = part.value.replaceAll(" ", "▁");
+    //             }
+    //             if (part.added) {
+    //                 contentAdd += green + part.value + reset;
+    //             } else if (part.removed) {
+    //                 contentRemove += red + part.value + reset;
+    //             } else {
+    //                 contentAdd += part.value;
+    //                 contentRemove += part.value;
+    //             }
+    //         }
+    //     });
+    const key = `\n\n${bold}Key:${reset} ${green}Added${reset} | ${red}Removed${reset} | ${skipped}Skipped${reset}`;
+    const data = {
+        meta: {
+            type: "messageUpdate",
+            displayName: "Message Edited",
+            calculateType: "messageUpdate",
+            color: NucleusColors.yellow,
+            emoji: "MESSAGE.EDIT",
+            timestamp: newMessage.editedTimestamp,
+            files: [
+                new AttachmentBuilder(Buffer.from(JSON.stringify(differences)), {
+                    name: "diff.json",
+                    description: "A JSON file containing the differences between the two messages."
+                })
+            ],
+            showDetails: true
+        },
+        separate: {
+            start: `To read the full log press the button below.\n\`\`\`ansi\n${key}\`\`\``,
+            end: `[[Jump to message]](${newMessage.url})`
+        },
+        list: {
+            messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+            sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+            sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel as Discord.GuildBasedChannel)),
+            sent: entry(newMessage.createdTimestamp, renderDelta(newMessage.createdTimestamp)),
+            edited: entry(newMessage.editedTimestamp, renderDelta(newMessage.editedTimestamp)),
+            mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+            attachments: entry(
+                renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+                renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+            ),
+            repliedTo: entry(
+                replyTo ? replyTo.messageId! : null,
+                replyTo
+                    ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${replyTo.messageId})`
+                    : "None"
+            )
+        },
+        hidden: {
+            guild: newMessage.guild.id
+        }
+    };
+    await log(data);
 }
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 3b6048a..bae82dd 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -1,10 +1,11 @@
 import * as Discord from "discord.js";
-import getEmojiByName from "./getEmojiByName.js";
 import { toHexArray } from "./calculate.js";
 import { promisify } from "util";
 import generateKeyValueList from "./generateKeyValueList.js";
 import client from "./client.js";
 import { DiscordAPIError } from "discord.js";
+import { Stream } from "node:stream";
+import EmojiEmbed from "./generateEmojiEmbed.js";
 
 const wait = promisify(setTimeout);
 
@@ -16,9 +17,17 @@
         color: number;
         emoji: string;
         timestamp: number;
+        files?: (
+            | Discord.BufferResolvable
+            | Stream
+            | Discord.JSONEncodable<Discord.APIAttachment>
+            | Discord.Attachment
+            | Discord.AttachmentBuilder
+            | Discord.AttachmentPayload
+        )[];
+        showDetails?: boolean;
     };
-    // eslint-disable-next-line @typescript-eslint/no-explicit-any
-    list: any;
+    list: Record<string, unknown>;
     hidden: {
         guild: string;
     };
@@ -116,16 +125,31 @@
             });
             if (channel) {
                 log.separate = log.separate ?? {};
-                const embed = new Discord.EmbedBuilder()
-                    .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
-                    .setDescription(
-                        (log.separate.start ? log.separate.start + "\n" : "") +
-                            generateKeyValueList(description) +
-                            (log.separate.end ? "\n" + log.separate.end : "")
-                    )
-                    .setTimestamp(log.meta.timestamp)
-                    .setColor(log.meta.color);
-                await channel.send({ embeds: [embed] });
+                const messageOptions: Parameters<Discord.TextChannel["send"]>[0] = {};
+                const components: Discord.ActionRowBuilder<Discord.ButtonBuilder> = new Discord.ActionRowBuilder();
+                messageOptions.embeds = [
+                    new EmojiEmbed()
+                        .setEmoji(log.meta.emoji)
+                        .setTitle(log.meta.displayName)
+                        .setDescription(
+                            (log.separate.start ? log.separate.start + "\n" : "") +
+                                generateKeyValueList(description) +
+                                (log.separate.end ? "\n" + log.separate.end : "")
+                        )
+                        .setTimestamp(log.meta.timestamp)
+                        .setColor(log.meta.color)
+                ];
+                if (log.meta.files) messageOptions.files = log.meta.files;
+                if (log.meta.showDetails) {
+                    components.addComponents(
+                        new Discord.ButtonBuilder()
+                            .setCustomId("log:showDetails")
+                            .setLabel("Show Details")
+                            .setStyle(Discord.ButtonStyle.Primary)
+                    );
+                    messageOptions.components = [components];
+                }
+                await channel.send(messageOptions);
             }
         }
     },