From f6425dc294790a0eef4c548db35fc8520880e873 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Sun, 12 Apr 2020 14:51:48 -0500 Subject: [PATCH] Refactored image/embed handling to prepare for something, don't use fuzz with sonic --- commands/9gag.js | 4 ++-- commands/bandicam.js | 4 ++-- commands/bird.js | 4 ++-- commands/blur.js | 4 ++-- commands/blurple.js | 4 ++-- commands/caption.js | 4 ++-- commands/caption2.js | 4 ++-- commands/cat.js | 4 ++-- commands/circle.js | 4 ++-- commands/deviantart.js | 4 ++-- commands/dog.js | 4 ++-- commands/eval.js | 5 +++-- commands/exec.js | 5 +++-- commands/explode.js | 4 ++-- commands/flip.js | 4 ++-- commands/flop.js | 4 ++-- commands/funky.js | 4 ++-- commands/gamexplain.js | 4 ++-- commands/haah.js | 4 ++-- commands/help.js | 2 +- commands/homebrew.js | 4 ++-- commands/hooh.js | 4 ++-- commands/hypercam.js | 4 ++-- commands/ifunny.js | 4 ++-- commands/implode.js | 4 ++-- commands/info.js | 4 ++-- commands/invert.js | 4 ++-- commands/jpeg.js | 4 ++-- commands/leak.js | 4 ++-- commands/magik.js | 4 ++-- commands/mc.js | 4 ++-- commands/meme.js | 4 ++-- commands/memecenter.js | 4 ++-- commands/motivate.js | 4 ++-- commands/qrcreate.js | 4 ++-- commands/retro.js | 4 ++-- commands/reverse.js | 4 ++-- commands/scott.js | 4 ++-- commands/screenshot.js | 4 ++-- commands/serverinfo.js | 2 +- commands/sharpen.js | 4 ++-- commands/shutterstock.js | 4 ++-- commands/slow.js | 4 ++-- commands/sonic.js | 4 ++-- commands/speed.js | 8 ++++---- commands/spin.js | 4 ++-- commands/stats.js | 2 +- commands/stretch.js | 4 ++-- commands/swirl.js | 4 ++-- commands/tile.js | 4 ++-- commands/trump.js | 4 ++-- commands/userinfo.js | 2 +- commands/waaw.js | 4 ++-- commands/wall.js | 4 ++-- commands/wdt.js | 4 ++-- commands/wide.js | 4 ++-- commands/wikihow.js | 4 ++-- commands/woow.js | 4 ++-- commands/xkcd.js | 2 +- events/messageCreate.js | 4 +++- events/ready.js | 2 +- utils/client.js | 3 +-- 62 files changed, 122 insertions(+), 119 deletions(-) diff --git a/commands/9gag.js b/commands/9gag.js index 20449f2..70df322 100644 --- a/commands/9gag.js +++ b/commands/9gag.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("East").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `9gag.${image.type}` - }); + }; }; exports.aliases = ["ninegag", "gag"]; diff --git a/commands/bandicam.js b/commands/bandicam.js index 840f921..27c3cdb 100644 --- a/commands/bandicam.js +++ b/commands/bandicam.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("North").scale(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `bandicam.${image.type}` - }); + }; }; exports.aliases = ["bandi"]; diff --git a/commands/bird.js b/commands/bird.js index e39585e..d672d48 100644 --- a/commands/bird.js +++ b/commands/bird.js @@ -4,14 +4,14 @@ exports.run = async (message) => { message.channel.sendTyping(); const imageData = await fetch("http://shibe.online/api/birds"); const json = await imageData.json(); - return message.channel.createMessage({ + return { embed: { color: 16711680, image: { url: json[0] } } - }); + }; }; exports.aliases = ["birb", "birds", "birbs"]; diff --git a/commands/blur.js b/commands/blur.js index f8023a0..b75452f 100644 --- a/commands/blur.js +++ b/commands/blur.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to blur!`; const buffer = await gm(image.path).coalesce().blur(15).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `blur.${image.type}` - }); + }; }; exports.category = 5; diff --git a/commands/blurple.js b/commands/blurple.js index 14f62e7..9062d30 100644 --- a/commands/blurple.js +++ b/commands/blurple.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to make blurple!`; const buffer = await gm(image.path).coalesce().threshold(75, true).out("+level-colors").out("\"#7289DA\",white").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `blurple.${image.type}` - }); + }; }; exports.aliases = ["blurp"]; diff --git a/commands/caption.js b/commands/caption.js index fb7fc8a..9f36d96 100644 --- a/commands/caption.js +++ b/commands/caption.js @@ -15,10 +15,10 @@ exports.run = async (message, args) => { const outputFinal = await gm(output).in("(").gravity("Center").trim().out("+repage").extent(size.width, size2.height + (size.width / 10)).out(")").background("white").out("-alpha", "set").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").bufferPromise(image.type, image.delay); await processMessage.delete(); //return upload(message, outputFinal, `caption.${image.type}`); - return message.channel.createMessage("", { + return { file: outputFinal, name: `caption.${image.type}` - }); + }; }; exports.aliases = ["gifc", "gcaption", "ifcaption", "ifunnycaption"]; diff --git a/commands/caption2.js b/commands/caption2.js index 0d0e16f..3f66fcd 100644 --- a/commands/caption2.js +++ b/commands/caption2.js @@ -13,10 +13,10 @@ exports.run = async (message, args) => { const size2 = await gm(text).sizePromise(); const outputFinal = await gm(image.path).gravity("North").extent(size.width, size2.height + size.height).out("null:", "(", text, "-set", "page", `+0+${size.height}`, ")", "-layers", "composite", "-layers", "optimize").bufferPromise(image.type, image.delay); await processMessage.delete(); - return message.channel.createMessage("", { + return { file: outputFinal, name: `caption2.${image.type}` - }); + }; }; exports.aliases = ["tags2", "meirl", "memecaption", "medotmecaption"]; diff --git a/commands/cat.js b/commands/cat.js index 623d69e..95e0152 100644 --- a/commands/cat.js +++ b/commands/cat.js @@ -8,14 +8,14 @@ exports.run = async (message) => { } }); const json = await data.json(); - return message.channel.createMessage({ + return { embed: { color: 16711680, image: { url: json[0].url } } - }); + }; }; exports.aliases = ["kitters", "kitties", "kitty", "cattos", "catto", "cats"]; diff --git a/commands/circle.js b/commands/circle.js index d602de5..3de4977 100644 --- a/commands/circle.js +++ b/commands/circle.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to add radial blur!`; const buffer = await gm(image.path).coalesce().out("-rotational-blur", 10).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `circle.${image.type}` - }); + }; }; exports.aliases = ["cblur", "radial", "radialblur"]; diff --git a/commands/deviantart.js b/commands/deviantart.js index f065c00..06bc71c 100644 --- a/commands/deviantart.js +++ b/commands/deviantart.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").scale(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `deviantart.${image.type}` - }); + }; }; exports.aliases = ["da", "deviant"]; diff --git a/commands/dog.js b/commands/dog.js index aa09f36..b52fc9d 100644 --- a/commands/dog.js +++ b/commands/dog.js @@ -4,14 +4,14 @@ exports.run = async (message) => { message.channel.sendTyping(); const imageData = await fetch("https://dog.ceo/api/breeds/image/random"); const json = await imageData.json(); - return message.channel.createMessage({ + return { embed: { color: 16711680, image: { url: json.message } } - }); + }; }; exports.aliases = ["doggos", "doggo", "pupper", "puppers", "dogs", "puppy", "puppies", "pups", "pup"]; diff --git a/commands/eval.js b/commands/eval.js index 33bd93d..1d37335 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -8,10 +8,11 @@ exports.run = async (message, args) => { const cleaned = await clean(evaled); const sendString = `\`\`\`js\n${cleaned}\n\`\`\``; if (sendString.length >= 2000) { - return message.channel.createMessage("The result was too large, so here it is as a file:", [{ + return { + text: "The result was too large, so here it is as a file:", file: cleaned, name: "result.txt" - }]); + }; } else { return sendString; } diff --git a/commands/exec.js b/commands/exec.js index 906e047..7139820 100644 --- a/commands/exec.js +++ b/commands/exec.js @@ -11,10 +11,11 @@ exports.run = async (message, args) => { const cleaned = await clean(execed.stdout); const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``; if (sendString.length >= 2000) { - return message.channel.createMessage("The result was too large, so here it is as a file:", [{ + return { + text: "The result was too large, so here it is as a file:", file: cleaned, name: "result.txt" - }]); + }; } else { return sendString; } diff --git a/commands/explode.js b/commands/explode.js index 577485e..144f233 100644 --- a/commands/explode.js +++ b/commands/explode.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to explode!`; const buffer = await gm(image.path).coalesce().implode([-2]).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `explode.${image.type}` - }); + }; }; exports.aliases = ["exp"]; diff --git a/commands/flip.js b/commands/flip.js index af30d0f..250283c 100644 --- a/commands/flip.js +++ b/commands/flip.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to flip!`; const buffer = await gm(image.path).flip().bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `flip.${image.type}` - }); + }; }; exports.category = 5; diff --git a/commands/flop.js b/commands/flop.js index 1b611f7..e82686e 100644 --- a/commands/flop.js +++ b/commands/flop.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to flop!`; const buffer = await gm(image.path).flop().bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `flop.${image.type}` - }); + }; }; exports.aliases = ["flip2"]; diff --git a/commands/funky.js b/commands/funky.js index c50c876..b0428c2 100644 --- a/commands/funky.js +++ b/commands/funky.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthEast").scale(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `funky.${image.type}` - }); + }; }; exports.aliases = ["funkymode", "newfunkymode", "funkykong"]; diff --git a/commands/gamexplain.js b/commands/gamexplain.js index 32aca07..029b395 100644 --- a/commands/gamexplain.js +++ b/commands/gamexplain.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(template).background("white").out("null:").out("(").out(image.path).coalesce().out("-virtual-pixel", "transparent").scale("1181x571!").out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `gamexplain.${image.type}` - }); + }; }; exports.aliases = ["gx"]; diff --git a/commands/haah.js b/commands/haah.js index 56079b7..ea33d4c 100644 --- a/commands/haah.js +++ b/commands/haah.js @@ -9,10 +9,10 @@ exports.run = async (message) => { const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.miff`; await gm(image.path).coalesce().gravity("West").crop("50%", 0).out("+repage").writePromise(data); const buffer = await gm(data).extent("%[fx:u.w*2]", "%[fx:u.h]").out("null:").out("(").out(data).flop().out(")").gravity("East").out("-layers", "Composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `haah.${image.type}` - }); + }; }; exports.aliases = ["magik4", "mirror2"]; diff --git a/commands/help.js b/commands/help.js index 2fb77cc..53fed78 100644 --- a/commands/help.js +++ b/commands/help.js @@ -29,7 +29,7 @@ exports.run = async (message, args) => { }] } }; - return message.channel.createMessage(embed); + return embed; } else { const categories = { general: [], diff --git a/commands/homebrew.js b/commands/homebrew.js index adbcac6..6b2818f 100644 --- a/commands/homebrew.js +++ b/commands/homebrew.js @@ -8,10 +8,10 @@ exports.run = async (message, args) => { const template = "./assets/images/hbc.png"; const cleanedMessage = args.join(" ").toLowerCase().replace(/\n/g, " "); const buffer = await gm(template).gravity("Center").font("./assets/hbc.ttf").out("-kerning", "-5").fill("white").pointSize(96).drawText(0, 0, cleanedMessage).bufferPromise("png"); - return message.channel.createMessage("", { + return { file: buffer, name: "homebrew.png" - }); + }; }; exports.aliases = ["hbc", "brew", "wiibrew"]; diff --git a/commands/hooh.js b/commands/hooh.js index 5501cd4..7b4b7dd 100644 --- a/commands/hooh.js +++ b/commands/hooh.js @@ -11,10 +11,10 @@ exports.run = async (message) => { await gm(image.path).coalesce().gravity("South").crop(0, "50%").out("+repage").writePromise(data); // const buffer = await gm(data2).extent("%[fx:u.w]", "%[fx:u.h*2]").out("null:").out(data).gravity("North").out("-layers", "Composite").bufferPromise(image.type, image.delay); const buffer = await gm(data).extent(size.width, size.height).out("null:").out("(").out(data).flip().out(")").geometry(`+0+${size.height / 2}`).out("-layers", "Composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `hooh.${image.type}` - }); + }; }; exports.aliases = ["magik6", "mirror4"]; diff --git a/commands/hypercam.js b/commands/hypercam.js index b8aa257..b6ff6f4 100644 --- a/commands/hypercam.js +++ b/commands/hypercam.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("NorthWest").scale(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `hypercam.${image.type}` - }); + }; }; exports.aliases = ["hcam"]; diff --git a/commands/ifunny.js b/commands/ifunny.js index b6b604d..1109853 100644 --- a/commands/ifunny.js +++ b/commands/ifunny.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().extent("%[fx:u.w]", "%[fx:u.h+(42*min(u.w/1024,u.h/42))]").out("null:").out(watermark).gravity("South").scale("%[fx:u.w]", null).out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `ifunny.${image.type}` - }); + }; }; exports.category = 5; diff --git a/commands/implode.js b/commands/implode.js index abb7382..ffc63df 100644 --- a/commands/implode.js +++ b/commands/implode.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to implode!`; const buffer = await gm(image.path).implode([1]).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `implode.${image.type}` - }); + }; }; exports.aliases = ["imp"]; diff --git a/commands/info.js b/commands/info.js index bdfdf95..6f7d9e1 100644 --- a/commands/info.js +++ b/commands/info.js @@ -1,7 +1,7 @@ const client = require("../utils/client.js"); const { version } = require("../package.json"); -exports.run = async (message) => { +exports.run = async () => { const dev = client.users.get(process.env.OWNER); const artist = client.users.get("401980971517214723"); const infoEmbed = { @@ -43,7 +43,7 @@ exports.run = async (message) => { ] } }; - return message.channel.createMessage(infoEmbed); + return infoEmbed; }; exports.aliases = ["botinfo", "credits"]; diff --git a/commands/invert.js b/commands/invert.js index 9383492..f0c5534 100644 --- a/commands/invert.js +++ b/commands/invert.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to invert!`; const buffer = await gm(image.path).coalesce().negative().bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `invert.${image.type}` - }); + }; }; exports.aliases = ["inverse", "negate", "negative"]; diff --git a/commands/jpeg.js b/commands/jpeg.js index c505247..416fc67 100644 --- a/commands/jpeg.js +++ b/commands/jpeg.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to add more JPEG!`; const buffer = await gm(`${image.path}[0]`).quality(1).bufferPromise("jpg"); - return message.channel.createMessage("", { + return { file: buffer, name: "jpeg.jpg" - }); + }; }; exports.aliases = ["needsmorejpeg", "jpegify", "magik2", "morejpeg", "jpg"]; diff --git a/commands/leak.js b/commands/leak.js index aa88efe..f1305ef 100644 --- a/commands/leak.js +++ b/commands/leak.js @@ -10,10 +10,10 @@ exports.run = async (message) => { const template = "./assets/images/leak.png"; const buffer = await 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").bufferPromise(image.type, image.delay); // 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 { file: buffer, name: `leak.${image.type}` - }); + }; }; exports.aliases = ["smash", "laxchris", "ssbu", "smashleak"]; diff --git a/commands/magik.js b/commands/magik.js index 52b786f..2a35dc7 100644 --- a/commands/magik.js +++ b/commands/magik.js @@ -9,10 +9,10 @@ exports.run = async (message) => { const processMessage = await message.channel.createMessage(" Processing... This might take a while"); const resultBuffer = await gm(image.path).in("(").in("(").coalesce().scale(600, 600).out(")").out("-liquid-rescale", "300x300").out(")").out("-liquid-rescale", "800x800").bufferPromise(image.type, image.delay); await processMessage.delete(); - return message.channel.createMessage("", { + return { file: resultBuffer, name: `magik.${image.type}` - }); + }; }; exports.aliases = ["imagemagic", "imagemagick", "imagemagik", "magic", "magick", "cas", "liquid"]; diff --git a/commands/mc.js b/commands/mc.js index a5553f0..f3f1593 100644 --- a/commands/mc.js +++ b/commands/mc.js @@ -4,10 +4,10 @@ exports.run = async (message, args) => { if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a Minecraft achievement!`; message.channel.sendTyping(); const request = await fetch(`https://www.minecraftskinstealer.com/achievement/a.php?i=13&h=Achievement+get%21&t=${encodeURIComponent(args.join("+"))}`); - return message.channel.createMessage("", { + return { file: await request.buffer(), name: "mc.png" - }); + }; }; exports.aliases = ["ach", "achievement", "minecraft"]; diff --git a/commands/meme.js b/commands/meme.js index 28f6f99..ac38fdf 100644 --- a/commands/meme.js +++ b/commands/meme.js @@ -15,10 +15,10 @@ exports.run = async (message, args) => { await gm(file).out("-size", "%[fx:u.w]").out("-delete", "0--1").background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:${topText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/`).out(")", "(", "+clone").out("-alpha", "extract").out("-morphology", "EdgeOut", "Octagon", "-background", "black", "-alpha", "shape", ")").compose("DstOver").out(")", "-composite").writePromise(file2); if (bottomText) await gm(file).out("-size", "%[fx:u.w]").out("-delete", "0--1").background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:${bottomText.toUpperCase().replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/`).out(")", "(", "+clone").out("-alpha", "extract").out("-morphology", "EdgeOut", "Octagon", "-background", "black", "-alpha", "shape", ")").compose("DstOver").out(")", "-composite").writePromise(file3); const buffer = await gm(file).out("-coalesce").out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(bottomText ? file3 : "null:").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `meme.${image.type}` - }); + }; }; exports.category = 5; diff --git a/commands/memecenter.js b/commands/memecenter.js index f372c85..4ba8bdc 100644 --- a/commands/memecenter.js +++ b/commands/memecenter.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 output = await gm(image.path).coalesce().background("white").extent("%[fx:u.w]", "%[fx:u.h+15]").out("null:").out(watermark).gravity("SouthEast").compose("over").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: output, name: `memecenter.${image.type}` - }); + }; }; exports.aliases = ["memec", "mcenter"]; diff --git a/commands/motivate.js b/commands/motivate.js index cba65db..e5232c7 100644 --- a/commands/motivate.js +++ b/commands/motivate.js @@ -26,10 +26,10 @@ exports.run = async (message, args) => { resultBuffer = await command2.bufferPromise(image.type, image.delay); } processMessage.delete(); - return message.channel.createMessage("", { + return { file: resultBuffer, name: `motivate.${image.type}` - }); + }; }; exports.aliases = ["motivational", "motiv", "demotiv", "demotivational", "poster"]; diff --git a/commands/qrcreate.js b/commands/qrcreate.js index d26f0c1..2e326a7 100644 --- a/commands/qrcreate.js +++ b/commands/qrcreate.js @@ -14,10 +14,10 @@ exports.run = async (message, args, content) => { if (error) throw error; }); writable.once("end", () => { - return message.channel.createMessage("", { + return { file: Buffer.concat(chunks), name: "qr.png" - }); + }; }); }; diff --git a/commands/retro.js b/commands/retro.js index d4ae371..49b06de 100644 --- a/commands/retro.js +++ b/commands/retro.js @@ -13,10 +13,10 @@ exports.run = async (message, args) => { } else { text = new RetroText().setLine(2, line1).setBackgroundStyle("outlineTri").setTextStyle("chrome"); } - return message.channel.createMessage("", { + return { file: await text.fetchBuffer(), name: "retro.png" - }); + }; }; exports.category = 4; diff --git a/commands/reverse.js b/commands/reverse.js index f609562..8020879 100644 --- a/commands/reverse.js +++ b/commands/reverse.js @@ -8,10 +8,10 @@ exports.run = async (message) => { if (image === undefined) return `${message.author.mention}, you need to provide a GIF to reverse!`; if (image.type !== "gif") return `${message.author.mention}, that isn't a GIF!`; const buffer = await gm(image.path).coalesce().out("-reverse").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: "reverse.gif" - }); + }; }; exports.aliases = ["backwards"]; diff --git a/commands/scott.js b/commands/scott.js index 7fa0ca5..c34d9f5 100644 --- a/commands/scott.js +++ b/commands/scott.js @@ -8,10 +8,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!`; const template = "./assets/images/scott.png"; const buffer = await 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").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `scott.${image.type}` - }); + }; }; exports.aliases = ["woz", "tv", "porn"]; diff --git a/commands/screenshot.js b/commands/screenshot.js index 2766f25..77f0a8f 100644 --- a/commands/screenshot.js +++ b/commands/screenshot.js @@ -19,10 +19,10 @@ exports.run = async (message, args) => { await page.goto(url); const screenshot = await page.screenshot(); await page.close(); - return message.channel.createMessage("", { + return { file: screenshot, name: "screenshot.png" - }); + }; }; exports.aliases = ["webshot", "ss", "shot", "page"]; diff --git a/commands/serverinfo.js b/commands/serverinfo.js index b067bbe..32b2a2a 100644 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -39,7 +39,7 @@ exports.run = async (message) => { ] } }; - return message.channel.createMessage(infoEmbed); + return infoEmbed; }; exports.aliases = ["server"]; diff --git a/commands/sharpen.js b/commands/sharpen.js index 67e7534..7f5f4c9 100644 --- a/commands/sharpen.js +++ b/commands/sharpen.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to sharpen!`; const buffer = await gm(image.path).coalesce().sharpen(10).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `sharpen.${image.type}` - }); + }; }; diff --git a/commands/shutterstock.js b/commands/shutterstock.js index 62ea242..f373c2d 100644 --- a/commands/shutterstock.js +++ b/commands/shutterstock.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await gm(image.path).coalesce().out("null:").out(watermark).gravity("Center").scale(null, "%[fx:u.h]").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `shutterstock.${image.type}` - }); + }; }; exports.aliases = ["stock", "stockphoto"]; diff --git a/commands/slow.js b/commands/slow.js index e425d2a..75dd8e0 100644 --- a/commands/slow.js +++ b/commands/slow.js @@ -10,10 +10,10 @@ exports.run = async (message) => { const value = await gm(image.path).identifyPromise(); const delay = value.Delay ? value.Delay[0].split("x") : [0, 100]; const buffer = await gm().delay(`${parseInt(delay[0]) * 2}x${delay[1]}`).out(image.path).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: "slow.gif" - }); + }; }; exports.aliases = ["slowdown", "slower", "gifspeed2"]; diff --git a/commands/sonic.js b/commands/sonic.js index 01bf812..261400e 100644 --- a/commands/sonic.js +++ b/commands/sonic.js @@ -11,10 +11,10 @@ exports.run = async (message, args) => { const cleanedMessage = args.join(" ").replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/${wrap(cleanedMessage, {width: 15, indent: ""})}`).writePromise(file); const buffer = await gm(template).composite(file).gravity("Center").geometry("474x332+160+10").bufferPromise("png", null, "sonic"); - return message.channel.createMessage("", { + return { file: buffer, name: "sonic.png" - }); + }; }; exports.category = 4; diff --git a/commands/speed.js b/commands/speed.js index 845d304..1d4d111 100644 --- a/commands/speed.js +++ b/commands/speed.js @@ -15,18 +15,18 @@ exports.run = async (message) => { const delay = value.Delay ? value.Delay[0].split("x") : [0, 100]; if (Math.round(parseInt(delay[0]) / 2) >= 2) { const buffer = await gm().delay(`${parseInt(delay[0]) / 2}x${delay[1]}`).out(image.path).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: "speed.gif" - }); + }; } else { if (!value.Scene) return `${message.author.mention}, that GIF is already too fast!`; const numbers = (await util.promisify(exec)(`seq 0 2 ${value.Scene.length}`)).stdout.split("\n").join(","); const buffer = await gm().out("(").out(image.path).coalesce().out(")").out("-delete", numbers).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: "speed.gif" - }); + }; } }; diff --git a/commands/spin.js b/commands/spin.js index fc32e9e..bd06355 100644 --- a/commands/spin.js +++ b/commands/spin.js @@ -8,10 +8,10 @@ exports.run = async (message) => { const processMessage = await message.channel.createMessage(" Processing... This might take a while"); const resultBuffer = await gm(image.path).coalesce().out("-duplicate", "29").scale("256x256>").scale("256x256<").background("white").virtualPixel("background").out("-rotate", "%[fx:360*t/n]").set("delay", "5").set("dispose", "background").out("-loop", "0").bufferPromise("gif"); await processMessage.delete(); - return message.channel.createMessage("", { + return { file: resultBuffer, name: "spin.gif" - }); + }; }; exports.aliases = ["rotate"]; diff --git a/commands/stats.js b/commands/stats.js index baa3b89..17975d6 100644 --- a/commands/stats.js +++ b/commands/stats.js @@ -41,7 +41,7 @@ exports.run = async (message) => { ] } }; - return message.channel.createMessage(embed); + return embed; }; exports.aliases = ["status", "stat"]; diff --git a/commands/stretch.js b/commands/stretch.js index 5a9a58d..fdc1206 100644 --- a/commands/stretch.js +++ b/commands/stretch.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to stretch!`; const buffer = await gm(image.path).coalesce().resize("512x512!").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `stretch.${image.type}` - }); + }; }; exports.aliases = ["aspect", "ratio", "aspect43", "43"]; diff --git a/commands/swirl.js b/commands/swirl.js index a0ff74f..d5509e1 100644 --- a/commands/swirl.js +++ b/commands/swirl.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to swirl!`; const buffer = await gm(image.path).coalesce().swirl(180).bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `swirl.${image.type}` - }); + }; }; exports.aliases = ["whirlpool"]; diff --git a/commands/tile.js b/commands/tile.js index fb62471..c912c69 100644 --- a/commands/tile.js +++ b/commands/tile.js @@ -8,10 +8,10 @@ exports.run = async (message) => { if (image === undefined) return `${message.author.mention}, you need to provide an image to tile!`; const output = await gm(image.path).coalesce().command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").streamPromise("miff"); const buffer = await gm(output).coalesce().resize("800x800>").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `tile.${image.type}` - }); + }; }; exports.aliases = ["wall2"]; diff --git a/commands/trump.js b/commands/trump.js index b23cbbe..2c44eaf 100644 --- a/commands/trump.js +++ b/commands/trump.js @@ -8,10 +8,10 @@ exports.run = async (message) => { 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 buffer = await 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").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `trump.${image.type}` - }); + }; }; exports.category = 5; diff --git a/commands/userinfo.js b/commands/userinfo.js index 0579823..37f30f0 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -55,7 +55,7 @@ exports.run = async (message, args) => { ] } }; - return message.channel.createMessage(infoEmbed); + return infoEmbed; }; exports.aliases = ["user"]; diff --git a/commands/waaw.js b/commands/waaw.js index 8ba67c8..7da1597 100644 --- a/commands/waaw.js +++ b/commands/waaw.js @@ -13,10 +13,10 @@ exports.run = async (message) => { await gm(data2).flop().writePromise(data); // const buffer = await gm(data2).extent("%[fx:u.w*2]", "%[fx:u.h]").out("null:").out(data).gravity("West").out("-layers", "Composite").bufferPromise(image.type, image.delay); const buffer = await gm(data2).extent(size.width, size.height).out("null:").out(data).geometry(`+${size.width / 2}+0`).out("-layers", "Composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `waaw.${image.type}` - }); + }; }; exports.aliases = ["magik3", "mirror"]; diff --git a/commands/wall.js b/commands/wall.js index ca31f2a..f06a651 100644 --- a/commands/wall.js +++ b/commands/wall.js @@ -8,10 +8,10 @@ exports.run = async (message) => { if (image === undefined) return `${message.author.mention}, you need to provide an image to make a wall from!`; const output = await gm(image.path).coalesce().resize(128).streamPromise("miff"); const buffer = await 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").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `wall.${image.type}` - }); + }; }; exports.category = 5; diff --git a/commands/wdt.js b/commands/wdt.js index 57dd374..285da64 100644 --- a/commands/wdt.js +++ b/commands/wdt.js @@ -8,10 +8,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!`; const template = "./assets/images/whodidthis.png"; const buffer = await gm(template).out("null:").out("(").out(image.path).coalesce().out(")").gravity("Center").resize("374x374>").out("-layers", "composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `wdt.${image.type}` - }); + }; }; exports.aliases = ["whodidthis"]; diff --git a/commands/wide.js b/commands/wide.js index 1cb8c92..43ad2e5 100644 --- a/commands/wide.js +++ b/commands/wide.js @@ -7,10 +7,10 @@ exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to stretch!`; const buffer = await gm(image.path).coalesce().resize("%[fx:(u.w*19)/2]x%[fx:u.h/2]!").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `wide.${image.type}` - }); + }; }; exports.aliases = ["w19", "wide19"]; diff --git a/commands/wikihow.js b/commands/wikihow.js index 557b614..8aae264 100644 --- a/commands/wikihow.js +++ b/commands/wikihow.js @@ -11,10 +11,10 @@ exports.run = async (message) => { const json = await request.json(); const image = await fetch(json["1"]); const imageBuffer = await image.buffer(); - return message.channel.createMessage("", { + return { file: imageBuffer, name: json["1"].split("/")[json["1"].split("/").length - 1] - }); + }; }; exports.aliases = ["wiki"]; diff --git a/commands/woow.js b/commands/woow.js index 37ebcaf..431952f 100644 --- a/commands/woow.js +++ b/commands/woow.js @@ -11,10 +11,10 @@ exports.run = async (message) => { await gm(image.path).coalesce().gravity("North").crop(0, "50%").out("+repage").writePromise(data2); await gm(data2).flip().writePromise(data); const buffer = await gm(data2).extent("%[fx:u.w]", "%[fx:u.h*2]").out("null:").out(data).gravity("South").out("-layers", "Composite").bufferPromise(image.type, image.delay); - return message.channel.createMessage("", { + return { file: buffer, name: `woow.${image.type}` - }); + }; }; exports.aliases = ["magik5", "mirror3"]; diff --git a/commands/xkcd.js b/commands/xkcd.js index 5b11800..65ccdd0 100644 --- a/commands/xkcd.js +++ b/commands/xkcd.js @@ -16,7 +16,7 @@ exports.run = async (message, args) => { } } }; - return message.channel.createMessage(embed); + return embed; } catch (e) { return `${message.author.mention}, I couldn't get that XKCD!`; } diff --git a/events/messageCreate.js b/events/messageCreate.js index c4c6a7f..60fd184 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -38,8 +38,10 @@ module.exports = async (message) => { logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`); try { const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy - if (typeof result === "string") { + if (typeof result === "string" || (typeof result === "object" && result.embed)) { await client.createMessage(message.channel.id, result); + } else if (typeof result === "object" && result.file) { + await client.createMessage(message.channel.id, result.text ? result.text : "", result); } } catch (error) { if (!error.toString().includes("Request entity too large")) { diff --git a/events/ready.js b/events/ready.js index a790392..fdf4912 100644 --- a/events/ready.js +++ b/events/ready.js @@ -72,7 +72,7 @@ module.exports = async () => { type !== "sonic" ? "-layers" : "", type !== "sonic" ? "OptimizeTransparency" : "" ) - .out("-fuzz", "2%") + .out(type !== "sonic" ? "-fuzz" : "", type !== "sonic" ? "2%" : "") .out("-limit", "memory", "64MB") .out("-limit", "map", "128MB") .stream(format, (err, stdout, stderr) => { diff --git a/utils/client.js b/utils/client.js index 08a4280..9eabe67 100644 --- a/utils/client.js +++ b/utils/client.js @@ -16,7 +16,6 @@ const client = new Client(process.env.TOKEN, { TYPING_START: true, USER_UPDATE: true }, - maxShards: "auto", - opusOnly: true + maxShards: "auto" }); module.exports = client;