Make the bot itself get the image file type again

This commit is contained in:
TheEssem 2021-01-04 20:53:34 -06:00
parent 10ee3c6a31
commit 9f2bd1fecb
51 changed files with 108 additions and 55 deletions

View file

@ -73,8 +73,7 @@ if (isMainThread) {
console.error(`Worker ${uuid} stopped with exit code ${code}`);
}
});
worker.postMessage({
uuid: uuid,
msg: jobs[uuid].msg,

View file

@ -8,7 +8,8 @@ exports.run = async (message) => {
cmd: "watermark",
path: image.path,
water: "./assets/images/9gag.png",
gravity: 6
gravity: 6,
type: image.type
});
return {
file: buffer,

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
water: "./assets/images/bandicam.png",
gravity: 2,
resize: true
resize: true,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "blur",
path: image.path,
sharp: false
sharp: false,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make blurple!`;
const { buffer, type } = await magick.run({
cmd: "blurple",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -9,7 +9,8 @@ exports.run = async (message, args) => {
const { buffer, type } = await magick.run({
cmd: "caption",
path: image.path,
caption: newArgs.join(" ").replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;")
caption: newArgs.join(" ").replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%"),
type: image.type
});
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
return {

View file

@ -9,7 +9,8 @@ exports.run = async (message, args) => {
const { buffer, type } = await magick.run({
cmd: "captionTwo",
path: image.path,
caption: newArgs.length !== 0 ? newArgs.join(" ").replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;") : words.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * words.length + 1)).join(" ")
caption: newArgs.length !== 0 ? newArgs.join(" ").replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%") : words.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * words.length + 1)).join(" "),
type: image.type
});
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
return {

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to add radial blur!`;
const { buffer, type} = await magick.run({
cmd: "circle",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to crop!`;
const { buffer, type } = await magick.run({
cmd: "crop",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
water: "./assets/images/deviantart.png",
gravity: 5,
resize: true
resize: true,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "explode",
path: image.path,
amount: -1
amount: -1,
type: image.type
});
return {
file: buffer,

View file

@ -22,7 +22,8 @@ exports.run = async (message, args) => {
const { buffer, type } = await magick.run({
cmd: "flag",
path: image.path,
overlay: path
overlay: path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to flip!`;
const { buffer, type } = await magick.run({
cmd: "flip",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "flip",
path: image.path,
flop: true
flop: true,
type: image.type
});
return {
file: buffer,

View file

@ -8,7 +8,8 @@ exports.run = async (message) => {
cmd: "freeze",
path: image.path,
loop: false,
onlyGIF: true
onlyGIF: true,
type: image.type
});
if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
return {

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
water: "./assets/images/funky.png",
gravity: 3,
resize: true
resize: true,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a GameXplain thumbnail meme!`;
const { buffer, type } = await magick.run({
cmd: "gamexplain",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const { buffer } = await magick.run({
cmd: "globe",
path: image.path
path: image.path,
type: image.type
});
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
return {

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "mirror",
path: image.path,
first: true
first: true,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "mirror",
path: image.path,
vertical: true
vertical: true,
type: image.type
});
return {
file: buffer,

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
water: "./assets/images/hypercam.png",
gravity: 1,
resize: true
resize: true,
type: image.type
});
return {
file: buffer,

View file

@ -10,7 +10,8 @@ exports.run = async (message) => {
water: "./assets/images/ifunny.png",
gravity: 8,
resize: true,
append: true
append: true,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "explode",
path: image.path,
amount: 1
amount: 1,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to invert!`;
const { buffer, type } = await magick.run({
cmd: "invert",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -4,9 +4,10 @@ exports.run = async (message) => {
message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to add more JPEG!`;
const { buffer, type } = await magick.run({
const { buffer } = await magick.run({
cmd: "jpeg",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Super Smash Bros. leak meme!`;
const { buffer, type } = await magick.run({
cmd: "leak",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const { buffer, type } = await magick.run({
cmd: "magik",
path: image.path
path: image.path,
type: image.type
});
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
return {

View file

@ -10,8 +10,9 @@ exports.run = async (message, args) => {
const { buffer, type } = await magick.run({
cmd: "meme",
path: image.path,
top: topText.toUpperCase().replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;"),
bottom: bottomText ? bottomText.toUpperCase().replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;") : ""
top: topText.toUpperCase().replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%"),
bottom: bottomText ? bottomText.toUpperCase().replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%") : "",
type: image.type
});
return {
file: buffer,

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
water: "./assets/images/memecenter.png",
gravity: 9,
mc: true
mc: true,
type: image.type
});
return {
file: buffer,

View file

@ -10,8 +10,9 @@ exports.run = async (message, args) => {
const { buffer, type } = await magick.run({
cmd: "motivate",
path: image.path,
top: topText.replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;"),
bottom: bottomText ? bottomText.replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;") : ""
top: topText.replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%"),
bottom: bottomText ? bottomText.replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%") : "",
type: image.type
});
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
return {

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to pixelate!`;
const { buffer, type } = await magick.run({
cmd: "resize",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -8,7 +8,8 @@ exports.run = async (message) => {
cmd: "reverse",
path: image.path,
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0,
onlyGIF: true
onlyGIF: true,
type: image.type
});
if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
return {

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Scott the Woz TV meme!`;
const { buffer, type } = await magick.run({
cmd: "scott",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "blur",
path: image.path,
sharp: true
sharp: true,
type: image.type
});
return {
file: buffer,

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
water: "./assets/images/shutterstock.png",
gravity: 5,
resize: true
resize: true,
type: image.type
});
return {
file: buffer,

View file

@ -8,7 +8,8 @@ exports.run = async (message) => {
cmd: "speed",
path: image.path,
slow: true,
onlyGIF: true
onlyGIF: true,
type: image.type
});
if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
return {

View file

@ -4,7 +4,7 @@ const wrap = require("../utils/wrap.js");
exports.run = async (message, args) => {
if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a Sonic meme!`;
message.channel.sendTyping();
const cleanedMessage = args.join(" ").replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;");
const cleanedMessage = args.join(" ").replace(/&/g, "\\&amp;").replace(/>/g, "\\&gt;").replace(/</g, "\\&lt;").replace(/"/g, "\\&quot;").replace(/'/g, "\\&apos;").replace(/%/g, "\\%");
const { buffer } = await magick.run({
cmd: "sonic",
text: wrap(cleanedMessage, {width: 15, indent: ""})

View file

@ -9,7 +9,8 @@ exports.run = async (message) => {
path: image.path,
soos: true,
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0,
onlyGIF: true
onlyGIF: true,
type: image.type
});
if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
return {

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "speed",
path: image.path,
onlyGIF: true
onlyGIF: true,
type: image.type
});
if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
return {

View file

@ -4,9 +4,10 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to spin!`;
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const { buffer, type } = await magick.run({
const { buffer } = await magick.run({
cmd: "spin",
path: image.path
path: image.path,
type: image.type
});
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
return {

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "resize",
path: image.path,
stretch: true
stretch: true,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to swirl!`;
const { buffer, type } = await magick.run({
cmd: "swirl",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to tile!`;
const { buffer, type } = await magick.run({
cmd: "tile",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Trump meme!`;
const { buffer, type } = await magick.run({
cmd: "trump",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -8,7 +8,8 @@ exports.run = async (message) => {
cmd: "freeze",
path: image.path,
loop: true,
onlyGIF: true
onlyGIF: true,
type: image.type
});
if (buffer === "nogif") return `${message.author.mention}, that isn't a GIF!`;
return {

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`;
const { buffer, type } = await magick.run({
cmd: "mirror",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a wall from!`;
const { buffer, type } = await magick.run({
cmd: "wall",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -6,7 +6,8 @@ exports.run = async (message) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a "who did this" meme!`;
const { buffer, type } = await magick.run({
cmd: "wdt",
path: image.path
path: image.path,
type: image.type
});
return {
file: buffer,

View file

@ -7,7 +7,8 @@ exports.run = async (message) => {
const { buffer, type } = await magick.run({
cmd: "resize",
path: image.path,
wide: true
wide: true,
type: image.type
});
return {
file: buffer,

View file

@ -8,7 +8,8 @@ exports.run = async (message) => {
cmd: "mirror",
path: image.path,
vertical: true,
first: true
first: true,
type: image.type
});
return {
file: buffer,

View file

@ -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) {