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