Added support for "gifv"s, fixed embed issue with image
This commit is contained in:
		
							parent
							
								
									fb59135388
								
							
						
					
					
						commit
						777b86e480
					
				
					 41 changed files with 167 additions and 175 deletions
				
			
		| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					const fs = require("fs");
 | 
				
			||||||
const gm = require("gm").subClass({
 | 
					const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -8,10 +9,10 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/9gag.png";
 | 
					  const watermark = "./assets/images/9gag.png";
 | 
				
			||||||
  const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite").out("-layers", "optimize");
 | 
					  const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `9gag.${image.type}`
 | 
					    name: `9gag.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,12 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/bandicam.png";
 | 
					  const watermark = "./assets/images/bandicam.png";
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
					    const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("North").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `bandicam.${image.type}`
 | 
					      name: `bandicam.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const command = gm(image.data).blur(10);
 | 
					  const command = gm(image.path).blur(10);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `blur.${image.type}`
 | 
					    name: `blur.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
 | 
					  const data = gm(image.path).threshold(75, true).out("+level-colors").out("\"#7289DA\",white");
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `blurple.${image.type}`
 | 
					    name: `blurple.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,15 @@
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
const gm = require("gm").subClass({
 | 
					const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const gmToBuffer = require("../utils/gmbuffer.js");
 | 
					const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
 | 
					//const upload = require("../utils/upload.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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/GIF to add a caption!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`;
 | 
				
			||||||
  if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
 | 
					  if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					 | 
				
			||||||
  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");
 | 
				
			||||||
  require("util").promisify(fs.writeFile)(path, image.data);
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const command = gm().out("-size", `${size.width}x`).background("white").fill("black").font("./assets/caption.otf", size.width / 10).gravity("Center").out(`caption:${args.join(" ")}`);
 | 
					    const command = gm().out("-size", `${size.width}x`).background("white").fill("black").font("./assets/caption.otf", size.width / 10).gravity("Center").out(`caption:${args.join(" ")}`);
 | 
				
			||||||
    const output = await gmToBuffer(command, "png");
 | 
					    const output = await gmToBuffer(command, "png");
 | 
				
			||||||
| 
						 | 
					@ -19,12 +17,13 @@ exports.run = async (message, args) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
      gm(output).gravity("Center").trim().out("+repage").extent(size.width, size2.height + (size.width / 10)).stream(async (error, output2) => {
 | 
					      gm(output).gravity("Center").trim().out("+repage").extent(size.width, size2.height + (size.width / 10)).stream(async (error, output2) => {
 | 
				
			||||||
        if (error) throw error;
 | 
					        if (error) throw error;
 | 
				
			||||||
        const command3 = gm(output2).out("-alpha", "set").background("none").out("(").out(path).out("-coalesce").out(")").out("-set", "page", "%[fx:u.w]x%[fx:u.h+v.h]+%[fx:t?(u.w-v.w)/2:0]+%[fx:t?u.h:0]").out("-coalesce").out("null:").out("-insert", 1).out("-layers", "composite").out("-layers", "optimize");
 | 
					        const command3 = gm(output2).out("-alpha", "set").background("none").out("(").out(image.path).out("-coalesce").out(")").colorspace("sRGB").out("-set", "page", "%[fx:u.w]x%[fx:u.h+v.h]+%[fx:t?(u.w-v.w)/2:0]+%[fx:t?u.h:0]").out("-coalesce").out("null:").out("-insert", 1).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
        const outputFinal = await gmToBuffer(command3, image.type);
 | 
					        const outputFinal = await gmToBuffer(command3, image.outputType);
 | 
				
			||||||
        await processMessage.delete();
 | 
					        await processMessage.delete();
 | 
				
			||||||
 | 
					        //return upload(message, outputFinal, `caption.${image.type}`);
 | 
				
			||||||
        return message.channel.createMessage("", {
 | 
					        return message.channel.createMessage("", {
 | 
				
			||||||
          file: outputFinal,
 | 
					          file: outputFinal,
 | 
				
			||||||
          name: `caption.${image.type}`
 | 
					          name: `caption.${image.outputType}`
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).out("-radial-blur", 10);
 | 
					  const data = gm(image.path).coalesce().out("-radial-blur", 10);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `circle.${image.type}`
 | 
					    name: `circle.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,12 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/deviantart.png";
 | 
					  const watermark = "./assets/images/deviantart.png";
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
					    const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `deviantart.${image.type}`
 | 
					      name: `deviantart.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).implode([-2]);
 | 
					  const data = gm(image.path).coalesce().implode([-2]);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `explode.${image.type}`
 | 
					    name: `explode.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const command = gm(image.data).flip();
 | 
					  const command = gm(image.path).flip();
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `flip.${image.type}`
 | 
					    name: `flip.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const command = gm(image.data).flop();
 | 
					  const command = gm(image.path).flop();
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `flop.${image.type}`
 | 
					    name: `flop.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,12 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/funky.png";
 | 
					  const watermark = "./assets/images/funky.png";
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
					    const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthEast").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `funky.${image.type}`
 | 
					      name: `funky.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,19 +2,16 @@ const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const gmToBuffer = require("../utils/gmbuffer.js");
 | 
					const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 GameXplain thumbnail meme!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image to make a GameXplain thumbnail meme!`;
 | 
				
			||||||
  const template = "./assets/images/gamexplain.png";
 | 
					  const template = "./assets/images/gamexplain.png";
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					  const command = gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("1181x571!").out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
  require("util").promisify(fs.writeFile)(path, image.data);
 | 
					 | 
				
			||||||
  const command = gm(template).background("white").out("null:").out("(").out(path).coalesce().out("-virtual-pixel", "transparent").resize("1181x571!").out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").out("-layers", "optimize");
 | 
					 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command, image.type),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `gamexplain.${image.type}`
 | 
					    name: `gamexplain.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,16 +11,16 @@ exports.run = async (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!`;
 | 
				
			||||||
  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  gm(image.data).size((error, size) => {
 | 
					  gm(image.path).size((error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    gm(image.data).coalesce().gravity("West").crop("50%", 0).out("+repage").write(data2, (error) => {
 | 
					    gm(image.path).coalesce().gravity("West").crop("50%", 0).out("+repage").write(data2, (error) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
      gm(data2).flop().write(data, async (error) => {
 | 
					      gm(data2).flop().write(data, async (error) => {
 | 
				
			||||||
        if (error) throw error;
 | 
					        if (error) throw error;
 | 
				
			||||||
        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize");
 | 
					        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize");
 | 
				
			||||||
        return message.channel.createMessage("", {
 | 
					        return message.channel.createMessage("", {
 | 
				
			||||||
          file: await gmToBuffer(command, image.type),
 | 
					          file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
          name: `haah.${image.type}`
 | 
					          name: `haah.${image.outputType}`
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,16 +11,16 @@ exports.run = async (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!`;
 | 
				
			||||||
  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  gm(image.data).size((error, size) => {
 | 
					  gm(image.path).size((error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    gm(image.data).coalesce().gravity("South").crop(0, "50%").out("+repage").write(data2, (error) => {
 | 
					    gm(image.path).coalesce().gravity("South").crop(0, "50%").out("+repage").write(data2, (error) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
      gm(data2).flip().write(data, async (error) => {
 | 
					      gm(data2).flip().write(data, async (error) => {
 | 
				
			||||||
        if (error) throw error;
 | 
					        if (error) throw error;
 | 
				
			||||||
        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "Optimize");
 | 
					        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "Optimize");
 | 
				
			||||||
        return message.channel.createMessage("", {
 | 
					        return message.channel.createMessage("", {
 | 
				
			||||||
          file: await gmToBuffer(command, image.type),
 | 
					          file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
          name: `hooh.${image.type}`
 | 
					          name: `hooh.${image.outputType}`
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,12 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/hypercam.png";
 | 
					  const watermark = "./assets/images/hypercam.png";
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
					    const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthWest").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `hypercam.${image.type}`
 | 
					      name: `hypercam.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,12 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/ifunny.png";
 | 
					  const watermark = "./assets/images/ifunny.png";
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const data = gm(image.data).coalesce().out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite").out("-layers", "optimize");
 | 
					    const data = gm(image.path).coalesce().out("null:").out(watermark).gravity("South").resize(size.width, null).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `ifunny.${image.type}`
 | 
					      name: `ifunny.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ exports.run = async (message, args) => {
 | 
				
			||||||
        "title": "Search Results",
 | 
					        "title": "Search Results",
 | 
				
			||||||
        "color": 16711680,
 | 
					        "color": 16711680,
 | 
				
			||||||
        "footer": {
 | 
					        "footer": {
 | 
				
			||||||
          "text": `Page ${i + 1} of ${images.length}`
 | 
					          "text": `Page ${i + 1} of ${images.items.length}`
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "image": {
 | 
					        "image": {
 | 
				
			||||||
          "url": value.link
 | 
					          "url": value.link
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).implode([1]);
 | 
					  const data = gm(image.path).implode([1]);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `implode.${image.type}`
 | 
					    name: `implode.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).negative();
 | 
					  const data = gm(image.path).negative();
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `invert.${image.type}`
 | 
					    name: `invert.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).setFormat("jpg").quality(1);
 | 
					  const data = gm(image.path).setFormat("jpg").quality(1);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data),
 | 
				
			||||||
    name: "jpeg.jpg"
 | 
					    name: "jpeg.jpg"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,21 +2,18 @@ const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const gmToBuffer = require("../utils/gmbuffer.js");
 | 
					const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 Super Smash Bros. leak meme!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Super Smash Bros. leak meme!`;
 | 
				
			||||||
  if (image.type === "gif") return `${message.author.mention}, this command doesn't work with GIFs!`;
 | 
					  if (image.type === "gif" || image.type === "mp4") return `${message.author.mention}, this command doesn't work with GIFs!`;
 | 
				
			||||||
  const template = "./assets/images/leak.png";
 | 
					  const template = "./assets/images/leak.png";
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					  const command = gm(template).out("-background").out("white").out("-gravity").out("Center").out("(").out("-clone").out("0").out("(").out(image.path).out("-virtual-pixel").out("white").out("-resize").out("640x360!").rotate("white", 15).out(")").out("-geometry").out("+450-200").out("-composite").out(")").out("+swap").out("-composite").out("-alpha").out("remove").out("-alpha").out("off");
 | 
				
			||||||
  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("white").out("-resize").out("640x360!").rotate("white", 15).out(")").out("-geometry").out("+450-200").out("-composite").out(")").out("+swap").out("-composite").out("-alpha").out("remove").out("-alpha").out("off");
 | 
					 | 
				
			||||||
  // const command = gm(template).out("-background", "white").gravity("Center").out("null:").out("(").out(path).out("-resize", "640x360!").out("-virtual-pixel", "white").rotate("white", 15).coalesce().geometry("+450-200").out(")").compose("over").out("-alpha", "remove").out("-alpha", "off").out("-layers", "composite");
 | 
					  // const command = gm(template).out("-background", "white").gravity("Center").out("null:").out("(").out(path).out("-resize", "640x360!").out("-virtual-pixel", "white").rotate("white", 15).coalesce().geometry("+450-200").out(")").compose("over").out("-alpha", "remove").out("-alpha", "off").out("-layers", "composite");
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command),
 | 
					    file: await gmToBuffer(command),
 | 
				
			||||||
    name: `leak.${image.type}`
 | 
					    name: `leak.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
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!`;
 | 
				
			||||||
  if (image.type === "gif") return `${message.author.mention}, this command doesn't work with GIFs!`;
 | 
					  if (image.type === "gif" || image.type === "mp4") return `${message.author.mention}, this command doesn't work with GIFs!`;
 | 
				
			||||||
  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");
 | 
				
			||||||
  gm(image.data).resize(800, 800).stream("miff", (error, stream) => {
 | 
					  gm(image.data).resize(800, 800).stream("miff", (error, stream) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ exports.run = async (message) => {
 | 
				
			||||||
      await processMessage.delete();
 | 
					      await processMessage.delete();
 | 
				
			||||||
      return message.channel.createMessage("", {
 | 
					      return message.channel.createMessage("", {
 | 
				
			||||||
        file: resultBuffer,
 | 
					        file: resultBuffer,
 | 
				
			||||||
        name: `magik.${image.type}`
 | 
					        name: `magik.${image.outputType}`
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,7 @@ exports.run = async (message, args) => {
 | 
				
			||||||
  const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
					  const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
				
			||||||
  const file3 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
					  const file3 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
				
			||||||
  gm(image.data).out("-coalesce").resize(600, 600).noProfile().write(file, (error) => {
 | 
					  gm(image.path).coalesce().resize(600, 600).noProfile().write(file, (error) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    gm(file).size((error, size) => {
 | 
					    gm(file).size((error, size) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
| 
						 | 
					@ -22,8 +22,8 @@ exports.run = async (message, args) => {
 | 
				
			||||||
          if (error) throw error;
 | 
					          if (error) throw error;
 | 
				
			||||||
          const data = gm(file).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite").out("-layers", "optimize");
 | 
					          const data = gm(file).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
          return message.channel.createMessage("", {
 | 
					          return message.channel.createMessage("", {
 | 
				
			||||||
            file: await gmToBuffer(data, image.type),
 | 
					            file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
            name: `meme.${image.type}`
 | 
					            name: `meme.${image.outputType}`
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,10 +9,10 @@ exports.run = async (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!`;
 | 
				
			||||||
  const watermark = "./assets/images/memecenter.png";
 | 
					  const watermark = "./assets/images/memecenter.png";
 | 
				
			||||||
  let resultBuffer;
 | 
					  let resultBuffer;
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const command = gm(image.data).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").out("-layers", "optimize");
 | 
					    const command = gm(image.path).coalesce().background("white").extent(size.width, size.height + 15).out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    const output = await gmToBuffer(command, image.type);
 | 
					    const output = await gmToBuffer(command, image.outputType);
 | 
				
			||||||
    gm(output).size(async (error, size2) => {
 | 
					    gm(output).size(async (error, size2) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
      resultBuffer = output;
 | 
					      resultBuffer = output;
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ exports.run = async (message) => {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return message.channel.createMessage("", {
 | 
					      return message.channel.createMessage("", {
 | 
				
			||||||
        file: resultBuffer,
 | 
					        file: resultBuffer,
 | 
				
			||||||
        name: `memecenter.${image.type}`
 | 
					        name: `memecenter.${image.outputType}`
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,3 @@
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
const gm = require("gm").subClass({
 | 
					const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -10,13 +9,11 @@ exports.run = async (message, args) => {
 | 
				
			||||||
  if (args.length === 0) return `${message.author.mention}, you need to provide some text to make a motivational poster!`;
 | 
					  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 processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
 | 
				
			||||||
  const [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
 | 
					  const [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					 | 
				
			||||||
  const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const text = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
					  const text = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
				
			||||||
  const text2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
					  const text2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
 | 
				
			||||||
  require("util").promisify(fs.writeFile)(path, image.data);
 | 
					  gm().in("(").in(image.path).coalesce().resize(500, 500).borderColor("black").border(5, 5).out(")").borderColor("white").border(3, 3).out("-layers", "optimize").write(file, (error) => {
 | 
				
			||||||
  gm().in("(").in(path).coalesce().resize(500, 500).borderColor("black").border(5, 5).out(")").borderColor("white").border(3, 3).out("-layers", "optimize").write(file, (error) => {
 | 
					 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    gm(file).size((error, size) => {
 | 
					    gm(file).size((error, size) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
| 
						 | 
					@ -35,21 +32,21 @@ exports.run = async (message, args) => {
 | 
				
			||||||
                  if (error) throw error;
 | 
					                  if (error) throw error;
 | 
				
			||||||
                  gm(text2).size(async (error, size4) => {
 | 
					                  gm(text2).size(async (error, size4) => {
 | 
				
			||||||
                    if (error) throw error;
 | 
					                    if (error) throw error;
 | 
				
			||||||
                    const command2 = gm(await gmToBuffer(command, image.type)).gravity("North").coalesce().background("black").extent(600, size2.height + size3.height + size4.height).out("null:", "(", text2, "-set", "page", `+0+${size2.height + size3.height}`, ")", "-layers", "composite", "-layers", "optimize");
 | 
					                    const command2 = gm(await gmToBuffer(command, image.outputType)).gravity("North").coalesce().background("black").extent(600, size2.height + size3.height + size4.height).out("null:", "(", text2, "-set", "page", `+0+${size2.height + size3.height}`, ")", "-layers", "composite", "-layers", "optimize");
 | 
				
			||||||
                    const resultBuffer = await gmToBuffer(command2, image.type);
 | 
					                    const resultBuffer = await gmToBuffer(command2, image.outputType);
 | 
				
			||||||
                    processMessage.delete();
 | 
					                    processMessage.delete();
 | 
				
			||||||
                    return message.channel.createMessage("", {
 | 
					                    return message.channel.createMessage("", {
 | 
				
			||||||
                      file: resultBuffer,
 | 
					                      file: resultBuffer,
 | 
				
			||||||
                      name: `motivate.${image.type}`
 | 
					                      name: `motivate.${image.outputType}`
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
                  });
 | 
					                  });
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
              } else {
 | 
					              } else {
 | 
				
			||||||
                const resultBuffer = await gmToBuffer(command, image.type);
 | 
					                const resultBuffer = await gmToBuffer(command, image.outputType);
 | 
				
			||||||
                processMessage.delete();
 | 
					                processMessage.delete();
 | 
				
			||||||
                return message.channel.createMessage("", {
 | 
					                return message.channel.createMessage("", {
 | 
				
			||||||
                  file: resultBuffer,
 | 
					                  file: resultBuffer,
 | 
				
			||||||
                  name: `motivate.${image.type}`
 | 
					                  name: `motivate.${image.outputType}`
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,19 +2,16 @@ const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const gmToBuffer = require("../utils/gmbuffer.js");
 | 
					const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 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!`;
 | 
				
			||||||
  const template = "./assets/images/scott.png";
 | 
					  const template = "./assets/images/scott.png";
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					  const command = gm(template).out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("415x234!").out("+distort", "Perspective", "0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out(")").compose("over").gravity("Center").geometry("-238-98").out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
  require("util").promisify(fs.writeFile)(path, image.data);
 | 
					 | 
				
			||||||
  const command = gm(template).out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("415x234!").coalesce().out("+distort", "Perspective", "0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out(")").compose("over").gravity("Center").geometry("-238-98").out("-layers", "composite").out("-layers", "optimize");
 | 
					 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command, image.type),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `scott.${image.type}`
 | 
					    name: `scott.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const command = gm(image.data).sharpen(10);
 | 
					  const command = gm(image.path).coalesce().sharpen(10);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `sharpen.${image.type}`
 | 
					    name: `sharpen.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,12 +8,12 @@ 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!`;
 | 
				
			||||||
  const watermark = "./assets/images/shutterstock.png";
 | 
					  const watermark = "./assets/images/shutterstock.png";
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const command = gm(image.data).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
					    const command = gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").resize(null, size.height).out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(command),
 | 
					      file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
      name: `shutterstock.${image.type}`
 | 
					      name: `shutterstock.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,3 @@
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
const { exec } = require("child_process");
 | 
					const { exec } = require("child_process");
 | 
				
			||||||
const util = require("util");
 | 
					const util = require("util");
 | 
				
			||||||
const gm = require("gm").subClass({
 | 
					const gm = require("gm").subClass({
 | 
				
			||||||
| 
						 | 
					@ -10,23 +9,21 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 a GIF to speed up!`;
 | 
					  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!`;
 | 
					  if (image.type !== "gif" && image.type !== "mp4") return `${message.author.mention}, that isn't a GIF!`;
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.gif`;
 | 
					  gm(image.path).identify(async (error, value) => {
 | 
				
			||||||
  util.promisify(fs.writeFile)(path, image.data);
 | 
					 | 
				
			||||||
  gm(image.data).identify(async (error, value) => {
 | 
					 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const delay = value.Delay[0].split("x");
 | 
					    const delay = value.Delay ? value.Delay[0].split("x") : [0, 100];
 | 
				
			||||||
    if (Math.round(parseInt(delay[0]) / 2) >= 2) {
 | 
					    if (Math.round(parseInt(delay[0]) / 2) >= 2) {
 | 
				
			||||||
      const data = gm().delay(`${parseInt(delay[0]) / 2}x${delay[1]}`).out(path);
 | 
					      const data = gm().delay(`${parseInt(delay[0]) / 2}x${delay[1]}`).out(image.path);
 | 
				
			||||||
      return message.channel.createMessage("", {
 | 
					      return message.channel.createMessage("", {
 | 
				
			||||||
        file: await gmToBuffer(data),
 | 
					        file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
        name: "speed.gif"
 | 
					        name: "speed.gif"
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      const numbers = (await util.promisify(exec)(`seq 0 2 ${value.Delay.length}`)).stdout.split("\n").join(",");
 | 
					      const numbers = (await util.promisify(exec)(`seq 0 2 ${value.Scene.length}`)).stdout.split("\n").join(",");
 | 
				
			||||||
      const data = gm().out("(").out(path).coalesce().out(")").out("-delete", numbers).out("-layers", "optimize");
 | 
					      const data = gm().out("(").out(image.path).coalesce().out(")").out("-delete", numbers).out("-layers", "optimize");
 | 
				
			||||||
      return message.channel.createMessage("", {
 | 
					      return message.channel.createMessage("", {
 | 
				
			||||||
        file: await gmToBuffer(data),
 | 
					        file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
        name: "speed.gif"
 | 
					        name: "speed.gif"
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,8 +7,8 @@ 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 spin!`;
 | 
					  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 processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
 | 
				
			||||||
  const command = gm(image.data).out("-duplicate", "29").scale("256x256>").scale("256x256<").background("transparent").virtualPixel("background").out("-distort", "SRT", "'%[fx:360*t/n]'").set("delay", "5").set("dispose", "Background").out("-loop", "0");
 | 
					  const command = gm(image.path).out("-duplicate", "29").scale("256x256>").scale("256x256<").background("transparent").virtualPixel("background").out("-distort", "SRT", "'%[fx:360*t/n]'").set("delay", "5").set("dispose", "Background").out("-loop", "0");
 | 
				
			||||||
  const resultBuffer = await gmToBuffer(command, "gif");
 | 
					  const resultBuffer = await gmToBuffer(command, image.outputType);
 | 
				
			||||||
  await processMessage.delete();
 | 
					  await processMessage.delete();
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: resultBuffer,
 | 
					    file: resultBuffer,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 stretch!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image to stretch!`;
 | 
				
			||||||
  const data = gm(image.data).resize("512x512!");
 | 
					  const data = gm(image.path).coalesce().resize("512x512!");
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `stretch.${image.type}`
 | 
					    name: `stretch.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,10 +7,10 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  const data = gm(image.data).swirl(180);
 | 
					  const data = gm(image.path).coalesce().swirl(180);
 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(data),
 | 
					    file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
    name: `swirl.${image.type}`
 | 
					    name: `swirl.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,12 +7,12 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  gm(image.data).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => {
 | 
					  gm(image.path).coalesce().command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream("miff", async (error, output) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    const data = gm(output).resize("800x800>");
 | 
					    const data = gm(output).coalesce().resize("800x800>");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `tile.${image.type}`
 | 
					      name: `tile.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,19 +2,16 @@ const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const gmToBuffer = require("../utils/gmbuffer.js");
 | 
					const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 Trump meme!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Trump meme!`;
 | 
				
			||||||
  const template = "./assets/images/trump.png";
 | 
					  const template = "./assets/images/trump.png";
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					  const command = gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").resize("365x179!").out("+distort", "Perspective", "0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").compose("over").gravity("Center").geometry("-217-135").out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
  require("util").promisify(fs.writeFile)(path, image.data);
 | 
					 | 
				
			||||||
  const command = gm(template).background("white").out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("365x179!").coalesce().out("+distort", "Perspective", "0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").compose("over").gravity("Center").geometry("-217-135").out("-layers", "composite").out("-layers", "optimize");
 | 
					 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command, image.type),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `trump.${image.type}`
 | 
					    name: `trump.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,16 +11,16 @@ exports.run = async (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!`;
 | 
				
			||||||
  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  gm(image.data).size((error, size) => {
 | 
					  gm(image.path).size((error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    gm(image.data).coalesce().gravity("East").crop("50%", 0).out("+repage").write(data2, (error) => {
 | 
					    gm(image.path).coalesce().gravity("East").crop("50%", 0).out("+repage").write(data2, (error) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
      gm(data2).flop().write(data, async (error) => {
 | 
					      gm(data2).flop().write(data, async (error) => {
 | 
				
			||||||
        if (error) throw error;
 | 
					        if (error) throw error;
 | 
				
			||||||
        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize");
 | 
					        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").out("-layers", "optimize");
 | 
				
			||||||
        return message.channel.createMessage("", {
 | 
					        return message.channel.createMessage("", {
 | 
				
			||||||
          file: await gmToBuffer(command, image.type),
 | 
					          file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
          name: `waaw.${image.type}`
 | 
					          name: `waaw.${image.outputType}`
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,12 +7,12 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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!`;
 | 
				
			||||||
  gm(image.data).resize(128).stream(async (error, output) => {
 | 
					  gm(image.path).coalesce().resize(128).stream("miff", async (error, output) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw 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).coalesce().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");
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `wall.${image.type}`
 | 
					      name: `wall.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,19 +2,16 @@ const gm = require("gm").subClass({
 | 
				
			||||||
  imageMagick: true
 | 
					  imageMagick: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const gmToBuffer = require("../utils/gmbuffer.js");
 | 
					const gmToBuffer = require("../utils/gmbuffer.js");
 | 
				
			||||||
const fs = require("fs");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.run = async (message) => {
 | 
					exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 "who did this" meme!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image to make a "who did this" meme!`;
 | 
				
			||||||
  const template = "./assets/images/whodidthis.png";
 | 
					  const template = "./assets/images/whodidthis.png";
 | 
				
			||||||
  const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
 | 
					  const command = gm(template).coalesce().out("null:").out(image.path).gravity("Center").resize("374x374>").out("-layers", "composite").out("-layers", "optimize");
 | 
				
			||||||
  require("util").promisify(fs.writeFile)(path, image.data);
 | 
					 | 
				
			||||||
  const command = gm(template).coalesce().out("null:").out(path).gravity("Center").resize("374x374>").out("-layers", "composite").out("-layers", "optimize");
 | 
					 | 
				
			||||||
  return message.channel.createMessage("", {
 | 
					  return message.channel.createMessage("", {
 | 
				
			||||||
    file: await gmToBuffer(command, image.type),
 | 
					    file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
    name: `wdt.${image.type}`
 | 
					    name: `wdt.${image.outputType}`
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,13 +7,13 @@ exports.run = async (message) => {
 | 
				
			||||||
  message.channel.sendTyping();
 | 
					  message.channel.sendTyping();
 | 
				
			||||||
  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 stretch!`;
 | 
					  if (image === undefined) return `${message.author.mention}, you need to provide an image to stretch!`;
 | 
				
			||||||
  gm(image.data).size(async (error, size) => {
 | 
					  gm(image.path).size(async (error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    if (size.width > 10000) return `${message.author.mention}, this image is too wide!`;
 | 
					    if (size.width > 10000) return `${message.author.mention}, this image is too wide!`;
 | 
				
			||||||
    const data = gm(image.data).resize(`${(size.width * 19) / 2}x${size.height / 2}!`);
 | 
					    const data = gm(image.path).coalesce().resize(`${(size.width * 19) / 2}x${size.height / 2}!`);
 | 
				
			||||||
    return message.channel.createMessage("", {
 | 
					    return message.channel.createMessage("", {
 | 
				
			||||||
      file: await gmToBuffer(data),
 | 
					      file: await gmToBuffer(data, image.outputType),
 | 
				
			||||||
      name: `wide.${image.type}`
 | 
					      name: `wide.${image.outputType}`
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,16 +11,16 @@ exports.run = async (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!`;
 | 
				
			||||||
  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
					  const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`;
 | 
				
			||||||
  gm(image.data).size((error, size) => {
 | 
					  gm(image.path).size((error, size) => {
 | 
				
			||||||
    if (error) throw error;
 | 
					    if (error) throw error;
 | 
				
			||||||
    gm(image.data).coalesce().gravity("North").crop(0, "50%").out("+repage").write(data2, (error) => {
 | 
					    gm(image.path).coalesce().gravity("North").crop(0, "50%").out("+repage").write(data2, (error) => {
 | 
				
			||||||
      if (error) throw error;
 | 
					      if (error) throw error;
 | 
				
			||||||
      gm(data2).flip().write(data, async (error) => {
 | 
					      gm(data2).flip().write(data, async (error) => {
 | 
				
			||||||
        if (error) throw error;
 | 
					        if (error) throw error;
 | 
				
			||||||
        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "optimize");
 | 
					        const command = gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+0+${size.height / 2}`).out("-layers", "Composite").out("-layers", "optimize");
 | 
				
			||||||
        return message.channel.createMessage("", {
 | 
					        return message.channel.createMessage("", {
 | 
				
			||||||
          file: await gmToBuffer(command, image.type),
 | 
					          file: await gmToBuffer(command, image.outputType),
 | 
				
			||||||
          name: `woow.${image.type}`
 | 
					          name: `woow.${image.outputType}`
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,5 +87,6 @@
 | 
				
			||||||
  "foobar2000",
 | 
					  "foobar2000",
 | 
				
			||||||
  "XMPlay",
 | 
					  "XMPlay",
 | 
				
			||||||
  "OpenMPT",
 | 
					  "OpenMPT",
 | 
				
			||||||
  "follow @esmBot_ on Twitter"
 | 
					  "follow @esmBot_ on Twitter",
 | 
				
			||||||
 | 
					  "with GIFs"
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,10 @@
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					const fetch = require("node-fetch");
 | 
				
			||||||
const fileType = require("file-type");
 | 
					const fileType = require("file-type");
 | 
				
			||||||
 | 
					const writeFile = require("util").promisify(require("fs").writeFile);
 | 
				
			||||||
const urlRegex = /(?:\w+:)?\/\/(\S+)/;
 | 
					const urlRegex = /(?:\w+:)?\/\/(\S+)/;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// this checks if the file is, in fact, an image
 | 
					// this checks if the file is, in fact, an image
 | 
				
			||||||
const typeCheck = async (image) => {
 | 
					const typeCheck = async (image, gifv = false) => {
 | 
				
			||||||
  // download the file to a buffer
 | 
					  // download the file to a buffer
 | 
				
			||||||
  const imageRequest = await fetch(image);
 | 
					  const imageRequest = await fetch(image);
 | 
				
			||||||
  const imageBuffer = await imageRequest.buffer();
 | 
					  const imageBuffer = await imageRequest.buffer();
 | 
				
			||||||
| 
						 | 
					@ -11,11 +12,18 @@ const typeCheck = async (image) => {
 | 
				
			||||||
    // get the file type
 | 
					    // get the file type
 | 
				
			||||||
    const imageType = await fileType.fromBuffer(imageBuffer);
 | 
					    const imageType = await fileType.fromBuffer(imageBuffer);
 | 
				
			||||||
    // check if the file is a jpeg, png, or webp
 | 
					    // check if the file is a jpeg, png, or webp
 | 
				
			||||||
    if (imageType && ["image/jpeg", "image/png", "image/webp", "image/gif"].includes(imageType.mime)) {
 | 
					    const formats = ["image/jpeg", "image/png", "image/webp", "image/gif"];
 | 
				
			||||||
 | 
					    if (gifv) formats.push("video/mp4");
 | 
				
			||||||
 | 
					    if (imageType && formats.includes(imageType.mime)) {
 | 
				
			||||||
      // if it is, then return the url with the file type
 | 
					      // if it is, then return the url with the file type
 | 
				
			||||||
 | 
					      const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${imageType.ext}`;
 | 
				
			||||||
 | 
					      await writeFile(path, imageBuffer);
 | 
				
			||||||
      return {
 | 
					      return {
 | 
				
			||||||
        type: imageType.ext,
 | 
					        type: imageType.ext,
 | 
				
			||||||
        data: imageBuffer
 | 
					        data: imageBuffer,
 | 
				
			||||||
 | 
					        url: image,
 | 
				
			||||||
 | 
					        outputType: imageType.ext === "mp4" ? "gif" : imageType.ext,
 | 
				
			||||||
 | 
					        path: path
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      // if not, then return false
 | 
					      // if not, then return false
 | 
				
			||||||
| 
						 | 
					@ -33,7 +41,23 @@ module.exports = async (cmdMessage) => {
 | 
				
			||||||
  // iterate over each message
 | 
					  // iterate over each message
 | 
				
			||||||
  for (const message of messages) {
 | 
					  for (const message of messages) {
 | 
				
			||||||
    // check the attachments first
 | 
					    // check the attachments first
 | 
				
			||||||
    if (message.attachments.length !== 0) {
 | 
					    if (message.embeds.length !== 0) {
 | 
				
			||||||
 | 
					      // embeds can have 2 possible entries with images, we check the thumbnail first
 | 
				
			||||||
 | 
					      if (message.embeds[0].type === "gifv") {
 | 
				
			||||||
 | 
					        const type = await typeCheck(message.embeds[0].video.url, true);
 | 
				
			||||||
 | 
					        if (type === false) continue;
 | 
				
			||||||
 | 
					        return type;
 | 
				
			||||||
 | 
					      } else if (message.embeds[0].thumbnail) {
 | 
				
			||||||
 | 
					        const type = await typeCheck(message.embeds[0].thumbnail.url);
 | 
				
			||||||
 | 
					        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 === false) continue;
 | 
				
			||||||
 | 
					        return type;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } else if (message.attachments.length !== 0) {
 | 
				
			||||||
      // 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
 | 
				
			||||||
| 
						 | 
					@ -51,18 +75,6 @@ module.exports = async (cmdMessage) => {
 | 
				
			||||||
      // 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 no urls then check the embeds
 | 
					      // if there's no urls then check the embeds
 | 
				
			||||||
    } else if (message.embeds.length !== 0) {
 | 
					 | 
				
			||||||
      // 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 === 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 === false) continue;
 | 
					 | 
				
			||||||
        return type;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue