blob: 26647902f1dbd666911602ad0136561071b34400 [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: {
20 id: entry(role.id, `\`${role.id}\``),
21 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 }
pineafane625d782022-05-09 18:04:32 +010029 log(data, client);
30 } catch {}
pineafan32767212022-03-14 21:27:39 +000031}