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