From dffbe4efb507835cd9aad7871d5e3f218444652f Mon Sep 17 00:00:00 2001 From: Palm Date: Mon, 13 Nov 2023 23:55:53 +0700 Subject: [PATCH] fix(bots-discord): exception when `Attachment#contentType` is null See: https://discord.js.org/docs/packages/discord.js/main/Attachment:Class#contentType --- apps/bot-discord/src/events/messageCreate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/bot-discord/src/events/messageCreate.js b/apps/bot-discord/src/events/messageCreate.js index d0fa5ea..fa4713c 100644 --- a/apps/bot-discord/src/events/messageCreate.js +++ b/apps/bot-discord/src/events/messageCreate.js @@ -14,7 +14,7 @@ export default { } 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') && !hasImmunity) { + if (msg.attachments.first()?.contentType?.startsWith('image') && !hasImmunity) { helper.scanImage(msg.attachments.first().url, `${msg.channelId}/${msg.id}`); }