From a72750b8d89e392e10a874c2ccdd0bcb734a0bf8 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 24 May 2021 20:43:46 +0300 Subject: [PATCH] logs: fix excluded_roles for messages --- backend/src/plugins/Logs/util/log.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/src/plugins/Logs/util/log.ts b/backend/src/plugins/Logs/util/log.ts index 7c205579..7499c0c4 100644 --- a/backend/src/plugins/Logs/util/log.ts +++ b/backend/src/plugins/Logs/util/log.ts @@ -5,6 +5,7 @@ import { TextChannel } from "eris"; import { createChunkedMessage, get, noop } from "../../../utils"; import { getLogMessage } from "./getLogMessage"; import { allowTimeout } from "../../../RegExpRunner"; +import { SavedMessage } from "../../../data/entities/SavedMessage"; const excludedUserProps = ["user", "member", "mod"]; const excludedRoleProps = ["message.member.roles", "member.roles"]; @@ -42,6 +43,15 @@ export async function log(pluginData: GuildPluginData, type: Log } if (opts.excluded_roles) { + if (data?.message instanceof SavedMessage) { + const member = pluginData.guild.members.get(data.message.user_id); + for (const role of member?.roles || []) { + if (opts.excluded_roles.includes(role)) { + continue logChannelLoop; + } + } + } + for (const prop of excludedRoleProps) { const roles = get(data, prop); if (!isRoleArray(roles)) {