Fix case-insensitive gfycat links in slash commands

This commit is contained in:
Essem 2022-08-26 14:54:26 -05:00
parent 7c1cbbc54b
commit 4e3e420875
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C

View file

@ -75,8 +75,15 @@ const getImage = async (image, image2, video, extraReturnTypes, gifv = false, ty
payload.path = image.replace(".mp4", ".gif");
} else if (gfycatURLs.includes(host)) {
// iirc Gfycat also seems to sometimes make GIFs static
if (link) {
const data = await request(`https://api.gfycat.com/v1/gfycats/${image.split("/").pop().split(".mp4")[0]}`);
const json = await data.body.json();
if (json.errorMessage) throw Error(json.errorMessage);
payload.path = json.gfyItem.gifUrl;
} else {
payload.path = `https://thumbs.gfycat.com/${image.split("/").pop().split(".mp4")[0]}-size_restricted.gif`;
}
}
payload.type = "image/gif";
} else if (video) {
payload.type = type ?? await getType(payload.path, extraReturnTypes);