blob: f0051a0e051c90b0bb0456cdafe9a670402f13b8 [file] [log] [blame]
pineafan63fc5e22022-08-04 22:04:10 +01001export const event = "roleCreate";
pineafan32767212022-03-14 21:27:39 +00002
3export async function callback(client, role) {
Skyler Grey75ea9172022-08-06 10:22:23 +01004 const {
5 getAuditLog,
6 log,
7 NucleusColors,
8 entry,
9 renderUser,
10 renderDelta,
11 renderRole
12 } = role.client.logger;
pineafan63fc5e22022-08-04 22:04:10 +010013 if (role.managed) return;
14 const auditLog = await getAuditLog(role.guild, "ROLE_CREATE");
Skyler Grey75ea9172022-08-06 10:22:23 +010015 const audit = auditLog.entries
16 .filter((entry) => entry.target.id === role.id)
17 .first();
pineafan63fc5e22022-08-04 22:04:10 +010018 if (audit.executor.id === client.user.id) return;
19 const data = {
20 meta: {
21 type: "roleCreate",
22 displayName: "Role Created",
23 calculateType: "guildRoleUpdate",
24 color: NucleusColors.green,
25 emoji: "GUILD.ROLES.CREATE",
26 timestamp: role.createdTimestamp
27 },
28 list: {
29 roleId: entry(role.id, `\`${role.id}\``),
30 role: entry(role.name, renderRole(role)),
31 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey75ea9172022-08-06 10:22:23 +010032 created: entry(
33 role.createdTimestamp,
34 renderDelta(role.createdTimestamp)
35 )
pineafan63fc5e22022-08-04 22:04:10 +010036 },
37 hidden: {
38 guild: role.guild.id
pineafan32767212022-03-14 21:27:39 +000039 }
pineafan63fc5e22022-08-04 22:04:10 +010040 };
41 log(data);
pineafan32767212022-03-14 21:27:39 +000042}