blob: 487a45e4c54d3397f7fe42215db73aaf2c1ea4fa [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
5 let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
6 let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
7 if (audit.executor.id == client.user.id) return;
8 let data = {
9 meta: {
10 type: 'roleCreate',
11 displayName: 'Role Created',
12 calculateType: 'guildRoleUpdate',
13 color: NucleusColors.green,
14 emoji: "GUILD.ROLES.CREATE",
15 timestamp: role.createdTimestamp
16 },
17 list: {
18 id: entry(role.id, `\`${role.id}\``),
19 role: entry(role.name, renderRole(role)),
20 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
21 created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
22 },
23 hidden: {
24 guild: role.guild.id
25 }
26 }
27 log(data, client);
28}