1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 00:31:00 -05:00
Daggerbot-TS/src/events/guildBanAdd.ts

25 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-11-21 20:25:24 -05:00
import Discord, { AuditLogEvent } from 'discord.js';
import { TClient } from '../client';
export default {
name: 'guildBanAdd',
execute: async(client:TClient, member:Discord.GuildMember)=>{
2022-11-25 04:49:12 -05:00
if (member.guild?.id != client.config.mainServer.id) return;
2022-11-21 20:25:24 -05:00
const fetchBanlog = await member.guild.fetchAuditLogs({
limit: 1,
type: AuditLogEvent.MemberBanAdd
})
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) {
const embed = 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}`}
);
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]})
} 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
}