From ef97602d322dca23c58a51f323b6fd4ad27f3bf9 Mon Sep 17 00:00:00 2001 From: Essem Date: Mon, 20 Jun 2022 10:55:55 -0500 Subject: [PATCH] Get slash command attachments working on stable eris --- utils/imagedetect.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/imagedetect.js b/utils/imagedetect.js index 57f685a..c7c6310 100644 --- a/utils/imagedetect.js +++ b/utils/imagedetect.js @@ -34,7 +34,7 @@ const imageFormats = ["image/jpeg", "image/png", "image/webp", "image/gif", "lar const videoFormats = ["video/mp4", "video/webm", "video/mov"]; // gets the proper image paths -const getImage = async (image, image2, video, extraReturnTypes, gifv = false) => { +const getImage = async (image, image2, video, extraReturnTypes, gifv = false, type = null) => { try { const payload = { url: image2, @@ -73,10 +73,10 @@ const getImage = async (image, image2, video, extraReturnTypes, gifv = false) => } payload.type = "image/gif"; } else if (video) { - payload.type = await getType(payload.path, extraReturnTypes); + payload.type = type ?? await getType(payload.path, extraReturnTypes); if (!payload.type || (!videoFormats.includes(payload.type) && !imageFormats.includes(payload.type))) return; } else { - payload.type = await getType(payload.path, extraReturnTypes); + payload.type = type ?? await getType(payload.path, extraReturnTypes); if (!payload.type || !imageFormats.includes(payload.type)) return; } return payload; @@ -126,8 +126,8 @@ export default async (client, cmdMessage, interaction, options, extraReturnTypes // we can get a raw attachment or a URL in the interaction itself if (options) { if (options.image) { - const attachment = interaction.data.resolved.attachments.get(options.image); - const result = await getImage(attachment.proxyUrl, attachment.url, video); + const attachment = interaction.data.resolved.attachments[options.image]; + const result = await getImage(attachment.proxy_url, attachment.url, video, attachment.content_type); if (result !== false) return result; } else if (options.link) { const result = await getImage(options.link, options.link, video);