pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 1 | export const event = "roleCreate"; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 2 | |
| 3 | export async function callback(client, role) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 4 | const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger; |
| 5 | if (role.managed) return; |
| 6 | const auditLog = await getAuditLog(role.guild, "ROLE_CREATE"); |
| 7 | const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first(); |
| 8 | 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)), |
| 22 | created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)) |
| 23 | }, |
| 24 | hidden: { |
| 25 | guild: role.guild.id |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 26 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 27 | }; |
| 28 | log(data); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 29 | } |