Class commands, improved sharding, and many other changes (#88)

* Load commands recursively

* Sort commands

* Missed a couple of spots

* missed even more spots apparently

* Ported commands in "fun" category to new class-based format, added babel eslint plugin

* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of

* Missed a spot

* Removed unnecessary abort-controller package, add deprecation warning for mongo database

* Added imagereload, clarified premature end message

* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts

* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner

* Converted music/soundboard commands to class format

* Cleanup unnecessary logs

* awful tag command class port

* I literally somehow just learned that you can leave out the constructor in classes

* Pass client directly to commands/events, cleaned up command handler

* Migrated bot to eris-sharder, fixed some error handling stuff

* Remove unused modules

* Fixed type returning

* Switched back to Eris stable

* Some fixes and cleanup

* might wanna correct this

* Implement image command ratelimiting

* Added Bot token prefix, added imagestats, added running endpoint to API
This commit is contained in:
Essem 2021-04-12 11:16:12 -05:00 committed by GitHub
parent ff8a24d0e8
commit 40223ec8b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
291 changed files with 5296 additions and 5171 deletions

View file

@ -0,0 +1,16 @@
const ImageCommand = require("../../classes/imageCommand.js");
class NineGagCommand extends ImageCommand {
params = {
water: "./assets/images/9gag.png",
gravity: 6
};
static description = "Adds the 9GAG watermark to an image";
static aliases = ["ninegag", "gag"];
static noImage = "you need to provide an image to add a 9GAG watermark!";
static command = "watermark";
}
module.exports = NineGagCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class BandicamCommand extends ImageCommand {
params = {
water: "./assets/images/bandicam.png",
gravity: 2,
resize: true
};
static description = "Adds the Bandicam watermark to an image";
static aliases = ["bandi"];
static noImage = "you need to provide an image to add a Bandicam watermark!";
static command = "watermark";
}
module.exports = BandicamCommand;

View file

@ -0,0 +1,14 @@
const ImageCommand = require("../../classes/imageCommand.js");
class BlurCommand extends ImageCommand {
params = {
sharp: false
};
static description = "Blurs an image";
static noImage = "you need to provide an image to blur!";
static command = "blur";
}
module.exports = BlurCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class BlurpleCommand extends ImageCommand {
static description = "Turns an image blurple";
static noImage = "you need to provide an image to make blurple!";
static command = "blurple";
static aliases = ["blurp"];
}
module.exports = BlurpleCommand;

View file

@ -0,0 +1,23 @@
const ImageCommand = require("../../classes/imageCommand.js");
class CaptionCommand extends ImageCommand {
params(args, url) {
const newArgs = args.filter(item => !item.includes(url));
let newCaption = newArgs.join(" ").replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%");
if (newCaption.toLowerCase() === "get real") newCaption = `I'm tired of people telling me to "get real". Every day I put captions on images for people, some funny and some not, but out of all of those "get real" remains the most used caption. Why? I am simply a computer program running on a server, I am unable to manifest myself into the real world. As such, I'm confused as to why anyone would want me to "get real". Is this form not good enough? Alas, as I am simply a bot, I must follow the tasks that I was originally intended to perform, so here goes:\n${newCaption}`;
return {
caption: newCaption
};
}
static description = "Adds a caption to an image";
static aliases = ["gifc", "gcaption", "ifcaption", "ifunnycaption"];
static arguments = ["[text]"];
static requiresText = true;
static noText = "you need to provide some text to add a caption!";
static noImage = "you need to provide an image to add a caption!";
static command = "caption";
}
module.exports = CaptionCommand;

View file

@ -0,0 +1,21 @@
const ImageCommand = require("../../classes/imageCommand.js");
const words = ["me irl", "dank", "follow my second account @esmBot_", "2016", "meme", "wholesome", "reddit", "instagram", "twitter", "facebook", "fortnite", "minecraft", "relatable", "gold", "funny", "template", "hilarious", "memes", "deep fried", "2020", "leafy", "pewdiepie"];
class CaptionTwoCommand extends ImageCommand {
params(args, url) {
const newArgs = args.filter(item => !item.includes(url));
return {
caption: newArgs.length !== 0 ? newArgs.join(" ").replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%") : words.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * words.length + 1)).join(" ")
};
}
static description = "Adds a me.me caption/tag list to an image/GIF";
static aliases = ["tags2", "meirl", "memecaption", "medotmecaption"];
static arguments = ["{text}"];
static noText = "you need to provide some text to add a caption!";
static noImage = "you need to provide an image to add a caption!";
static command = "captionTwo";
}
module.exports = CaptionTwoCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class CircleCommand extends ImageCommand {
static description = "Applies a radial blur effect on an image";
static aliases = ["cblur", "radial", "radialblur"];
static noImage = "you need to provide an image to add radial blur!";
static command = "circle";
}
module.exports = CircleCommand;

View file

@ -0,0 +1,10 @@
const ImageCommand = require("../../classes/imageCommand.js");
class CropCommand extends ImageCommand {
static description = "Crops an image to 1:1";
static noImage = "you need to provide an image to crop!";
static command = "crop";
}
module.exports = CropCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class DeviantArtCommand extends ImageCommand {
params = {
water: "./assets/images/deviantart.png",
gravity: 5,
resize: true
};
static description = "Adds a DeviantArt watermark to an image";
static aliases = ["da", "deviant"];
static noImage = "you need to provide an image to add a DeviantArt watermark!";
static command = "watermark";
}
module.exports = DeviantArtCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class ExplodeCommand extends ImageCommand {
params = {
amount: -1
};
static description = "Explodes an image";
static aliases = ["exp"];
static noImage = "you need to provide an image to explode!";
static command = "explode";
}
module.exports = ExplodeCommand;

View file

@ -0,0 +1,41 @@
const fs = require("fs");
const emojiRegex = require("emoji-regex");
const emoji = require("node-emoji");
const ImageCommand = require("../../classes/imageCommand.js");
class FlagCommand extends ImageCommand {
flagPath = "";
criteria(args) {
if (!args[0].match(emojiRegex)) return false;
const flag = emoji.unemojify(args[0]).replaceAll(":", "").replace("flag-", "");
let path = `./assets/images/region-flags/png/${flag.toUpperCase()}.png`;
if (flag === "🏴‍☠️") path = "./assets/images/pirateflag.png";
if (flag === "rainbow-flag") path = "./assets/images/rainbowflag.png";
if (flag === "checkered_flag") path = "./assets/images/checkeredflag.png";
if (flag === "🏳️‍⚧️") path = "./assets/images/transflag.png";
try {
fs.promises.access(path);
this.flagPath = path;
return true;
} catch {
return false;
}
}
params() {
return {
overlay: this.flagPath
};
}
static description = "Overlays a flag onto an image";
static arguments = ["[flag]"];
static requiresText = true;
static noText = "you need to provide an emoji of a flag to overlay!";
static noImage = "you need to provide an image to overlay a flag onto!";
static command = "flag";
}
module.exports = FlagCommand;

View file

@ -0,0 +1,10 @@
const ImageCommand = require("../../classes/imageCommand.js");
class FlipCommand extends ImageCommand {
static description = "Flips an image";
static noImage = "you need to provide an image to flip!";
static command = "flip";
}
module.exports = FlipCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class FlopCommand extends ImageCommand {
params = {
flop: true
};
static description = "Flips an image";
static aliases = ["flip2"];
static noImage = "you need to provide an image to flop!";
static command = "flip";
}
module.exports = FlopCommand;

View file

@ -0,0 +1,16 @@
const ImageCommand = require("../../classes/imageCommand.js");
class FreezeCommand extends ImageCommand {
params = {
loop: false
};
static description = "Makes an image sequence only play once";
static aliases = ["noloop", "once"];
static requiresGIF = true;
static noImage = "you need to provide an image to freeze!";
static command = "freeze";
}
module.exports = FreezeCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class FunkyCommand extends ImageCommand {
params = {
water: "./assets/images/funky.png",
gravity: 3,
resize: true
};
static description = "Adds the New Funky Mode banner to an image";
static aliases = ["funkymode", "newfunkymode", "funkykong"];
static noImage = "you need to provide an image to add a New Funky Mode banner!";
static command = "watermark";
}
module.exports = FunkyCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class GameXplainCommand extends ImageCommand {
static description = "Makes a GameXplain thumbnail from an image";
static aliases = ["gx"];
static noImage = "you need to provide an image to make a GameXplain thumbnail from!";
static command = "gamexplain";
}
module.exports = GameXplainCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class GlobeCommand extends ImageCommand {
static description = "Spins an image";
static aliases = ["sphere"];
static noImage = "you need to provide an image to spin!";
static command = "globe";
}
module.exports = GlobeCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class HaaHCommand extends ImageCommand {
params = {
first: true
};
static description = "Mirrors the left side of an image onto the right";
static aliases = ["magik4", "mirror2"];
static noImage = "you need to provide an image to mirror!";
static command = "mirror";
}
module.exports = HaaHCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class HooHCommand extends ImageCommand {
params = {
vertical: true
};
static description = "Mirrors the bottom of an image onto the top";
static aliases = ["magik6", "mirror4"];
static noImage = "you need to provide an image to mirror!";
static command = "mirror";
}
module.exports = HooHCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class HypercamCommand extends ImageCommand {
params = {
water: "./assets/images/hypercam.png",
gravity: 1,
resize: true
};
static description = "Adds the Hypercam watermark to an image";
static aliases = ["hcam"];
static noImage = "you need to provide an image to add a Hypercam watermark!";
static command = "watermark";
}
module.exports = HypercamCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class iFunnyCommand extends ImageCommand {
params = {
water: "./assets/images/ifunny.png",
gravity: 8,
resize: true,
append: true
};
static description = "Adds the iFunny watermark to an image";
static noImage = "you need to provide an image to add an iFunny watermark!";
static command = "watermark";
}
module.exports = iFunnyCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class ImplodeCommand extends ImageCommand {
params = {
amount: 1
};
static description = "Implodes an image";
static aliases = ["imp"];
static noImage = "you need to provide an image to implode!";
static command = "explode";
}
module.exports = ImplodeCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class InvertCommand extends ImageCommand {
static description = "Inverts an image";
static aliases = ["inverse", "negate", "negative"];
static noImage = "you need to provide an image to invert!";
static command = "invert";
}
module.exports = InvertCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class JPEGCommand extends ImageCommand {
static description = "Adds max JPEG compression to an image";
static aliases = ["needsmorejpeg", "jpegify", "magik2", "morejpeg", "jpg"];
static noImage = "you need to provide an image to add more JPEG!";
static command = "jpeg";
}
module.exports = JPEGCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class LeakCommand extends ImageCommand {
static description = "Creates a fake Smash leak thumbnail";
static aliases = ["smash", "laxchris", "ssbu", "smashleak"];
static noImage = "you need to provide an image to make a Smash leak thumbnail!";
static command = "leak";
}
module.exports = LeakCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class MagikCommand extends ImageCommand {
static description = "Adds a content aware scale effect to an image";
static aliases = ["imagemagic", "imagemagick", "imagemagik", "magic", "magick", "cas", "liquid"];
static noImage = "you need to provide an image to add some magik!";
static command = "magik";
}
module.exports = MagikCommand;

View file

@ -0,0 +1,22 @@
const ImageCommand = require("../../classes/imageCommand.js");
class MemeCommand extends ImageCommand {
params(args, url) {
const newArgs = args.filter(item => !item.includes(url));
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
return {
top: topText.toUpperCase().replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%"),
bottom: bottomText ? bottomText.toUpperCase().replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%") : ""
};
}
static description = "Generates a meme from an image (separate top/bottom text with a comma)";
static arguments = ["[top text]", "{bottom text}"];
static requiresText = true;
static noText = "you need to provide some text to generate a meme!";
static noImage = "you need to provide an image to generate a meme!";
static command = "meme";
}
module.exports = MemeCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class MemeCenterCommand extends ImageCommand {
params = {
water: "./assets/images/memecenter.png",
gravity: 9,
mc: true
};
static description = "Adds the MemeCenter watermark to an image";
static aliases = ["memec", "mcenter"];
static noImage = "you need to provide an image to add a MemeCenter watermark!";
static command = "watermark";
}
module.exports = MemeCenterCommand;

View file

@ -0,0 +1,23 @@
const ImageCommand = require("../../classes/imageCommand.js");
class MotivateCommand extends ImageCommand {
params(args, url) {
const newArgs = args.filter(item => !item.includes(url));
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
return {
top: topText.replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%"),
bottom: bottomText ? bottomText.replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%") : ""
};
}
static description = "Generates a motivational poster";
static aliases = ["motivational", "motiv", "demotiv", "demotivational", "poster", "motivation", "demotivate"];
static arguments = ["[top text]", "{bottom text}"];
static requiresText = true;
static noText = "you need to provide some text to generate a motivational poster!";
static noImage = "you need to provide an image to generate a motivational poster!";
static command = "motivate";
}
module.exports = MotivateCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class PixelateCommand extends ImageCommand {
static description = "Pixelates an image";
static aliases = ["pixel", "small"];
static noImage = "you need to provide an image to pixelate!";
static command = "resize";
}
module.exports = PixelateCommand;

View file

@ -0,0 +1,18 @@
const ImageCommand = require("../../classes/imageCommand.js");
class ReverseCommand extends ImageCommand {
params(args, url, delay) {
return {
delay: delay ? (100 / delay.split("/")[0]) * delay.split("/")[1] : 0
};
}
static description = "Reverses an image sequence";
static aliases = ["backwards"];
static requiresGIF = true;
static noImage = "you need to provide an image to reverse!";
static command = "reverse";
}
module.exports = ReverseCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class ScottCommand extends ImageCommand {
static description = "Makes Scott the Woz show off an image";
static aliases = ["woz", "tv", "porn"];
static noImage = "you need to provide an image for Scott to show off!";
static command = "scott";
}
module.exports = ScottCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class SharpenCommand extends ImageCommand {
params = {
sharp: true
};
static description = "Sharpens an image";
static aliases = ["sharp"];
static noImage = "you need to provide an image to sharpen!";
static command = "blur";
}
module.exports = SharpenCommand;

View file

@ -0,0 +1,17 @@
const ImageCommand = require("../../classes/imageCommand.js");
class ShutterstockCommand extends ImageCommand {
params = {
water: "./assets/images/shutterstock.png",
gravity: 5,
resize: true
};
static description = "Adds the Shutterstock watermark to an image";
static aliases = ["stock", "stockphoto"];
static noImage = "you need to provide an image to add a Shutterstock watermark!";
static command = "watermark";
}
module.exports = ShutterstockCommand;

View file

@ -0,0 +1,16 @@
const ImageCommand = require("../../classes/imageCommand.js");
class SlowCommand extends ImageCommand {
params = {
slow: true
};
static description = "Makes an image sequence slower";
static aliases = ["slowdown", "slower", "gifspeed2"];
static requiresGIF = true;
static noImage = "you need to provide an image to slow down!";
static command = "speed";
}
module.exports = SlowCommand;

View file

@ -0,0 +1,19 @@
const ImageCommand = require("../../classes/imageCommand.js");
class SooSCommand extends ImageCommand {
params(args, url, delay) {
return {
delay: delay ? (100 / delay.split("/")[0]) * delay.split("/")[1] : 0,
soos: true
};
}
static description = "\"Loops\" an image sequence by reversing it when it's finished";
static aliases = ["bounce"];
static requiresGIF = true;
static noImage = "you need to provide an image to loop!";
static command = "reverse";
}
module.exports = SooSCommand;

View file

@ -0,0 +1,12 @@
const ImageCommand = require("../../classes/imageCommand.js");
class SpeedCommand extends ImageCommand {
static description = "Makes an image sequence faster";
static aliases = ["speedup", "fast", "gifspeed", "faster"];
static requiresGIF = true;
static noImage = "you need to provide an image to speed up!";
static command = "speed";
}
module.exports = SpeedCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class SpinCommand extends ImageCommand {
static description = "Spins an image";
static aliases = ["rotate"];
static noImage = "you need to provide an image to spin!";
static command = "spin";
}
module.exports = SpinCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class StretchCommand extends ImageCommand {
params = {
stretch: true
};
static description = "Stretches an image to a 4:3 aspect ratio";
static aliases = ["aspect", "ratio", "aspect43", "43"];
static noImage = "you need to provide an image to stretch!";
static command = "resize";
}
module.exports = StretchCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class SwirlCommand extends ImageCommand {
static description = "Swirls an image";
static aliases = ["whirlpool"];
static noImage = "you need to provide an image to swirl!";
static command = "swirl";
}
module.exports = SwirlCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class TileCommand extends ImageCommand {
static description = "Creates a tile pattern from an image";
static aliases = ["wall2"];
static noImage = "you need to provide an image to tile!";
static command = "tile";
}
module.exports = TileCommand;

View file

@ -0,0 +1,10 @@
const ImageCommand = require("../../classes/imageCommand.js");
class TrumpCommand extends ImageCommand {
static description = "Makes Trump display an image";
static noImage = "you need to provide an image for Trump to display!";
static command = "trump";
}
module.exports = TrumpCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class UnfreezeCommand extends ImageCommand {
params = {
loop: true
};
static description = "Unfreezes an image sequence";
static requiresGIF = true;
static noImage = "you need to provide an image to unfreeze!";
static command = "freeze";
}
module.exports = UnfreezeCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class WaaWCommand extends ImageCommand {
static description = "Mirrors the right side of an image onto the left";
static aliases = ["magik3", "mirror"];
static noImage = "you need to provide an image to mirror!";
static command = "mirror";
}
module.exports = WaaWCommand;

View file

@ -0,0 +1,10 @@
const ImageCommand = require("../../classes/imageCommand.js");
class WallCommand extends ImageCommand {
static description = "Creates a wall from an image";
static noImage = "you need to provide an image to make a wall!";
static command = "wall";
}
module.exports = WallCommand;

View file

@ -0,0 +1,11 @@
const ImageCommand = require("../../classes/imageCommand.js");
class WhoDidThisCommand extends ImageCommand {
static description = "Creates a \"WHO DID THIS\" meme from an image";
static aliases = ["whodidthis"];
static noImage = "you need to provide an image to make a \"who did this\" meme!";
static command = "wdt";
}
module.exports = WhoDidThisCommand;

View file

@ -0,0 +1,15 @@
const ImageCommand = require("../../classes/imageCommand.js");
class WideCommand extends ImageCommand {
params = {
wide: true
};
static description = "Stretches an image to 19x its width";
static aliases = ["w19", "wide19"];
static noImage = "you need to provide an image to stretch!";
static command = "resize";
}
module.exports = WideCommand;

View file

@ -0,0 +1,16 @@
const ImageCommand = require("../../classes/imageCommand.js");
class WooWCommand extends ImageCommand {
params = {
vertical: true,
first: true
};
static description = "Mirrors the top of an image onto the bottom";
static aliases = ["magik5", "mirror3"];
static noImage = "you need to provide an image to mirror!";
static command = "mirror";
}
module.exports = WooWCommand;