fix(bots-discord): exception when Attachment#contentType is null

See: https://discord.js.org/docs/packages/discord.js/main/Attachment:Class#contentType
This commit is contained in:
Palm
2023-11-13 23:55:53 +07:00
committed by GitHub
parent 4c1a2d6ac4
commit dffbe4efb5

View File

@@ -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}`);
}