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/guildBanRemove.ts

17 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-11-21 20:25:24 -05:00
import Discord, { AuditLogEvent } from 'discord.js';
2023-04-14 06:47:58 -04:00
import TClient from '../client.js';
2022-11-21 20:25:24 -05:00
export default {
2023-03-05 05:04:10 -05:00
async run(client:TClient, member:Discord.GuildMember){
if (member.guild?.id != client.config.mainServer.id) return;
const unbanLog = (await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanRemove})).entries.first();
if (!unbanLog) return console.log(`User was unbanned from ${member.guild.name} but no audit log for this user.`)
2023-03-05 05:04:10 -05:00
const { executor, target, reason } = unbanLog;
2023-05-23 01:14:17 -04:00
if (target.id === member.user.id) (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Unbanned: ${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}\``},
{name: '🔹 Reason', value: `${reason === null ? 'Reason unspecified.': reason}`}
2023-03-05 05:04:10 -05:00
)]});
else console.log(`User was unbanned from ${member.guild.name} but no audit log could be fetched.`)
2023-03-05 05:04:10 -05:00
}
2022-11-25 04:49:30 -05:00
}