Removed extra image request for image commands, various other tweaks
This commit is contained in:
parent
4439fca6d3
commit
ef071a39d4
39 changed files with 67 additions and 156 deletions
|
@ -2,16 +2,13 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a 9GAG watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/9gag.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("East");
|
||||
const data = gm(image.data).composite(watermark).gravity("East");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a Bandicam watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/bandicam.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("North").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("North").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 blur!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).blur(5).toBuffer();
|
||||
const resultBuffer = await sharp(image.data).blur(5).toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `blur.${image.type}`
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 make blurple!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
|
||||
const data = gm(image.data).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 radial blur!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).out("-radial-blur", 10);
|
||||
const data = gm(image.data).out("-radial-blur", 10);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a DeviantArt watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/deviantart.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 explode!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).implode([-2]);
|
||||
const data = gm(image.data).implode([-2]);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 flip!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).flip().toBuffer();
|
||||
const resultBuffer = await sharp(image.data).flip().toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `flip.${image.type}`
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 flop!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).flop().toBuffer();
|
||||
const resultBuffer = await sharp(image.data).flop().toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: `flop.${image.type}`
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 New Funky Mode!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/funky.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("NorthEast").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("NorthEast").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,10 +9,8 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a GameXplain thumbnail meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/gamexplain.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("-background").out("white").out("-gravity").out("Center").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("1181x571!").out(")").out("-geometry").out("+0+40").out("-composite").out(")").out("+swap").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
return message.channel.createMessage("", {
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("West").crop("50%", 0).strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("West").crop("50%", 0).strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flop().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("South").crop(0, "50%").strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("South").crop(0, "50%").strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flip().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a Hypercam watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/hypercam.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).composite(watermark).gravity("NorthWest").resize(null, size.height);
|
||||
const data = gm(image.data).composite(watermark).gravity("NorthWest").resize(null, size.height);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,18 +2,15 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a iFunny watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/ifunny.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const data = gm(imageBuffer).append(watermark).gravity("South").resize(size.width, null);
|
||||
const data = gm(image.data).append(watermark).gravity("South").resize(size.width, null);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 implode!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).implode([1]);
|
||||
const data = gm(image.data).implode([1]);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 invert!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).negative();
|
||||
const data = gm(image.data).negative();
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 more JPEG!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).setFormat("jpg").quality(1);
|
||||
const data = gm(image.data).setFormat("jpg").quality(1);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).resize(800, 800).stream((error, stream) => {
|
||||
gm(image.data).resize(800, 800).stream((error, stream) => {
|
||||
if (error) console.error;
|
||||
gm(stream).out("-liquid-rescale", "400x400").stream(async (error, stream2) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
const { spawn } = require("child_process");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
const image = await require("../utils/imagedetect.js")(message);
|
||||
if (image === undefined) return `${message.author.mention}, you need to provide an image to generate a meme!`;
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a meme!`;
|
||||
message.channel.sendTyping();
|
||||
const request = await fetch(image.url);
|
||||
const buffer = await request.buffer();
|
||||
const [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
|
||||
const child = spawn("./utils/meme.sh", [topText.toUpperCase().replace(/\\/g, "\\\\"), bottomText ? bottomText.toUpperCase().replace(/\\/g, "\\\\") : ""]);
|
||||
child.stdin.write(buffer);
|
||||
child.stdin.write(image.data);
|
||||
child.stdin.end();
|
||||
const chunks = [];
|
||||
child.stdout.on("data", (data) => {
|
||||
|
|
|
@ -2,20 +2,17 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a MemeCenter watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/memecenter.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
let resultBuffer;
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const command = gm(imageBuffer).out(watermark).background("#FFFFFF").gravity("East").out("-smush").out("-9");
|
||||
const output = await gmToBuffer(command);
|
||||
const command = gm(image.data).out(watermark).background("#FFFFFF").gravity("East").out("-smush").out("-9");
|
||||
const output = await gmToBuffer(command, "png");
|
||||
gm(output).size(async (error, size2) => {
|
||||
if (error) console.error;
|
||||
resultBuffer = output;
|
||||
|
@ -25,7 +22,7 @@ exports.run = async (message) => {
|
|||
}
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "memecenter.png"
|
||||
name: `memecenter.${image.type}`
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,9 +11,9 @@ exports.run = async (message) => {
|
|||
inlineVolume: true
|
||||
});
|
||||
connection.setVolume(0.5);
|
||||
connection.on("error", () => {
|
||||
connection.on("error", (error) => {
|
||||
voiceChannel.leave();
|
||||
console.error;
|
||||
throw error;
|
||||
});
|
||||
connection.on("end", () => {
|
||||
voiceChannel.leave();
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const fetch = require("node-fetch");
|
||||
const jsqr = require("jsqr");
|
||||
const sharp = require("sharp");
|
||||
|
||||
|
@ -6,9 +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 an image with a QR code to read it!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const rawData = await sharp(imageBuffer).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const rawData = await sharp(image.data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
return `\`\`\`\n${qrBuffer.data}\n\`\`\``;
|
||||
};
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,12 +9,10 @@ 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!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/scott.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("-gravity").out("Center").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("415x234!").out("+distort").out("Perspective").out("0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out("-geometry").out("-110+83").out(")").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "scott.png"
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sharp = require("sharp");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 sharpen!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const resultBuffer = await sharp(imageBuffer).sharpen(5).toBuffer();
|
||||
const resultBuffer = await sharp(image.data).sharpen(5).toBuffer();
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "sharpen.png"
|
||||
|
|
|
@ -2,22 +2,19 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 a Shutterstock watermark!`;
|
||||
message.channel.sendTyping();
|
||||
const watermark = "./assets/images/shutterstock.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).size(async (error, size) => {
|
||||
gm(image.data).size(async (error, size) => {
|
||||
if (error) console.error;
|
||||
const command = gm(imageBuffer).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const command = gm(image.data).composite(watermark).gravity("Center").resize(null, size.height);
|
||||
const output = await gmToBuffer(command);
|
||||
return message.channel.createMessage("", {
|
||||
file: output,
|
||||
name: "shutterstock.png"
|
||||
name: `shutterstock.${image.type}`
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ exports.run = async (message, args) => {
|
|||
gm(474, 332).out("+size").gravity("Center").out("-pointsize", 40).out("-font", "Bitstream Vera Sans").out(`pango:${wrap(cleanedMessage, {width: 15, indent: ""})}`).negative().out("-fuzz", "30%").transparent("black").write(file, async (error) => {
|
||||
if (error) console.error;
|
||||
const command = gm(template).composite(file).gravity("Center").geometry("474x332+160+10");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "sonic.png"
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 swirl!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = gm(imageBuffer).swirl(180);
|
||||
const data = gm(image.data).swirl(180);
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 tile!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
|
||||
gm(image.data).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
|
||||
if (error) console.error;
|
||||
const data = gm(output).resize("800x800>");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
|
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,12 +9,10 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Trump meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/trump.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).out("-background").out("none").out("-gravity").out("South").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("365x179!").out("+distort").out("Perspective").out("0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").out("-geometry").out("-25-1").out("-composite").out(")").out("+swap").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "trump.png"
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("East").crop("50%", 0).strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("East").crop("50%", 0).strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flop().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -2,15 +2,12 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 make a wall from!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
gm(imageBuffer).resize(128).stream(async (error, output) => {
|
||||
gm(image.data).resize(128).stream(async (error, output) => {
|
||||
if (error) console.error;
|
||||
const data = gm(output).virtualPixel("tile").matteColor("none").out("-background", "none").resize("512x512!").out("-distort").out("Perspective").out("0,0,57,42 0,128,63,130 128,0,140,60 128,128,140,140");
|
||||
const resultBuffer = await gmToBuffer(data);
|
||||
|
|
|
@ -2,7 +2,6 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
const fs = require("fs");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -10,12 +9,10 @@ exports.run = async (message) => {
|
|||
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a "who did this" meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/whodidthis.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).composite(path).gravity("Center").geometry("374x374+0+0");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
const resultBuffer = await gmToBuffer(command, "png");
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "wdt.png"
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
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 mirror!`;
|
||||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("North").crop(0, "50%").strip().write(data2, (error) => {
|
||||
gm(image.data).gravity("North").crop(0, "50%").strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flip().strip().write(data, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -101,7 +101,7 @@ module.exports = async (message) => {
|
|||
}
|
||||
} catch (error) {
|
||||
logger.error(error.stack);
|
||||
await client.createMessage(message.channel.id, "Uh oh! I ran into an error while running this command. Please report the content of the attached file here: <https://github.com/TheEssem/esmBot-rewrite/issues>", [{
|
||||
await client.createMessage(message.channel.id, "Uh oh! I ran into an error while running this command. Please report the content of the attached file here or on the esmBot Support server: <https://github.com/TheEssem/esmBot-rewrite/issues>", [{
|
||||
file: Buffer.from(`Message: ${error}\n\nStack Trace: ${error.stack}`),
|
||||
name: "error.txt"
|
||||
}]);
|
||||
|
|
|
@ -14,14 +14,14 @@ const typeCheck = async (image) => {
|
|||
// if it is, then return the url with the file type
|
||||
return {
|
||||
type: imageType.ext,
|
||||
url: image
|
||||
data: imageBuffer
|
||||
};
|
||||
} else {
|
||||
// if not, then return a message
|
||||
return "Not the correct file type";
|
||||
// if not, then return false
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
if (error) console.error;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,7 @@ module.exports = async (cmdMessage) => {
|
|||
// get type of file
|
||||
const type = await typeCheck(message.attachments[0].url);
|
||||
// move to the next message if the file isn't an image
|
||||
if (type === "Not the correct file type") continue;
|
||||
if (type === false) continue;
|
||||
// if the file is an image then return it
|
||||
return type;
|
||||
// if there's nothing in the attachments check the embeds next
|
||||
|
@ -44,12 +44,12 @@ module.exports = async (cmdMessage) => {
|
|||
// embeds can have 2 possible entries with images, we check the thumbnail first
|
||||
if (message.embeds[0].thumbnail) {
|
||||
const type = await typeCheck(message.embeds[0].thumbnail.url);
|
||||
if (type === "Not the correct file type") continue;
|
||||
if (type === false) continue;
|
||||
return type;
|
||||
// if there isn't a thumbnail check the image area
|
||||
} else if (message.embeds[0].image) {
|
||||
const type = await typeCheck(message.embeds[0].image.url);
|
||||
if (type === "Not the correct file type") continue;
|
||||
if (type === false) continue;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ const logger = winston.createLogger({
|
|||
format: winston.format.printf(log => `[${moment().format("YYYY-MM-DD HH:mm:ss")}]: [${log.level.toUpperCase()}] - ${log.message}`)
|
||||
});
|
||||
|
||||
exports.log = (type, content) => content ? logger.log(type, content) : logger.log("info", content);
|
||||
exports.log = (type, content) => content ? logger.log(type, content) : logger.log("info", type);
|
||||
|
||||
exports.error = (...args) => this.log("error", ...args);
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ exports.clean = async (text) => {
|
|||
.replace(config.catToken, "<redacted>")
|
||||
.replace(config.googleKey, "<redacted>")
|
||||
.replace(config.cseID, "<redacted>")
|
||||
.replace(config.dblToken, "<redacted>");
|
||||
.replace(config.dblToken, "<redacted>")
|
||||
.replace(config.mongoURL, "<redacted>");
|
||||
|
||||
return text;
|
||||
};
|
||||
|
|
|
@ -6,18 +6,24 @@ module.exports = async (sound, message) => {
|
|||
if (message.member.voiceState.channelID) {
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("voiceConnect") || !message.channel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I can't join this voice channel!`);
|
||||
const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
|
||||
client.createMessage(message.channel.id, "🔊 Playing sound...");
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I don't have permission to join this voice channel!`);
|
||||
const playingMessage = await client.createMessage(message.channel.id, "🔊 Playing sound...");
|
||||
const connection = await client.joinVoiceChannel(voiceChannel.id);
|
||||
console.log(connection.current);
|
||||
if (connection.playing) {
|
||||
connection.stopPlaying();
|
||||
connection.play(fs.createReadStream(sound));
|
||||
} else {
|
||||
connection.play(fs.createReadStream(sound));
|
||||
}
|
||||
connection.play(fs.createReadStream(sound));
|
||||
connection.on("error", (error) => {
|
||||
voiceChannel.leave();
|
||||
playingMessage.delete();
|
||||
logger.error(error);
|
||||
});
|
||||
connection.once("end", () => {
|
||||
voiceChannel.leave();
|
||||
playingMessage.delete();
|
||||
});
|
||||
} else {
|
||||
client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);
|
||||
|
|
Loading…
Reference in a new issue