pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 1 | import { purgeByUser } from '../automations/tickets/delete.js'; |
| 2 | import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js'; |
| 3 | |
| 4 | export const event = 'guildBanAdd'; |
| 5 | |
| 6 | export async function callback(client, ban) { |
| 7 | try { await statsChannelRemove(client, ban.user); } catch {} |
| 8 | try { purgeByUser(ban.user.id, ban.guild); } catch {} |
| 9 | try { |
| 10 | const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger |
| 11 | let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_ADD') |
| 12 | let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first(); |
| 13 | if (audit.executor.id == client.user.id) return |
| 14 | console.log(ban.reason) |
| 15 | let data = { |
| 16 | meta: { |
| 17 | type: 'memberBan', |
| 18 | displayName: 'Member Banned', |
| 19 | calculateType: 'guildMemberPunish', |
| 20 | color: NucleusColors.red, |
| 21 | emoji: "PUNISH.BAN.RED", |
| 22 | timestamp: new Date().getTime() |
| 23 | }, |
| 24 | list: { |
| 25 | id: entry(ban.user.id, `\`${ban.user.id}\``), |
| 26 | name: entry(ban.user.id, renderUser(ban.user)), |
| 27 | banned: entry(new Date().getTime(), renderDelta(new Date().getTime())), |
| 28 | bannedBy: entry(audit.executor.id, renderUser(audit.executor)), |
| 29 | reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"), |
| 30 | accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)), |
| 31 | serverMemberCount: ban.guild.memberCount, |
| 32 | }, |
| 33 | hidden: { |
| 34 | guild: ban.guild.id |
| 35 | } |
| 36 | } |
| 37 | log(data, ban.user.client); |
| 38 | } catch {} |
| 39 | } |