blob: f0fbb5761f9b5431a41c0583be56fa48a815f863 [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001export const event = 'messageDelete'
2
3export async function callback(client, message) {
pineafane625d782022-05-09 18:04:32 +01004 try {
5 if (message.author.id == client.user.id) return;
6 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
7 let auditLog = await getAuditLog(message.guild, 'MEMBER_BAN_ADD')
8 let audit = auditLog.entries.filter(entry => entry.target.id == message.author.id).first();
9 if (audit) {
10 if (audit.createdAt - 100 < new Date().getTime()) return;
pineafan32767212022-03-14 21:27:39 +000011 }
pineafane625d782022-05-09 18:04:32 +010012 message.reference = message.reference || {}
13 let content = message.cleanContent
14 if (content.length > 256) content = content.substring(0, 253) + '...'
15 let data = {
16 meta: {
17 type: 'messageDelete',
18 displayName: 'Message Deleted',
19 calculateType: 'messageDelete',
20 color: NucleusColors.red,
21 emoji: 'MESSAGE.DELETE',
22 timestamp: new Date().getTime()
23 },
24 separate: {
25 start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
26 },
27 list: {
pineafanda6e5342022-07-03 10:03:16 +010028 messageId: entry(message.id, `\`${message.id}\``),
pineafane625d782022-05-09 18:04:32 +010029 sentBy: entry(message.author.id, renderUser(message.author)),
30 sentIn: entry(message.channel.id, renderChannel(message.channel)),
31 deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
32 mentions: message.mentions.users.size,
33 attachments: message.attachments.size,
34 repliedTo: entry(
35 message.reference.messageId || null,
36 message.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
37 )
38 },
39 hidden: {
40 guild: message.channel.guild.id
41 }
42 }
pineafan4edb7762022-06-26 19:21:04 +010043 log(data);
pineafane625d782022-05-09 18:04:32 +010044 } catch {}
pineafan32767212022-03-14 21:27:39 +000045}