pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | import getEmojiByName from "../utils/getEmojiByName.js"; |
| 2 | |
| 3 | export const event = 'emojiUpdate'; |
| 4 | |
| 5 | export async function callback(client, oe, ne) { |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 6 | try { |
| 7 | const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 8 | |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 9 | if (oe.name == ne.name) return |
| 10 | let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE'); |
| 11 | let audit = auditLog.entries.first(); |
| 12 | if (audit.executor.id == client.user.id) return; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 13 | |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 14 | let changes = { |
| 15 | id: entry(ne.id, `\`${ne.id}\``), |
| 16 | emoji: entry(ne.id, renderEmoji(ne)), |
| 17 | edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)), |
| 18 | editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)), |
| 19 | name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``), |
| 20 | } |
| 21 | let data = { |
| 22 | meta:{ |
| 23 | type: 'emojiUpdate', |
| 24 | displayName: 'Emoji Edited', |
| 25 | calculateType: 'emojiUpdate', |
| 26 | color: NucleusColors.yellow, |
| 27 | emoji: "GUILD.EMOJI.EDIT", |
| 28 | timestamp: audit.createdTimestamp |
| 29 | }, |
| 30 | list: changes, |
| 31 | hidden: { |
| 32 | guild: ne.guild.id |
| 33 | } |
| 34 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 35 | log(data); |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 36 | } catch {} |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 37 | } |