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) { |
| 6 | const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger |
| 7 | |
| 8 | if (oe.name == ne.name) return |
| 9 | let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE'); |
| 10 | let audit = auditLog.entries.first(); |
| 11 | if (audit.executor.id == client.user.id) return; |
| 12 | |
| 13 | let changes = { |
| 14 | id: entry(ne.id, `\`${ne.id}\``), |
| 15 | emoji: entry(ne.id, renderEmoji(ne)), |
| 16 | edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)), |
| 17 | editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)), |
| 18 | name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``), |
| 19 | } |
| 20 | let data = { |
| 21 | meta:{ |
| 22 | type: 'emojiUpdate', |
| 23 | displayName: 'Emoji Edited', |
| 24 | calculateType: 'emojiUpdate', |
| 25 | color: NucleusColors.yellow, |
| 26 | emoji: "GUILD.EMOJI.EDIT", |
| 27 | timestamp: audit.createdTimestamp |
| 28 | }, |
| 29 | list: changes, |
| 30 | hidden: { |
| 31 | guild: ne.guild.id |
| 32 | } |
| 33 | } |
| 34 | log(data, client); |
| 35 | } |