From 2650ab81a57a2e6e037de905eefffe6777dbb9f8 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 8 Nov 2020 17:52:56 +0200 Subject: [PATCH] Add excluded_categories option to log channels --- backend/src/plugins/Logs/types.ts | 1 + backend/src/plugins/Logs/util/log.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/backend/src/plugins/Logs/types.ts b/backend/src/plugins/Logs/types.ts index 759d7581..6545b595 100644 --- a/backend/src/plugins/Logs/types.ts +++ b/backend/src/plugins/Logs/types.ts @@ -19,6 +19,7 @@ const LogChannel = t.partial({ excluded_users: t.array(t.string), excluded_message_regexes: t.array(TRegex), excluded_channels: t.array(t.string), + excluded_categories: t.array(t.string), format: tNullable(tLogFormats), timestamp_format: t.string, include_embed_timestamp: t.boolean, diff --git a/backend/src/plugins/Logs/util/log.ts b/backend/src/plugins/Logs/util/log.ts index 6abdedaa..f5aab896 100644 --- a/backend/src/plugins/Logs/util/log.ts +++ b/backend/src/plugins/Logs/util/log.ts @@ -43,6 +43,22 @@ export async function log(pluginData: GuildPluginData, type: Log } } + // If this entry is from an excluded category, skip it + if (opts.excluded_categories) { + if ( + type === LogType.MESSAGE_DELETE || + type === LogType.MESSAGE_DELETE_BARE || + type === LogType.MESSAGE_EDIT || + type === LogType.MESSAGE_SPAM_DETECTED || + type === LogType.CENSOR || + type === LogType.CLEAN + ) { + if (data.channel.parent_id && opts.excluded_categories.includes(data.channel.parent_id)) { + continue logChannelLoop; + } + } + } + // If this entry contains a message with an excluded regex, skip it if (type === LogType.MESSAGE_DELETE && opts.excluded_message_regexes && data.message.data.content) { for (const regex of opts.excluded_message_regexes) {