Simplified and fixed image API, updated packages

This commit is contained in:
TheEssem 2020-10-06 14:48:22 -05:00
parent f1404a8393
commit ac4e1f5dd8
55 changed files with 135 additions and 161 deletions

View file

@ -18,50 +18,36 @@ const port = 3000;
const formats = ["image/jpeg", "image/png", "image/webp", "image/gif"];
function isValidJSON(json) {
try {
JSON.parse(json);
} catch (e) {
return false;
}
return true;
}
app.get("/", (req, res) => {
res.send(`esmBot v${version}`);
});
app.post("/:method", upload.single("image"), async (req, res, next) => {
app.post("/run", upload.single("image"), async (req, res, next) => {
const type = req.file ? (req.file.mimetype === "video/mp4" ? "image/gif" : req.file.mimetype) : "image/png";
if (!formats.includes(type)) {
return res.sendStatus(400);
}
const object = {
cmd: req.params.method,
path: req.file ? req.file.path : null,
type: type.split("/")[1],
delay: req.query.delay ? parseInt(req.query.delay) : 0
};
for (const param of Object.keys(req.query)) {
if (param === "delay") continue;
switch (param) {
case "sharp":
case "flop":
case "loop":
case "vertical":
case "first":
case "stretch":
case "wide":
case "soos":
case "slow":
case "resize":
case "append":
case "mc":
if (req.query[param] === "true") {
object[param] = true;
} else {
object[param] = false;
}
break;
default:
object[param] = req.query[param];
break;
}
}
if (!isValidJSON(req.body.data)) return res.sendStatus(400);
const object = JSON.parse(req.body.data);
if (!magick.check(object.cmd)) return res.sendStatus(400);
object.path = req.file ? req.file.path : null;
object.type = type.split("/")[1];
try {
const data = await magick(object, true);
const data = await magick.run(object, true);
res.contentType(type);
res.send(data);
} catch (e) {
next(e);

View file

@ -4,7 +4,7 @@ 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 a 9GAG watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/9gag.png",

View file

@ -4,7 +4,7 @@ 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 a Bandicam watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/bandicam.png",

View file

@ -4,7 +4,7 @@ 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 blur!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "blur",
path: image.path,
sharp: false,

View file

@ -4,7 +4,7 @@ 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 make blurple!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "blurple",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -6,7 +6,7 @@ exports.run = async (message, args) => {
const newArgs = args.filter(item => !item.includes(image.url) );
if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const outputFinal = await magick({
const outputFinal = await magick.run({
cmd: "caption",
path: image.path,
caption: newArgs.join(" "),

View file

@ -6,7 +6,7 @@ exports.run = async (message, args) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`;
const newArgs = args.filter(item => !item.includes(image.url) );
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const outputFinal = await magick({
const outputFinal = await magick.run({
cmd: "captionTwo",
path: image.path,
caption: newArgs.length !== 0 ? newArgs.join(" ") : words.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * words.length + 1)).join(" "),

View file

@ -4,7 +4,7 @@ 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 radial blur!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "circle",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 crop!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "crop",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 a DeviantArt watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/deviantart.png",

View file

@ -4,7 +4,7 @@ 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 explode!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "explode",
path: image.path,
amount: -1,

View file

@ -19,7 +19,7 @@ exports.run = async (message, args) => {
} catch (e) {
return `${message.author.mention}, that isn't a flag!`;
}
const buffer = await magick({
const buffer = await magick.run({
cmd: "flag",
path: image.path,
overlay: path,

View file

@ -4,7 +4,7 @@ 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 flip!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "flip",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 flop!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "flip",
path: image.path,
flop: true,

View file

@ -5,7 +5,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to freeze!`;
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "freeze",
path: image.path,
loop: false,

View file

@ -4,7 +4,7 @@ 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 New Funky Mode!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/funky.png",

View file

@ -4,7 +4,7 @@ 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 make a GameXplain thumbnail meme!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "gamexplain",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 = await magick({
const buffer = await magick.run({
cmd: "globe",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 mirror!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "mirror",
path: image.path,
first: true,

View file

@ -3,7 +3,7 @@ const magick = require("../utils/image.js");
exports.run = async (message, args) => {
if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a Homebrew Channel edit!`;
message.channel.sendTyping();
const buffer = await magick({
const buffer = await magick.run({
cmd: "homebrew",
caption: args.join(" ").toLowerCase().replace(/\n/g, " ")
});

View file

@ -4,7 +4,7 @@ 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 mirror!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "mirror",
path: image.path,
vertical: true,

View file

@ -4,7 +4,7 @@ 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 a Hypercam watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/hypercam.png",

View file

@ -4,7 +4,7 @@ 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 a iFunny watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/ifunny.png",

View file

@ -4,7 +4,7 @@ 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 implode!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "explode",
path: image.path,
amount: 1,

View file

@ -4,7 +4,7 @@ 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 invert!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "invert",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 = await magick({
const buffer = await magick.run({
cmd: "jpeg",
path: image.path
});

View file

@ -4,7 +4,7 @@ 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 make a Super Smash Bros. leak meme!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "leak",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -5,7 +5,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to loop!`;
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "freeze",
path: image.path,
loop: true,

View file

@ -4,7 +4,7 @@ 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 add some magik!`;
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const buffer = await magick({
const buffer = await magick.run({
cmd: "magik",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -7,7 +7,7 @@ exports.run = async (message, args) => {
const newArgs = args.filter(item => !item.includes(image.url) );
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a meme!`;
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
const buffer = await magick({
const buffer = 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;"),

View file

@ -4,7 +4,7 @@ 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 a MemeCenter watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/memecenter.png",

View file

@ -7,7 +7,7 @@ exports.run = async (message, args) => {
if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a motivational poster!`;
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
const buffer = await magick({
const buffer = 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;"),

View file

@ -4,7 +4,7 @@ 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 pixelate!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "resize",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -5,7 +5,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to reverse!`;
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "reverse",
path: image.path,
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0

View file

@ -4,7 +4,7 @@ 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 make a Scott the Woz TV meme!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "scott",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 sharpen!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "sharpen",
path: image.path,
sharp: true,

View file

@ -4,7 +4,7 @@ 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 a Shutterstock watermark!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "watermark",
path: image.path,
water: "./assets/images/shutterstock.png",

View file

@ -6,7 +6,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to slow down!`;
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "speed",
path: image.path,
slow: true,

View file

@ -5,7 +5,7 @@ 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 buffer = await magick({
const buffer = await magick.run({
cmd: "sonic",
text: wrap(cleanedMessage, {width: 15, indent: ""})
});

View file

@ -5,7 +5,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to loop!`;
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "reverse",
path: image.path,
soos: true,

View file

@ -5,7 +5,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide a GIF to speed up!`;
if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "speed",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 = await magick({
const buffer = await magick.run({
cmd: "spin",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 stretch!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "resize",
path: image.path,
stretch: true,

View file

@ -4,7 +4,7 @@ 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 swirl!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "swirl",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 tile!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "tile",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 make a Trump meme!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "trump",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 mirror!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "mirror",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 make a wall from!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "wall",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 make a "who did this" meme!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "wdt",
path: image.path,
type: image.type.toUpperCase(),

View file

@ -4,7 +4,7 @@ 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 stretch!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "resize",
path: image.path,
wide: true,

View file

@ -4,7 +4,7 @@ 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 mirror!`;
const buffer = await magick({
const buffer = await magick.run({
cmd: "mirror",
path: image.path,
vertical: true,

116
package-lock.json generated
View file

@ -69,9 +69,9 @@
"integrity": "sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM="
},
"@types/node": {
"version": "14.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.1.tgz",
"integrity": "sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ=="
"version": "14.11.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.5.tgz",
"integrity": "sha512-jVFzDV6NTbrLMxm4xDSIW/gKnk8rQLF9wAzLWIOg+5nU6ACrIMndeBdXci0FGtqJbP9tQvm6V39eshc96TO2wQ=="
},
"abort-controller": {
"version": "3.0.0",
@ -224,39 +224,12 @@
}
},
"bl": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz",
"integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz",
"integrity": "sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g==",
"requires": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",
"readable-stream": "^3.4.0"
},
"dependencies": {
"buffer": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
"integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
}
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
}
},
"bluebird": {
@ -1847,9 +1820,9 @@
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
},
"moment": {
"version": "2.27.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz",
"integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ=="
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"moment-duration-format": {
"version": "2.3.2",
@ -1857,37 +1830,26 @@
"integrity": "sha512-cBMXjSW+fjOb4tyaVHuaVE/A5TqkukDWiOfxxAjY+PEqmmBQlLwn+8OzwPiG3brouXKY5Un4pBjAeB6UToXHaQ=="
},
"mongodb": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.0.tgz",
"integrity": "sha512-/XWWub1mHZVoqEsUppE0GV7u9kanLvHxho6EvBxQbShXTKYF9trhZC2NzbulRGeG7xMJHD8IOWRcdKx5LPjAjQ==",
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.2.tgz",
"integrity": "sha512-sSZOb04w3HcnrrXC82NEh/YGCmBuRgR+C1hZgmmv4L6dBz4BkRse6Y8/q/neXer9i95fKUBbFi4KgeceXmbsOA==",
"requires": {
"bl": "^2.2.0",
"bl": "^2.2.1",
"bson": "^1.1.4",
"denque": "^1.4.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2",
"saslprep": "^1.0.0"
},
"dependencies": {
"bl": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz",
"integrity": "sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g==",
"requires": {
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
}
}
}
},
"mongoose": {
"version": "5.10.2",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.2.tgz",
"integrity": "sha512-VO5eZawEMFh2gx9XPg9ZafzFg5eIVs4R7PW6kK1MFqBq34YD7GomkalYWVt02HctvTPDI1mkXsm52LXNZR1NxA==",
"version": "5.10.8",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.8.tgz",
"integrity": "sha512-hbpFhOU6rWkWPkekUeSJxqWwzsjVQZ9xPg4WmWA1HJ8YDvjyNye1xbp82fw67BpnyvcjHxyU3/YhujsOCx55yw==",
"requires": {
"bson": "^1.1.4",
"kareem": "2.3.1",
"mongodb": "3.6.0",
"mongodb": "3.6.2",
"mongoose-legacy-pluralize": "1.0.2",
"mpath": "0.7.0",
"mquery": "3.2.2",
@ -2012,9 +1974,9 @@
}
},
"node-addon-api": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.1.tgz",
"integrity": "sha512-YUpjl57P55u2yUaKX5Bgy4t5s6SCNYMg+62XNg+k41aYbBL1NgWrZfcgljR5MxDxHDjzl0qHDNtH6SkW4DXNCA=="
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.2.tgz",
"integrity": "sha512-+D4s2HCnxPd5PjjI0STKwncjXTUKKqm74MDMz9OPXavjsGmjkvwgLtA5yoxJUdmpj52+2u+RrXgPipahKczMKg=="
},
"node-emoji": {
"version": "1.10.0",
@ -2641,13 +2603,13 @@
"optional": true
},
"sharp": {
"version": "0.26.0",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.26.0.tgz",
"integrity": "sha512-MNldekb9ZnliJAD+qP6uBTf3Wd6HaDVhKYbxXG+SQDvit9fa+2X4wECJvMRF8FLdY4saojrz3BHsnt4OmJw7xg==",
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.26.1.tgz",
"integrity": "sha512-9MhwS4ys8pnwBH7MtnBdLzUv+cb24QC4xbzzQL6A+1MQ4Se2V6oPHEX8TIGIZUPRKi6S1kJPVNzt/Xqqp6/H3Q==",
"requires": {
"color": "^3.1.2",
"detect-libc": "^1.0.3",
"node-addon-api": "^3.0.0",
"node-addon-api": "^3.0.2",
"npmlog": "^4.1.2",
"prebuild-install": "^5.3.5",
"semver": "^7.3.2",
@ -2899,6 +2861,32 @@
"readable-stream": "^3.1.1"
},
"dependencies": {
"bl": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz",
"integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==",
"requires": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",
"readable-stream": "^3.4.0"
},
"dependencies": {
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
}
}
},
"buffer": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
"integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",

View file

@ -34,17 +34,17 @@
"form-data": "^3.0.0",
"jsqr": "^1.3.1",
"lavacord": "^1.1.9",
"moment": "^2.27.0",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"mongoose": "^5.10.2",
"node-addon-api": "^3.0.1",
"mongoose": "^5.10.8",
"node-addon-api": "^3.0.2",
"node-emoji": "^1.10.0",
"node-fetch": "^2.6.1",
"node-tweet": "^0.1.4",
"puppeteer-core": "^2.1.1",
"qrcode": "^1.4.4",
"retrotext": "github:TheEssem/retrotext",
"sharp": "^0.26.0",
"sharp": "^0.26.1",
"winston": "^3.3.3"
},
"devDependencies": {

View file

@ -11,8 +11,7 @@ const client = new Client(process.env.TOKEN, {
GUILD_ROLE_CREATE: true,
GUILD_ROLE_DELETE: true,
GUILD_ROLE_UPDATE: true,
TYPING_START: true,
USER_UPDATE: true
TYPING_START: true
},
maxShards: "auto"
});

View file

@ -4,22 +4,23 @@ const { promisify } = require("util");
const FormData = require("form-data");
const fs = require("fs");
module.exports = async (object, fromAPI = false) => {
exports.run = async (object, fromAPI = false) => {
if (process.env.API === "true" && !fromAPI) {
const params = [];
for (const element of Object.keys(object)) {
params.push(`${element}=${encodeURIComponent(object[element])}`);
}
const form = new FormData();
form.append("data", JSON.stringify(object));
if (object.path) form.append("image", fs.createReadStream(object.path));
const req = await fetch(`${process.env.API_URL}/${object.cmd}?${params.join("&")}`, {
const req = await fetch(`${process.env.API_URL}/run`, {
method: "POST",
body: form,
headers: form.getHeaders()
});
return object.cmd === "qrread" ? await req.json() : await req.buffer();
return await req.buffer();
} else {
const data = await promisify(magick[object.cmd])(object);
return data;
}
};
exports.check = (cmd) => {
return magick[cmd] ? true : false;
};