26 lines
No EOL
1.3 KiB
JavaScript
26 lines
No EOL
1.3 KiB
JavaScript
import ImageCommand from "../../classes/imageCommand.js";
|
|
|
|
class MemeCommand extends ImageCommand {
|
|
params(url) {
|
|
const newArgs = this.args.filter(item => !item.includes(url));
|
|
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
|
|
return {
|
|
top: (this.specialArgs.case ? topText : topText.toUpperCase()).replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%"),
|
|
bottom: bottomText ? (this.specialArgs.case ? bottomText : bottomText.toUpperCase()).replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%") : ""
|
|
};
|
|
}
|
|
|
|
static description = "Generates a meme from an image (separate top/bottom text with a comma)";
|
|
static arguments = ["[top text]", "{bottom text}"];
|
|
static flags = [{
|
|
name: "case",
|
|
description: "Make the meme text case-sensitive (allows for lowercase 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";
|
|
}
|
|
|
|
export default MemeCommand; |