blob: 3b7c5c2c2c074ab4666addb14cfb0b8a1c035754 [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001export const event = 'messageDelete'
2
3export async function callback(client, message) {
4 if (message.author.id == client.user.id) return;
5 const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
6 message.reference = message.reference || {}
7 let content = message.cleanContent
8 if (content.length > 256) content = content.substring(0, 253) + '...'
9 let data = {
10 meta: {
11 type: 'messageDelete',
12 displayName: 'Message Deleted',
13 calculateType: 'messageDelete',
14 color: NucleusColors.red,
15 emoji: 'MESSAGE.DELETE',
16 timestamp: new Date().getTime()
17 },
18 separate: {
19 start: `**Message:**\n\`\`\`${content}\`\`\``
20 },
21 list: {
22 id: entry(message.id, `\`${message.id}\``),
23 sentBy: entry(message.author.id, renderUser(message.author)),
24 sentIn: entry(message.channel.id, renderChannel(message.channel)),
25 deleted: entry(new Date(message.createdTimestamp), renderDelta(new Date(message.createdTimestamp))),
26 mentions: message.mentions.users.size,
27 attachments: message.attachments.size,
28 repliedTo: entry(
29 message.reference.messageId || null,
30 message.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
31 )
32 },
33 hidden: {
34 guild: message.channel.guild.id
35 }
36 }
37 log(data, client);
38}