Fixed GIF-only commands
This commit is contained in:
parent
cf5c649384
commit
5e34e45ac4
1 changed files with 8 additions and 9 deletions
|
@ -3,23 +3,22 @@ const fetch = require("node-fetch");
|
||||||
// gets the proper image paths
|
// gets the proper image paths
|
||||||
const getImage = async (image, image2, gifv = false) => {
|
const getImage = async (image, image2, gifv = false) => {
|
||||||
try {
|
try {
|
||||||
let requestImage = image;
|
const payload = {
|
||||||
|
url: image2,
|
||||||
|
path: image
|
||||||
|
};
|
||||||
if (gifv) {
|
if (gifv) {
|
||||||
if (image2.includes("tenor.com") && process.env.TENOR !== "") {
|
if (image2.includes("tenor.com") && process.env.TENOR !== "") {
|
||||||
const data = await fetch(`https://api.tenor.com/v1/gifs?ids=${image2.split("-").pop()}&key=${process.env.TENOR}`);
|
const data = await fetch(`https://api.tenor.com/v1/gifs?ids=${image2.split("-").pop()}&key=${process.env.TENOR}`);
|
||||||
const json = await data.json();
|
const json = await data.json();
|
||||||
console.log(json.results[0].media[0].gif.url);
|
payload.path = json.results[0].media[0].gif.url;
|
||||||
requestImage = json.results[0].media[0].gif.url;
|
|
||||||
} else if (image2.includes("giphy.com")) {
|
} else if (image2.includes("giphy.com")) {
|
||||||
requestImage = `https://media0.giphy.com/media/${image2.split("-").pop()}/giphy.gif`;
|
payload.path = `https://media0.giphy.com/media/${image2.split("-").pop()}/giphy.gif`;
|
||||||
} else if (image2.includes("imgur.com")) {
|
} else if (image2.includes("imgur.com")) {
|
||||||
requestImage = image.replace(".mp4", ".gif");
|
payload.path = image.replace(".mp4", ".gif");
|
||||||
}
|
}
|
||||||
|
payload.type = "gif";
|
||||||
}
|
}
|
||||||
const payload = {
|
|
||||||
url: image2,
|
|
||||||
path: requestImage
|
|
||||||
};
|
|
||||||
return payload;
|
return payload;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name === "AbortError") {
|
if (error.name === "AbortError") {
|
||||||
|
|
Loading…
Reference in a new issue