1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-27 20:35:38 -05:00

log manual bans cuz yes

This commit is contained in:
AnxietyisReal 2022-11-22 12:25:24 +11:00
parent 79bbb33b7f
commit 96e4836401
2 changed files with 46 additions and 0 deletions

23
src/events/guildBanAdd.ts Normal file
View File

@ -0,0 +1,23 @@
import Discord, { AuditLogEvent } from 'discord.js';
import { TClient } from '../client';
export default {
name: 'guildBanAdd',
execute: async(client:TClient, member:Discord.GuildMember)=>{
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(
{name: '🔹 Moderator', value: `<@${executor.id}> (\`${executor.id}\`)`},
{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.`)
}
}
}

View File

@ -0,0 +1,23 @@
import Discord, { AuditLogEvent } from 'discord.js';
import { TClient } from '../client';
export default {
name: 'guildBanRemove',
execute: async(client:TClient, member:Discord.GuildMember)=>{
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) {
const embed = 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}> (\`${executor.id}\`)`},
{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 unbanned from ${member.guild.name} but no audit log could be fetched.`)
}
}
}