From 13306f17accea5d3653dd4b8670ba0d6ab69c7c5 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 6 Sep 2021 15:20:46 -0400 Subject: evidence command and more logging --- src/listeners/custom/bushUpdateModlog.ts | 33 +++++++++++++++++++++++++++ src/listeners/custom/bushUpdateSettings.ts | 36 ++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/listeners/custom/bushUpdateModlog.ts create mode 100644 src/listeners/custom/bushUpdateSettings.ts (limited to 'src/listeners/custom') diff --git a/src/listeners/custom/bushUpdateModlog.ts b/src/listeners/custom/bushUpdateModlog.ts new file mode 100644 index 0000000..16e0dbf --- /dev/null +++ b/src/listeners/custom/bushUpdateModlog.ts @@ -0,0 +1,33 @@ +import { BushListener } from '@lib'; +import { MessageEmbed } from 'discord.js'; +import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents'; + +export default class BushUpdateModlogListener extends BushListener { + public constructor() { + super('bushUpdateModlog', { + emitter: 'client', + event: 'bushUpdateModlog', + category: 'custom' + }); + } + + public override async exec( + ...[moderator, modlogID, key, oldModlog, newModlog]: BushClientEvents['bushUpdateModlog'] + ): Promise { + const logChannel = await moderator.guild.getLogChannel('moderation'); + if (!logChannel) return; + + const logEmbed = new MessageEmbed() + .setColor(util.colors.discord.BLURPLE) + .setTimestamp() + .setAuthor(moderator.user.tag, moderator.user.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined) + .addField('**Action**', `${'Update Modlog'}`) + .addField('**Moderator**', `${moderator} (${moderator.user.tag})`) + .addField('**ModLog Changed**', modlogID) + .addField('**Value Changed**', key) + .addField('**Old Value**', await util.inspectCleanRedactCodeblock(oldModlog, undefined, undefined, 1024)) + .addField('**New Value**', await util.inspectCleanRedactCodeblock(newModlog, undefined, undefined, 1024)); + + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/custom/bushUpdateSettings.ts b/src/listeners/custom/bushUpdateSettings.ts new file mode 100644 index 0000000..eae3062 --- /dev/null +++ b/src/listeners/custom/bushUpdateSettings.ts @@ -0,0 +1,36 @@ +import { BushListener } from '@lib'; +import { MessageEmbed } from 'discord.js'; +import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents'; + +export default class BushUpdateSettingsListener extends BushListener { + public constructor() { + super('bushUpdateSettings', { + emitter: 'client', + event: 'bushUpdateSettings', + category: 'custom' + }); + } + + public override async exec( + ...[setting, guild, oldSettings, newSettings, moderator]: BushClientEvents['bushUpdateSettings'] + ): Promise { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + + const logEmbed = new MessageEmbed().setColor(util.colors.discord.BLURPLE).setTimestamp(); + + if (moderator) + logEmbed.setAuthor( + moderator.user.tag, + moderator.user.avatarURL({ dynamic: true, format: 'png', size: 4096 }) ?? undefined + ); + logEmbed.addField('**Action**', `${'Update Settings'}`); + if (moderator) logEmbed.addField('**Moderator**', `${moderator} (${moderator.user.tag})`); + logEmbed + .addField('**Setting Changed**', setting) + .addField('**Old Value**', await util.inspectCleanRedactCodeblock(oldSettings, 'js', undefined, 1024)) + .addField('**New Value**', await util.inspectCleanRedactCodeblock(newSettings, 'js', undefined, 1024)); + + return await logChannel.send({ embeds: [logEmbed] }); + } +} -- cgit