From 4f0571681d2fcde5712c7091bf2dcf5924c20e9d Mon Sep 17 00:00:00 2001 From: reis Date: Thu, 24 Aug 2023 14:40:00 +0300 Subject: [PATCH] fix(bot-discord): fix immunity check --- apps/bot-discord/src/events/messageCreate.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/bot-discord/src/events/messageCreate.js b/apps/bot-discord/src/events/messageCreate.js index 1f36d33..d0fa5ea 100644 --- a/apps/bot-discord/src/events/messageCreate.js +++ b/apps/bot-discord/src/events/messageCreate.js @@ -12,17 +12,18 @@ export default { await command.execute(msg, args, config); } } - if (msg.member.roles.cache.some(role => role.id === config.discord.ignoreRole)) return; + const hasImmunity = msg.member.roles.cache.some(role => role.id === config.discord.ignoreRole); if (config.discord.ignoreChannels.includes(msg.channelId)) return; - if (msg.attachments.first() && msg.attachments.first().contentType.startsWith('image')) { + if (msg.attachments.first() && msg.attachments.first().contentType.startsWith('image') && !hasImmunity) { helper.scanImage(msg.attachments.first().url, `${msg.channelId}/${msg.id}`); } - if (!msg.content) return; - helper.scanText( - msg.content.toLowerCase().replace(/<.*?>/g, ''), - `${msg.channelId}/${msg.id}` - ); + if (msg.content && !hasImmunity) { + helper.scanText( + msg.content.toLowerCase().replace(/<.*?>/g, ''), + `${msg.channelId}/${msg.id}` + ); + } // Sticky message if (msg.channel.id !== config.sticky.channelId) return;