blob: 5081dd1faf0f9d03838da7106671bcff4de036d8 [file] [log] [blame]
pineafane625d782022-05-09 18:04:32 +01001import humanizeDuration from 'humanize-duration';
2export const event = 'inviteCreate'
3
4export async function callback(client, invite) {
5 try {
6 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
7 let auditLog = await getAuditLog(invite.guild, 'INVITE_CREATE');
8 let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
9 if (audit.executor.id == client.user.id) return;
10 let data = {
11 meta: {
12 type: 'inviteCreate',
13 displayName: 'Invite Created',
14 calculateType: 'guildUpdate',
15 color: NucleusColors.green,
16 emoji: "INVITE.CREATE",
17 timestamp: invite.createdTimestamp
18 },
19 list: {
20 channel: entry(invite.channel.id, renderChannel(invite.channel)),
21 link: entry(invite.url, invite.url),
22 expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
23 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
24 created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
25 },
26 hidden: {
27 guild: invite.guild.id
28 }
29 }
pineafan4edb7762022-06-26 19:21:04 +010030 log(data);
pineafane625d782022-05-09 18:04:32 +010031 } catch {}
32}