diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/parseQuery.ts b/src/equicordplugins/messageLoggerEnhanced/utils/parseQuery.ts index 6011fd06..0dd86b39 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/parseQuery.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/parseQuery.ts @@ -113,10 +113,10 @@ export const doesMatch = (type: typeof validIdSearchTypes[number], value: string case "attachment": return message.attachments.length > 0; case "image": - return message.attachments.some(a => a.content_type?.startsWith("image")) || + return message.attachments.some(a => a?.content_type?.startsWith("image")) || message.embeds.some(e => e.image || e.thumbnail); case "video": - return message.attachments.some(a => a.content_type?.startsWith("video")) || + return message.attachments.some(a => a?.content_type?.startsWith("video")) || message.embeds.some(e => e.video); case "embed": return message.embeds.length > 0; diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/saveImage/index.ts b/src/equicordplugins/messageLoggerEnhanced/utils/saveImage/index.ts index 27a37a59..4a1f159b 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/saveImage/index.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/saveImage/index.ts @@ -57,7 +57,7 @@ export function isAttachmentGoodToCache(attachment: MessageAttachment, fileExten export async function cacheMessageImages(message: LoggedMessage | LoggedMessageJSON) { try { for (const attachment of message.attachments) { - const fileExtension = getFileExtension(attachment.filename ?? attachment.url) ?? attachment.content_type?.split("/")?.[1] ?? ".png"; + const fileExtension = getFileExtension(attachment.filename ?? attachment.url) ?? attachment?.content_type?.split("/")?.[1] ?? ".png"; if (!isAttachmentGoodToCache(attachment, fileExtension)) { Flogger.log("skipping", attachment.filename); @@ -68,7 +68,7 @@ export async function cacheMessageImages(message: LoggedMessage | LoggedMessageJ attachment.oldProxyUrl = attachment.proxy_url; // only normal urls work if theres a charset in the content type /shrug - if (attachment.content_type?.includes(";")) { + if (attachment?.content_type?.includes(";")) { attachment.proxy_url = attachment.url; } else { // apparently proxy urls last longer