Removed extra image request for image commands, various other tweaks

This commit is contained in:
TheEssem 2019-11-11 14:54:19 -06:00
parent 4439fca6d3
commit ef071a39d4
39 changed files with 67 additions and 156 deletions

View File

@ -2,16 +2,13 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a 9GAG watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/9gag.png"; const watermark = "./assets/images/9gag.png";
const imageData = await fetch(image.url); const data = gm(image.data).composite(watermark).gravity("East");
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).composite(watermark).gravity("East");
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,18 +2,15 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a Bandicam watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/bandicam.png"; const watermark = "./assets/images/bandicam.png";
const imageData = await fetch(image.url); gm(image.data).size(async (error, size) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).size(async (error, size) => {
if (error) console.error; 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); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -1,13 +1,10 @@
const sharp = require("sharp"); const sharp = require("sharp");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to blur!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to blur!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const resultBuffer = await sharp(image.data).blur(5).toBuffer();
const imageBuffer = await imageData.buffer();
const resultBuffer = await sharp(imageBuffer).blur(5).toBuffer();
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `blur.${image.type}` name: `blur.${image.type}`

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to make blurple!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add radial blur!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).out("-radial-blur", 10);
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).out("-radial-blur", 10);
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,18 +2,15 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a DeviantArt watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/deviantart.png"; const watermark = "./assets/images/deviantart.png";
const imageData = await fetch(image.url); gm(image.data).size(async (error, size) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).size(async (error, size) => {
if (error) console.error; 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); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to explode!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to explode!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).implode([-2]);
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).implode([-2]);
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -1,13 +1,10 @@
const sharp = require("sharp"); const sharp = require("sharp");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to flip!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to flip!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const resultBuffer = await sharp(image.data).flip().toBuffer();
const imageBuffer = await imageData.buffer();
const resultBuffer = await sharp(imageBuffer).flip().toBuffer();
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `flip.${image.type}` name: `flip.${image.type}`

View File

@ -1,13 +1,10 @@
const sharp = require("sharp"); const sharp = require("sharp");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to flop!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to flop!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const resultBuffer = await sharp(image.data).flop().toBuffer();
const imageBuffer = await imageData.buffer();
const resultBuffer = await sharp(imageBuffer).flop().toBuffer();
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: `flop.${image.type}` name: `flop.${image.type}`

View File

