pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame^] | 1 | import { callback as statsChannelAdd } from '../automations/statsChannelAdd.js'; |
| 2 | import { callback as welcome } from '../automations/welcome.js'; |
| 3 | import log from '../utils/log.js'; |
| 4 | export const event = 'guildMemberUpdate' |
| 5 | |
| 6 | export async function callback(client, before, after) { |
| 7 | try { |
| 8 | const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger |
| 9 | if (before.nickname != after.nickname) { |
| 10 | let auditLog = await getAuditLog(after.guild, 'MEMBER_UPDATE'); |
| 11 | let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first(); |
| 12 | if (audit.executor.id == client.user.id) return; |
| 13 | let data = { |
| 14 | meta: { |
| 15 | type: 'memberUpdate', |
| 16 | displayName: 'Nickname Changed', |
| 17 | calculateType: 'guildMemberUpdate', |
| 18 | color: NucleusColors.yellow, |
| 19 | emoji: "PUNISH.NICKNAME.YELLOW", |
| 20 | timestamp: new Date().getTime() |
| 21 | }, |
| 22 | list: { |
| 23 | id: entry(after.id, `\`${after.id}\``), |
| 24 | before: entry(before.nickname, before.nickname ? before.nickname : '*None*'), |
| 25 | after: entry(after.nickname, after.nickname ? after.nickname : '*None*'), |
| 26 | updated: entry(new Date().getTime(), renderDelta(new Date().getTime())), |
| 27 | updatedBy: entry(audit.executor.id, renderUser(audit.executor)) |
| 28 | }, |
| 29 | hidden: { |
| 30 | guild: after.guild.id |
| 31 | } |
| 32 | } |
| 33 | log(data, after.client); |
| 34 | } |
| 35 | } catch (e) { console.log(e) } |
| 36 | } |