Remove delay parameter, change argument handling, make help command show proper flag types

This commit is contained in:
Essem 2022-06-07 18:26:40 -05:00
parent 28f0245652
commit 6b34cb9d9e
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
63 changed files with 82 additions and 219 deletions

View file

@ -3,7 +3,7 @@ const allowedFonts = ["futura", "impact", "helvetica", "arial", "roboto", "noto"
class CaptionCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
let newCaption = newArgs.replaceAll("&", "&amp;").replaceAll(">", "&gt;").replaceAll("<", "&lt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;").replaceAll("\\n", "\n");
if (process.env.NODE_ENV === "development" && newCaption.toLowerCase() === "get real" && !this.specialArgs.noEgg) 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 {

View file

@ -4,7 +4,7 @@ const allowedFonts = ["futura", "impact", "helvetica", "arial", "roboto", "noto"
class CaptionTwoCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
return {
caption: newArgs && newArgs.trim() ? newArgs.replaceAll("&", "&amp;").replaceAll(">", "&gt;").replaceAll("<", "&lt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;").replaceAll("%", "%").replaceAll("\\n", "\n") : words.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * words.length + 1)).join(" "),
top: !!this.specialArgs.top,

View file

@ -7,7 +7,7 @@ class FlagCommand extends ImageCommand {
flagPath = "";
async criteria() {
const text = this.type === "classic" ? this.args[0] : this.options.text;
const text = this.options.text ?? this.args[0];
if (!text.match(emojiRegex)) return false;
const flag = emoji.unemojify(text).replaceAll(":", "").replace("flag-", "");
let path = `assets/images/region-flags/png/${flag.toUpperCase()}.png`;

View file

@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class FreezeCommand extends ImageCommand {
params() {
const frameCount = parseInt(this.type === "classic" ? this.args[0] : this.options.endframe);
const frameCount = parseInt(this.options.endframe ?? this.args[0]);
return {
loop: false,
frame: isNaN(frameCount) ? -1 : frameCount

View file

@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class JPEGCommand extends ImageCommand {
params() {
const quality = parseInt(this.type === "classic" ? this.args[0] : this.options.quality);
const quality = parseInt(this.options.quality ?? this.args[0]);
return {
quality: isNaN(quality) ? 1 : Math.max(1, Math.min(quality, 100))
};

View file

@ -3,7 +3,7 @@ const allowedFonts = ["futura", "impact", "helvetica", "arial", "roboto", "noto"
class MemeCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
const [topText, bottomText] = newArgs.split(/(?<!\\),/).map(elem => elem.trim());
return {
top: (this.specialArgs.case ? topText : topText.toUpperCase()).replaceAll("&", "&amp;").replaceAll(">", "&gt;").replaceAll("<", "&lt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;").replaceAll("\\n", "\n"),

View file

@ -3,7 +3,7 @@ const allowedFonts = ["futura", "impact", "helvetica", "arial", "roboto", "noto"
class MotivateCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
const [topText, bottomText] = newArgs.split(/(?<!\\),/).map(elem => elem.trim());
return {
top: topText.replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%"),

View file

@ -1,10 +1,10 @@
import ImageCommand from "../../classes/imageCommand.js";
import { random } from "../../utils/misc.js";
const names = ["esmBot", "me_irl", "dankmemes", "hmmm", "gaming", "wholesome", "chonkers", "memes", "funny", "pcmasterrace", "thomastheplankengine"];
const names = ["esmBot", "me_irl", "dankmemes", "hmmm", "gaming", "wholesome", "chonkers", "memes", "funny", "lies"];
class RedditCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
return {
caption: newArgs && newArgs.trim() ? newArgs.replaceAll("\n", "").replaceAll(" ", "") : random(names)
};

View file

@ -1,12 +1,6 @@
import ImageCommand from "../../classes/imageCommand.js";
class ReverseCommand extends ImageCommand {
params(url, delay) {
return {
delay: delay ? (100 / delay.split("/")[0]) * delay.split("/")[1] : 0
};
}
static description = "Reverses an image sequence";
static aliases = ["backwards"];

View file

@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class SlowCommand extends ImageCommand {
params() {
const speed = parseInt(this.type === "classic" ? this.args[0] : this.options.multiplier);
const speed = parseInt(this.options.multiplier ?? this.args[0]);
return {
slow: true,
speed: isNaN(speed) ? 2 : speed

View file

@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class SnapchatCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
const position = parseFloat(this.specialArgs.position);
return {
caption: newArgs.replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%"),

View file

@ -1,9 +1,8 @@
import ImageCommand from "../../classes/imageCommand.js";
class SooSCommand extends ImageCommand {
params(url, delay) {
params() {
return {
delay: delay ? (100 / delay.split("/")[0]) * delay.split("/")[1] : 0,
soos: true
};
}

View file

@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class SpeedCommand extends ImageCommand {
params() {
const speed = parseInt(this.type === "classic" ? this.args[0] : this.options.multiplier);
const speed = parseInt(this.options.multiplier ?? this.args[0]);
return {
speed: isNaN(speed) || speed < 1 ? 2 : speed
};

View file

@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class WhisperCommand extends ImageCommand {
params(url) {
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
const newArgs = this.options.text ?? this.args.filter(item => !item.includes(url)).join(" ");
return {
caption: newArgs.replaceAll("&", "&amp;").replaceAll(">", "&gt;").replaceAll("<", "&lt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;").replaceAll("\\n", "\n")
};