diff --git a/src/discord/GuildWrapper.js b/src/discord/GuildWrapper.js index deab74fa0..360ca5014 100644 --- a/src/discord/GuildWrapper.js +++ b/src/discord/GuildWrapper.js @@ -185,7 +185,7 @@ export default class GuildWrapper { /** * send this message to the guild's log channel - * @param {import('discord.js').MessagePayload|import('discord.js').MessageOptions} options + * @param {import('discord.js').MessagePayload|import('discord.js').MessageCreateOptions} options * @return {Promise} Discord message (if it was sent) */ async log(options) { @@ -195,7 +195,7 @@ export default class GuildWrapper { /** * send this message to the guild's message log channel - * @param {import('discord.js').MessagePayload|import('discord.js').MessageOptions} options + * @param {import('discord.js').MessagePayload|import('discord.js').MessageCreateOptions} options * @return {Promise} Discord message (if it was sent) */ async logMessage(options) { @@ -205,7 +205,7 @@ export default class GuildWrapper { /** * send this message to the guild's join log channel - * @param {import('discord.js').MessagePayload|import('discord.js').MessageOptions} options + * @param {import('discord.js').MessagePayload|import('discord.js').MessageCreateOptions} options * @return {Promise} Discord message (if it was sent) */ async logJoin(options) { diff --git a/src/embeds/MessageDeleteEmbed.js b/src/embeds/MessageDeleteEmbed.js index 23572815e..d8157fe52 100644 --- a/src/embeds/MessageDeleteEmbed.js +++ b/src/embeds/MessageDeleteEmbed.js @@ -18,7 +18,11 @@ export default class MessageDeleteEmbed extends EmbedWrapper { this.setAuthor({ name: `Message by ${escapeMarkdown(message.author.tag)} was deleted in #${message.channel.name}`, iconURL: message.author.avatarURL() - }).setFooter({text: message.author.id}); + }).setFooter({text: + `Message ID: ${message.id}\n` + + `Channel ID: ${message.channel.id}\n` + + `User ID: ${message.author.id}` + }); if (message.content.length) { this.setDescription(message.content.substring(0, EMBED_DESCRIPTION_LIMIT)); diff --git a/src/events/discord/MessageDeleteBulkEventListener.js b/src/events/discord/MessageDeleteBulkEventListener.js index c4035495e..ba65291b6 100644 --- a/src/events/discord/MessageDeleteBulkEventListener.js +++ b/src/events/discord/MessageDeleteBulkEventListener.js @@ -1,8 +1,8 @@ import EventListener from '../EventListener.js'; -import {EmbedBuilder, escapeMarkdown} from 'discord.js'; +import {AttachmentBuilder, EmbedBuilder, userMention} from 'discord.js'; import colors from '../../util/colors.js'; import GuildWrapper from '../../discord/GuildWrapper.js'; -import {EMBED_DESCRIPTION_LIMIT} from '../../util/apiLimits.js'; +import {EMBED_DESCRIPTION_LIMIT, MESSAGE_FILE_LIMIT} from '../../util/apiLimits.js'; export default class MessageDeleteBulkEventListener extends EventListener { get name() { @@ -18,11 +18,29 @@ export default class MessageDeleteBulkEventListener extends EventListener { const embed = new EmbedBuilder() .setTitle(`${messages.size} messages were deleted in ${channel.name}`) .setColor(colors.RED); + const attachments = []; for (const message of messages.sort((m1, m2) => m1.createdTimestamp - m2.createdTimestamp).values()) { - if (!message.content) { + for (const attachment of message.attachments.values()) { + attachments.push(new AttachmentBuilder(attachment.attachment) + .setDescription(attachment.description) + .setName(attachment.name) + .setSpoiler(true)); + } + + let content = message.content.replaceAll('\n', ' ').trim(); + let attachmentCount = message.attachments.size; + + if (!content && attachmentCount === 0) { continue; } - const data = `${escapeMarkdown(message.author.tag)} (${message.author.id}): ${message.content.replaceAll('\n', ' ').trim()}\n`; + + let data = `${userMention(message.author.id)} (${message.id})`; + if (attachmentCount) { + data += `${attachmentCount} file${attachmentCount === 1 ? '' : 's'}`; + } + if (content) { + data += `: ${content}\n`; + } const description = embed.data.description ?? ''; embed.setDescription((description + data).substring(0, EMBED_DESCRIPTION_LIMIT)); @@ -39,6 +57,7 @@ export default class MessageDeleteBulkEventListener extends EventListener { const guild = new GuildWrapper(channel.guild); await guild.logMessage({ embeds: [embed], + files: attachments.slice(0, MESSAGE_FILE_LIMIT) }); } } \ No newline at end of file diff --git a/src/util/apiLimits.js b/src/util/apiLimits.js index 2cb28e1ce..d081a95cb 100644 --- a/src/util/apiLimits.js +++ b/src/util/apiLimits.js @@ -94,4 +94,6 @@ export const BULK_DELETE_MAX_AGE = 14 * 24 * 60 * 60 * 1000; * maximum number of bans that can be fetched per page * @type {number} */ -export const FETCH_BAN_PAGE_SIZE = 1000; \ No newline at end of file +export const FETCH_BAN_PAGE_SIZE = 1000; + +export const MESSAGE_FILE_LIMIT = 10; \ No newline at end of file