pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | export const event = 'messageDelete' |
| 2 | |
| 3 | export 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: { |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame^] | 19 | start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*', |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 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 | } |