From 6172dc6ac66280637fb5768de6182cabd8e14a91 Mon Sep 17 00:00:00 2001 From: Anthony Berg Date: Sat, 13 Jan 2024 00:57:14 +0000 Subject: [PATCH] feat(arabot): add logging for sus note purges --- src/commands/mod/sus.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/commands/mod/sus.ts b/src/commands/mod/sus.ts index a4dde56..9871c05 100644 --- a/src/commands/mod/sus.ts +++ b/src/commands/mod/sus.ts @@ -507,6 +507,7 @@ export class SusCommand extends Subcommand { ) { // Get the arguments const user = interaction.options.getUser('user', true); + const mod = interaction.user; const { guild, channel } = interaction; // Checks if all the variables are of the right type @@ -616,6 +617,8 @@ export class SusCommand extends Subcommand { embeds: [], }); } + + await this.deleteAllNotesLogger(user, mod, guild); }); // Remove the buttons after they have been clicked @@ -628,4 +631,37 @@ export class SusCommand extends Subcommand { // Remove sus role from the user await member.roles.remove(IDs.roles.restrictions.sus); } + + // Logs removal of 1 sus note + private async deleteAllNotesLogger(user: User, mod: User, guild: Guild) { + // Log the sus note + let logChannel = guild.channels.cache.get(IDs.channels.logs.sus) as + | TextChannel + | undefined; + + if (logChannel === undefined) { + logChannel = (await guild.channels.fetch(IDs.channels.logs.sus)) as + | TextChannel + | undefined; + if (logChannel === undefined) { + this.container.logger.error('Sus Error: Could not fetch log channel'); + return; + } + } + + const embed = new EmbedBuilder() + .setColor('#28A745') + .setAuthor({ + name: `Purged all sus notes for ${user.tag}`, + iconURL: `${user.displayAvatarURL()}`, + }) + .addFields( + { name: 'User', value: `${user}`, inline: true }, + { name: 'Moderator', value: `${mod}`, inline: true }, + ) + .setTimestamp() + .setFooter({ text: `ID: ${user.id}` }); + + await logChannel.send({ embeds: [embed] }); + } }