blob: 76af433c45db0b54304c4c09a8281099cbbfb99e [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001export const event = 'roleCreate'
2
3export async function callback(client, role) {
4 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
pineafan377794f2022-04-18 19:01:01 +01005 if (role.managed) return;
pineafan32767212022-03-14 21:27:39 +00006 let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
7 let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
8 if (audit.executor.id == client.user.id) return;
9 let data = {
10 meta: {
11 type: 'roleCreate',
12 displayName: 'Role Created',
13 calculateType: 'guildRoleUpdate',
14 color: NucleusColors.green,
15 emoji: "GUILD.ROLES.CREATE",
16 timestamp: role.createdTimestamp
17 },
18 list: {
19 id: entry(role.id, `\`${role.id}\``),
20 role: entry(role.name, renderRole(role)),
21 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
22 created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
23 },
24 hidden: {
25 guild: role.guild.id
26 }
27 }
28 log(data, client);
29}