blob: a1601bb25a5e5b41d3ee8d990e20eb221b3ea142 [file] [log] [blame]
pineafane625d782022-05-09 18:04:32 +01001import { callback as statsChannelAdd } from '../automations/statsChannelAdd.js';
2import { callback as welcome } from '../automations/welcome.js';
3import log from '../utils/log.js';
4export const event = 'guildMemberUpdate'
5
6export 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}