pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 1 | import { purgeByUser } from "../actions/tickets/delete.js"; |
| 2 | import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js"; |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 3 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 4 | export const event = "guildBanRemove"; |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 5 | |
| 6 | export async function callback(client, ban) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 7 | await statsChannelRemove(client, ban.user); |
| 8 | purgeByUser(ban.user.id, ban.guild); |
| 9 | const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger; |
| 10 | const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_REMOVE"); |
| 11 | const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first(); |
| 12 | if (audit.executor.id === client.user.id) return; |
| 13 | await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason); |
| 14 | const data = { |
| 15 | meta: { |
| 16 | type: "memberUnban", |
| 17 | displayName: "Member Unbanned", |
| 18 | calculateType: "guildMemberPunish", |
| 19 | color: NucleusColors.green, |
| 20 | emoji: "PUNISH.BAN.GREEN", |
| 21 | timestamp: new Date().getTime() |
| 22 | }, |
| 23 | list: { |
| 24 | memberId: entry(ban.user.id, `\`${ban.user.id}\``), |
| 25 | name: entry(ban.user.id, renderUser(ban.user)), |
| 26 | unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())), |
| 27 | unbannedBy: entry(audit.executor.id, renderUser(audit.executor)), |
| 28 | accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)) |
| 29 | }, |
| 30 | hidden: { |
| 31 | guild: ban.guild.id |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 32 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame^] | 33 | }; |
| 34 | log(data); |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 35 | } |