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) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 4 | const { |
| 5 | getAuditLog, |
| 6 | log, |
| 7 | NucleusColors, |
| 8 | entry, |
| 9 | renderUser, |
| 10 | renderDelta, |
| 11 | renderRole |
| 12 | } = role.client.logger; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 13 | if (role.managed) return; |
| 14 | const auditLog = await getAuditLog(role.guild, "ROLE_CREATE"); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 15 | const audit = auditLog.entries |
| 16 | .filter((entry) => entry.target.id === role.id) |
| 17 | .first(); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 18 | if (audit.executor.id === client.user.id) return; |
| 19 | const data = { |
| 20 | meta: { |
| 21 | type: "roleCreate", |
| 22 | displayName: "Role Created", |
| 23 | calculateType: "guildRoleUpdate", |
| 24 | color: NucleusColors.green, |
| 25 | emoji: "GUILD.ROLES.CREATE", |
| 26 | timestamp: role.createdTimestamp |
| 27 | }, |
| 28 | list: { |
| 29 | roleId: entry(role.id, `\`${role.id}\``), |
| 30 | role: entry(role.name, renderRole(role)), |
| 31 | createdBy: entry(audit.executor.id, renderUser(audit.executor)), |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 32 | created: entry( |
| 33 | role.createdTimestamp, |
| 34 | renderDelta(role.createdTimestamp) |
| 35 | ) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 36 | }, |
| 37 | hidden: { |
| 38 | guild: role.guild.id |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 39 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 40 | }; |
| 41 | log(data); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 42 | } |