2023-12-24 22:02:59 -05:00
|
|
|
import Discord from 'discord.js';
|
2023-04-14 06:47:58 -04:00
|
|
|
import TClient from '../client.js';
|
2023-12-24 10:21:40 -05:00
|
|
|
export default class GuildBanAdd {
|
|
|
|
static async run(client:TClient, member:Discord.GuildMember){
|
|
|
|
if (member.guild?.id != client.config.dcServer.id) return;
|
2023-12-24 22:02:59 -05:00
|
|
|
const banLog = (await member.guild.fetchAuditLogs({ limit: 1, type: Discord.AuditLogEvent.MemberBanAdd })).entries.first();
|
2023-06-09 21:11:19 -04:00
|
|
|
if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`)
|
2023-03-05 05:04:10 -05:00
|
|
|
const {executor, target, reason } = banLog;
|
2023-06-09 21:11:19 -04:00
|
|
|
if (target.id === member.user.id) {
|
|
|
|
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.username}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
2023-03-05 05:04:10 -05:00
|
|
|
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
2023-06-09 21:11:19 -04:00
|
|
|
{name: '🔹 Reason', value: `${reason === null ? 'Reason unspecified': reason}`}
|
|
|
|
);
|
2023-12-24 10:21:40 -05:00
|
|
|
if (!await client.userLevels.fetchUser(member.user.id)) embed.setFooter({text: 'Rank data has been wiped.'});
|
|
|
|
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]})
|
2023-06-09 21:11:19 -04:00
|
|
|
} else console.log(`User was banned from "${member.guild.name}" but no audit log could be fetched.`)
|
2023-03-05 05:04:10 -05:00
|
|
|
}
|
2022-11-25 04:49:12 -05:00
|
|
|
}
|