Make the bot itself get the image file type again
This commit is contained in:
parent
10ee3c6a31
commit
9f2bd1fecb
51 changed files with 108 additions and 55 deletions
|
@ -1,6 +1,7 @@
|
|||
const client = require("./client.js");
|
||||
const fetch = require("node-fetch");
|
||||
const url = require("url");
|
||||
const { getType } = require("./image.js");
|
||||
const execPromise = require("util").promisify(require("child_process").exec);
|
||||
|
||||
const tenorURLs = [
|
||||
|
@ -17,6 +18,8 @@ const imgurURLs = [
|
|||
"i.imgur.com"
|
||||
];
|
||||
|
||||
const formats = ["image/jpeg", "image/png", "image/webp", "image/gif"];
|
||||
|
||||
// gets the proper image paths
|
||||
const getImage = async (image, image2, gifv = false) => {
|
||||
try {
|
||||
|
@ -41,6 +44,9 @@ const getImage = async (image, image2, gifv = false) => {
|
|||
payload.path = image.replace(".mp4", ".gif");
|
||||
}
|
||||
payload.type = "image/gif";
|
||||
} else {
|
||||
payload.type = await getType(payload.path);
|
||||
if (!payload.type || !formats.includes(payload.type)) return;
|
||||
}
|
||||
return payload;
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue