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-03-05 05:04:10 -05:00
|
|
|
async run(client:TClient, member:Discord.GuildMember){
|
|
|
|
if (member.guild?.id != client.config.mainServer.id) return;
|
|
|
|
const fetchUnbanlog = await member.guild.fetchAuditLogs({limit: 1, type: AuditLogEvent.MemberBanRemove})
|
|
|
|
const unbanLog = fetchUnbanlog.entries.first();
|
|
|
|
if (!unbanLog) return console.log(`${member.user.tag} was unbanned from ${member.guild.name} but no audit log for this user.`)
|
|
|
|
const { executor, target, reason } = unbanLog;
|
|
|
|
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.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields(
|
|
|
|
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
|
|
|
{name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified.': reason}`}
|
|
|
|
)]});
|
|
|
|
else console.log(`${target.tag} was unbanned from ${member.guild.name} but no audit log could be fetched.`)
|
|
|
|
}
|
2022-11-25 04:49:30 -05:00
|
|
|
}
|