2022-11-21 20:25:24 -05:00
|
|
|
import Discord, { AuditLogEvent } from 'discord.js';
|
2023-01-27 21:33:55 -05:00
|
|
|
import TClient from '../client';
|
2022-11-21 20:25:24 -05:00
|
|
|
export default {
|
2023-01-02 04:45:05 -05:00
|
|
|
async run(client:TClient, member:Discord.GuildMember){
|
2022-11-25 04:49:12 -05:00
|
|
|
if (member.guild?.id != client.config.mainServer.id) return;
|
2023-02-13 02:37:23 -05:00
|
|
|
const fetchBanlog = await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanAdd})
|
2022-11-21 20:25:24 -05:00
|
|
|
const banLog = fetchBanlog.entries.first();
|
|
|
|
if (!banLog) return console.log(`${member.user.tag} was banned from ${member.guild.name} but no audit log for this user.`)
|
|
|
|
const {executor, target, reason } = banLog;
|
|
|
|
if (target.id == member.user.id) {
|
2023-02-13 02:37:23 -05:00
|
|
|
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
|
|
|
new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
2022-11-22 01:38:40 -05:00
|
|
|
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
2022-11-21 20:25:24 -05:00
|
|
|
{name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified': reason}`}
|
2023-02-13 02:37:23 -05:00
|
|
|
)]})
|
2022-11-21 20:25:24 -05:00
|
|
|
} else {
|
|
|
|
console.log(`${target.tag} was banned from ${member.guild.name} but no audit log could be fetched.`)
|
|
|
|
}
|
|
|
|
}
|
2022-11-25 04:49:12 -05:00
|
|
|
}
|