pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | export const event = 'roleCreate' |
| 2 | |
| 3 | export async function callback(client, role) { |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 4 | try { |
| 5 | const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger |
| 6 | if (role.managed) return; |
| 7 | let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE'); |
| 8 | let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first(); |
| 9 | if (audit.executor.id == client.user.id) return; |
| 10 | let data = { |
| 11 | meta: { |
| 12 | type: 'roleCreate', |
| 13 | displayName: 'Role Created', |
| 14 | calculateType: 'guildRoleUpdate', |
| 15 | color: NucleusColors.green, |
| 16 | emoji: "GUILD.ROLES.CREATE", |
| 17 | timestamp: role.createdTimestamp |
| 18 | }, |
| 19 | list: { |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 20 | roleId: entry(role.id, `\`${role.id}\``), |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 21 | role: entry(role.name, renderRole(role)), |
| 22 | createdBy: entry(audit.executor.id, renderUser(audit.executor)), |
| 23 | created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)) |
| 24 | }, |
| 25 | hidden: { |
| 26 | guild: role.guild.id |
| 27 | } |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 28 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 29 | log(data); |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 30 | } catch {} |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 31 | } |