@ -2,18 +2,15 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add New Funky Mode!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/funky.png"; const watermark = "./assets/images/funky.png";
const imageData = await fetch(image.url); gm(image.data).size(async (error, size) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).size(async (error, size) => {
if (error) console.error; 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); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,7 +2,6 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
const fs = require("fs"); const fs = require("fs");
exports.run = async (message) => { 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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to make a GameXplain thumbnail meme!`;
message.channel.sendTyping(); message.channel.sendTyping();
const template = "./assets/images/gamexplain.png"; 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}`; 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 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); const resultBuffer = await gmToBuffer(command);
return message.channel.createMessage("", { return message.channel.createMessage("", {

View File

@ -3,17 +3,14 @@
const gm = require("gm").subClass({ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`;
message.channel.sendTyping(); 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
const data2 = `/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; if (error) console.error;
gm(data2).flop().strip().write(data, async (error) => { gm(data2).flop().strip().write(data, async (error) => {
if (error) console.error; if (error) console.error;

View File

@ -3,17 +3,14 @@
const gm = require("gm").subClass({ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`;
message.channel.sendTyping(); 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
const data2 = `/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; if (error) console.error;
gm(data2).flip().strip().write(data, async (error) => { gm(data2).flip().strip().write(data, async (error) => {
if (error) console.error; if (error) console.error;

View File

@ -2,18 +2,15 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a Hypercam watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/hypercam.png"; const watermark = "./assets/images/hypercam.png";
const imageData = await fetch(image.url); gm(image.data).size(async (error, size) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).size(async (error, size) => {
if (error) console.error; 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); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,18 +2,15 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a iFunny watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/ifunny.png"; const watermark = "./assets/images/ifunny.png";
const imageData = await fetch(image.url); gm(image.data).size(async (error, size) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).size(async (error, size) => {
if (error) console.error; 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); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to implode!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to implode!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).implode([1]);
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).implode([1]);
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to invert!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to invert!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).negative();
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).negative();
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add more JPEG!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).setFormat("jpg").quality(1);
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).setFormat("jpg").quality(1);
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; 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 processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const imageData = await fetch(image.url); gm(image.data).resize(800, 800).stream((error, stream) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).resize(800, 800).stream((error, stream) => {
if (error) console.error; if (error) console.error;
gm(stream).out("-liquid-rescale", "400x400").stream(async (error, stream2) => { gm(stream).out("-liquid-rescale", "400x400").stream(async (error, stream2) => {
if (error) console.error; if (error) console.error;

View File

@ -1,16 +1,13 @@
const { spawn } = require("child_process"); const { spawn } = require("child_process");
const fetch = require("node-fetch");
exports.run = async (message, args) => { exports.run = async (message, args) => {
const image = await require("../utils/imagedetect.js")(message); 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 (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!`; if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a meme!`;
message.channel.sendTyping(); 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 [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
const child = spawn("./utils/meme.sh", [topText.toUpperCase().replace(/\\/g, "\\\\"), bottomText ? bottomText.toUpperCase().replace(/\\/g, "\\\\") : ""]); 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(); child.stdin.end();
const chunks = []; const chunks = [];
child.stdout.on("data", (data) => { child.stdout.on("data", (data) => {

View File

@ -2,20 +2,17 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a MemeCenter watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/memecenter.png"; const watermark = "./assets/images/memecenter.png";
const imageData = await fetch(image.url);
const imageBuffer = await imageData.buffer();
let resultBuffer; let resultBuffer;
gm(imageBuffer).size(async (error, size) => { gm(image.data).size(async (error, size) => {
if (error) console.error; if (error) console.error;
const command = gm(imageBuffer).out(watermark).background("#FFFFFF").gravity("East").out("-smush").out("-9"); const command = gm(image.data).out(watermark).background("#FFFFFF").gravity("East").out("-smush").out("-9");
const output = await gmToBuffer(command); const output = await gmToBuffer(command, "png");
gm(output).size(async (error, size2) => { gm(output).size(async (error, size2) => {
if (error) console.error; if (error) console.error;
resultBuffer = output; resultBuffer = output;
@ -25,7 +22,7 @@ exports.run = async (message) => {
} }
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: "memecenter.png" name: `memecenter.${image.type}`
}); });
}); });
}); });

View File

@ -11,9 +11,9 @@ exports.run = async (message) => {
inlineVolume: true inlineVolume: true
}); });
connection.setVolume(0.5); connection.setVolume(0.5);
connection.on("error", () => { connection.on("error", (error) => {
voiceChannel.leave(); voiceChannel.leave();
console.error; throw error;
}); });
connection.on("end", () => { connection.on("end", () => {
voiceChannel.leave(); voiceChannel.leave();

View File

@ -1,4 +1,3 @@
const fetch = require("node-fetch");
const jsqr = require("jsqr"); const jsqr = require("jsqr");
const sharp = require("sharp"); const sharp = require("sharp");
@ -6,9 +5,7 @@ exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image with a QR code to read it!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const rawData = await sharp(image.data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
const imageBuffer = await imageData.buffer();
const rawData = await sharp(imageBuffer).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height); const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
return `\`\`\`\n${qrBuffer.data}\n\`\`\``; return `\`\`\`\n${qrBuffer.data}\n\`\`\``;
}; };

View File

@ -2,7 +2,6 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
const fs = require("fs"); const fs = require("fs");
exports.run = async (message) => { 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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Scott the Woz TV meme!`;
message.channel.sendTyping(); message.channel.sendTyping();
const template = "./assets/images/scott.png"; 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}`; 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 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("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: "scott.png" name: "scott.png"

View File

@ -1,13 +1,10 @@
const sharp = require("sharp"); const sharp = require("sharp");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to sharpen!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to sharpen!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const resultBuffer = await sharp(image.data).sharpen(5).toBuffer();
const imageBuffer = await imageData.buffer();
const resultBuffer = await sharp(imageBuffer).sharpen(5).toBuffer();
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: "sharpen.png" name: "sharpen.png"

View File

@ -2,22 +2,19 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to add a Shutterstock watermark!`;
message.channel.sendTyping(); message.channel.sendTyping();
const watermark = "./assets/images/shutterstock.png"; const watermark = "./assets/images/shutterstock.png";
const imageData = await fetch(image.url); gm(image.data).size(async (error, size) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).size(async (error, size) => {
if (error) console.error; 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); const output = await gmToBuffer(command);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: output, file: output,
name: "shutterstock.png" name: `shutterstock.${image.type}`
}); });
}); });
}; };

View File

@ -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) => { 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; if (error) console.error;
const command = gm(template).composite(file).gravity("Center").geometry("474x332+160+10"); 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("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: "sonic.png" name: "sonic.png"

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to swirl!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to swirl!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); const data = gm(image.data).swirl(180);
const imageBuffer = await imageData.buffer();
const data = gm(imageBuffer).swirl(180);
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to tile!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to tile!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); gm(image.data).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
if (error) console.error; if (error) console.error;
const data = gm(output).resize("800x800>"); const data = gm(output).resize("800x800>");
const resultBuffer = await gmToBuffer(data); const resultBuffer = await gmToBuffer(data);

View File

@ -2,7 +2,6 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
const fs = require("fs"); const fs = require("fs");
exports.run = async (message) => { 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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Trump meme!`;
message.channel.sendTyping(); message.channel.sendTyping();
const template = "./assets/images/trump.png"; 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}`; 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 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("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: "trump.png" name: "trump.png"

View File

@ -3,17 +3,14 @@
const gm = require("gm").subClass({ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`;
message.channel.sendTyping(); 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
const data2 = `/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; if (error) console.error;
gm(data2).flop().strip().write(data, async (error) => { gm(data2).flop().strip().write(data, async (error) => {
if (error) console.error; if (error) console.error;

View File

@ -2,15 +2,12 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to make a wall from!`;
message.channel.sendTyping(); message.channel.sendTyping();
const imageData = await fetch(image.url); gm(image.data).resize(128).stream(async (error, output) => {
const imageBuffer = await imageData.buffer();
gm(imageBuffer).resize(128).stream(async (error, output) => {
if (error) console.error; 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 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); const resultBuffer = await gmToBuffer(data);

View File

@ -2,7 +2,6 @@ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const gmToBuffer = require("../utils/gmbuffer.js"); const gmToBuffer = require("../utils/gmbuffer.js");
const fetch = require("node-fetch");
const fs = require("fs"); const fs = require("fs");
exports.run = async (message) => { 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!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to make a "who did this" meme!`;
message.channel.sendTyping(); message.channel.sendTyping();
const template = "./assets/images/whodidthis.png"; 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}`; 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 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("", { return message.channel.createMessage("", {
file: resultBuffer, file: resultBuffer,
name: "wdt.png" name: "wdt.png"

View File

@ -3,17 +3,14 @@
const gm = require("gm").subClass({ const gm = require("gm").subClass({
imageMagick: true imageMagick: true
}); });
const fetch = require("node-fetch");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`; if (image === undefined) return `${message.author.mention}, you need to provide an image to mirror!`;
message.channel.sendTyping(); 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 data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
const data2 = `/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; if (error) console.error;
gm(data2).flip().strip().write(data, async (error) => { gm(data2).flip().strip().write(data, async (error) => {
if (error) console.error; if (error) console.error;

View File

@ -101,7 +101,7 @@ module.exports = async (message) => {
} }
} catch (error) { } catch (error) {
logger.error(error.stack); 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}`), file: Buffer.from(`Message: ${error}\n\nStack Trace: ${error.stack}`),
name: "error.txt" name: "error.txt"
}]); }]);

View File

@ -14,14 +14,14 @@ const typeCheck = async (image) => {
// if it is, then return the url with the file type // if it is, then return the url with the file type
return { return {
type: imageType.ext, type: imageType.ext,
url: image data: imageBuffer
}; };
} else { } else {
// if not, then return a message // if not, then return false
return "Not the correct file type"; return false;
} }
} catch (error) { } catch (error) {
if (error) console.error; throw error;
} }
}; };
@ -36,7 +36,7 @@ module.exports = async (cmdMessage) => {
// get type of file // get type of file
const type = await typeCheck(message.attachments[0].url); const type = await typeCheck(message.attachments[0].url);
// move to the next message if the file isn't an image // 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 // if the file is an image then return it
return type; return type;
// if there's nothing in the attachments check the embeds next // 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 // embeds can have 2 possible entries with images, we check the thumbnail first
if (message.embeds[0].thumbnail) { if (message.embeds[0].thumbnail) {
const type = await typeCheck(message.embeds[0].thumbnail.url); const type = await typeCheck(message.embeds[0].thumbnail.url);
if (type === "Not the correct file type") continue; if (type === false) continue;
return type; return type;
// if there isn't a thumbnail check the image area // if there isn't a thumbnail check the image area
} else if (message.embeds[0].image) { } else if (message.embeds[0].image) {
const type = await typeCheck(message.embeds[0].image.url); const type = await typeCheck(message.embeds[0].image.url);
if (type === "Not the correct file type") continue; if (type === false) continue;
return type; return type;
} }
} }

View File

@ -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}`) 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); exports.error = (...args) => this.log("error", ...args);

View File

@ -19,7 +19,8 @@ exports.clean = async (text) => {
.replace(config.catToken, "<redacted>") .replace(config.catToken, "<redacted>")
.replace(config.googleKey, "<redacted>") .replace(config.googleKey, "<redacted>")
.replace(config.cseID, "<redacted>") .replace(config.cseID, "<redacted>")
.replace(config.dblToken, "<redacted>"); .replace(config.dblToken, "<redacted>")
.replace(config.mongoURL, "<redacted>");
return text; return text;
}; };

View File

@ -6,18 +6,24 @@ module.exports = async (sound, message) => {
if (message.member.voiceState.channelID) { 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!`); 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); 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); const connection = await client.joinVoiceChannel(voiceChannel.id);
console.log(connection.current);
if (connection.playing) { if (connection.playing) {
connection.stopPlaying(); connection.stopPlaying();
connection.play(fs.createReadStream(sound));
} else {
connection.play(fs.createReadStream(sound));
} }
connection.play(fs.createReadStream(sound));
connection.on("error", (error) => { connection.on("error", (error) => {
voiceChannel.leave(); voiceChannel.leave();
playingMessage.delete();
logger.error(error); logger.error(error);
}); });
connection.once("end", () => { connection.once("end", () => {
voiceChannel.leave(); voiceChannel.leave();
playingMessage.delete();
}); });
} else { } else {
client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`); client.createMessage(message.channel.id, `${message.author.mention}, you need to be in a voice channel first!`);