blob: 6fded26e2abb3f2b23b85d6ef0138c03d01d60de [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001export const event = 'roleCreate'
2
3export async function callback(client, role) {
pineafane625d782022-05-09 18:04:32 +01004 try {
5 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
6 if (role.managed) return;
7 let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
8 let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
9 if (audit.executor.id == client.user.id) return;
10 let data = {
11 meta: {
12 type: 'roleCreate',
13 displayName: 'Role Created',
14 calculateType: 'guildRoleUpdate',
15 color: NucleusColors.green,
16 emoji: "GUILD.ROLES.CREATE",
17 timestamp: role.createdTimestamp
18 },
19 list: {
pineafanda6e5342022-07-03 10:03:16 +010020 roleId: entry(role.id, `\`${role.id}\``),
pineafane625d782022-05-09 18:04:32 +010021 role: entry(role.name, renderRole(role)),
22 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
23 created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
24 },
25 hidden: {
26 guild: role.guild.id
27 }
pineafan32767212022-03-14 21:27:39 +000028 }
pineafan4edb7762022-06-26 19:21:04 +010029 log(data);
pineafane625d782022-05-09 18:04:32 +010030 } catch {}
pineafan32767212022-03-14 21:27:39 +000031}