From c3a1de0d601c136a0c38fd5134880239315c6374 Mon Sep 17 00:00:00 2001 From: Essem Date: Thu, 23 Jun 2022 18:44:10 -0500 Subject: [PATCH] Update to Tenor API v2 (you'll need to get a new key) --- utils/imagedetect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/imagedetect.js b/utils/imagedetect.js index c7c6310..99423c3 100644 --- a/utils/imagedetect.js +++ b/utils/imagedetect.js @@ -46,7 +46,7 @@ const getImage = async (image, image2, video, extraReturnTypes, gifv = false, ty // Tenor doesn't let us access a raw GIF without going through their API, // so we use that if there's a key in the config if (process.env.TENOR !== "") { - const data = await fetch(`https://g.tenor.com/v1/gifs?ids=${image2.split("-").pop()}&media_filter=minimal&limit=1&key=${process.env.TENOR}`); + const data = await fetch(`https://tenor.googleapis.com/v2/posts?ids=${image2.split("-").pop()}&media_filter=gif&limit=1&key=${process.env.TENOR}`); if (data.status === 429) { if (extraReturnTypes) { payload.type = "tenorlimit"; @@ -57,7 +57,7 @@ const getImage = async (image, image2, video, extraReturnTypes, gifv = false, ty } const json = await data.json(); if (json.error) throw Error(json.error); - payload.path = json.results[0].media[0].gif.url; + payload.path = json.results[0].media_formats.gif.url; } } else if (giphyURLs.includes(host)) { // Can result in an HTML page instead of a GIF