From d65f5b99d7f0f8b25655a8603d2b419d98f9df31 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 8 Nov 2020 17:55:33 +0200 Subject: [PATCH] Add exclude_bots option to log channels --- backend/src/plugins/Logs/types.ts | 1 + backend/src/plugins/Logs/util/log.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/backend/src/plugins/Logs/types.ts b/backend/src/plugins/Logs/types.ts index 6545b595..11d87e37 100644 --- a/backend/src/plugins/Logs/types.ts +++ b/backend/src/plugins/Logs/types.ts @@ -20,6 +20,7 @@ const LogChannel = t.partial({ excluded_message_regexes: t.array(TRegex), excluded_channels: t.array(t.string), excluded_categories: t.array(t.string), + exclude_bots: t.boolean, 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 f5aab896..852a224e 100644 --- a/backend/src/plugins/Logs/util/log.ts +++ b/backend/src/plugins/Logs/util/log.ts @@ -27,6 +27,15 @@ export async function log(pluginData: GuildPluginData, type: Log } } + // If we're excluding bots and the logged user is a bot, skip it + if (opts.exclude_bots) { + for (const prop of excludedUserProps) { + if (data && data[prop] && data[prop].bot) { + continue logChannelLoop; + } + } + } + // If this entry is from an excluded channel, skip it if (opts.excluded_channels) { if (