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 |
| 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 | } |