editing messageEdit logs to be clearer.
Co-authored-by: PineappleFan <pineapplefanyt@gmail.com>
Co-authored-by: Skyler <skyler3665@gmail.com>
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);
}
}
},