pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | export const event = 'roleCreate' |
| 2 | |
| 3 | export async function callback(client, role) { |
| 4 | const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame^] | 5 | if (role.managed) return; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 6 | let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE'); |
| 7 | let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first(); |
| 8 | if (audit.executor.id == client.user.id) return; |
| 9 | let 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 | id: 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 |
| 26 | } |
| 27 | } |
| 28 | log(data, client); |
| 29 | } |