pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | export const event = 'messageDelete' |
| 2 | |
| 3 | export async function callback(client, message) { |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 4 | 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; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 11 | } |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 12 | 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: { |
| 28 | id: entry(message.id, `\`${message.id}\``), |
| 29 | 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 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame^] | 43 | log(data); |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 44 | } catch {} |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 45 | } |