blob: f1b0a91c149895ebd91c87f08eb94d598dad86ea [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 Grey11236ba2022-08-08 21:13:33 +01004 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger;
pineafan63fc5e22022-08-04 22:04:10 +01005 if (role.managed) return;
6 const auditLog = await getAuditLog(role.guild, "ROLE_CREATE");
Skyler Grey11236ba2022-08-08 21:13:33 +01007 const audit = auditLog.entries.filter((entry) => entry.target.id === role.id).first();
pineafan63fc5e22022-08-04 22:04:10 +01008 if (audit.executor.id === client.user.id) return;
9 const 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 roleId: entry(role.id, `\`${role.id}\``),
20 role: entry(role.name, renderRole(role)),
21 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey11236ba2022-08-08 21:13:33 +010022 created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010023 },
24 hidden: {
25 guild: role.guild.id
pineafan32767212022-03-14 21:27:39 +000026 }
pineafan63fc5e22022-08-04 22:04:10 +010027 };
28 log(data);
pineafan32767212022-03-14 21:27:39 +000029}