Replaced retro with New And Improved™ variant
This commit is contained in:
		
							parent
							
								
									64ab2b9bc1
								
							
						
					
					
						commit
						2d5eef2c8c
					
				
					 7 changed files with 128 additions and 460 deletions
				
			
		| 
						 | 
				
			
			@ -1,22 +1,31 @@
 | 
			
		|||
const RetroText = require("retrotext");
 | 
			
		||||
const { TextStyle, BackgroundStyle } = RetroText;
 | 
			
		||||
const magick = require("../utils/image.js");
 | 
			
		||||
const wrap = require("../utils/wrap.js");
 | 
			
		||||
 | 
			
		||||
exports.run = async (message, args) => {
 | 
			
		||||
  if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate some retro text!`;
 | 
			
		||||
  message.channel.sendTyping();
 | 
			
		||||
  const [line1, line2, line3] = args.join(" ").split(",").map(elem => elem.trim());
 | 
			
		||||
  if (/^[\w ]+$/i.test(line1) === false || /^[\w ]+$/i.test(line2) === false || /^[\w ]+$/i.test(line3) === false) return `${message.author.mention}, only alphanumeric characters, spaces, and underscores are allowed!`;
 | 
			
		||||
  let text;
 | 
			
		||||
  if (line3) {
 | 
			
		||||
    text = new RetroText.default().setLine1(line1).setLine2(line2).setLine3(line3).setBackgroundStyle(BackgroundStyle.OUTLINE_TRIANGLE).setTextStyle(TextStyle.CHROME);
 | 
			
		||||
  } else if (line2) {
 | 
			
		||||
    text = new RetroText.default().setLine1(line1).setLine2(line2).setBackgroundStyle(BackgroundStyle.OUTLINE_TRIANGLE).setTextStyle(TextStyle.CHROME);
 | 
			
		||||
  let [line1, line2, line3] = args.join(" ").replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%").split(",").map(elem => elem.trim());
 | 
			
		||||
  if (!line2 && line1.length > 15) {
 | 
			
		||||
    const [split1, split2, split3] = wrap(line1, { width: 15, indent: "" }).split("\n");
 | 
			
		||||
    line1 = split1;
 | 
			
		||||
    line2 = split2 ? split2 : "";
 | 
			
		||||
    line3 = split3 ? split3 : "";
 | 
			
		||||
  } else {
 | 
			
		||||
    text = new RetroText.default().setLine2(line1).setBackgroundStyle(BackgroundStyle.OUTLINE_TRIANGLE).setTextStyle(TextStyle.CHROME);
 | 
			
		||||
    if (!line2) {
 | 
			
		||||
      line2 = "";
 | 
			
		||||
    }
 | 
			
		||||
    if (!line3) {
 | 
			
		||||
      line3 = "";
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  const buffer = await text.fetchBuffer();
 | 
			
		||||
  const { buffer } = await magick.run({
 | 
			
		||||
    cmd: "retro",
 | 
			
		||||
    line1,
 | 
			
		||||
    line2,
 | 
			
		||||
    line3
 | 
			
		||||
  });
 | 
			
		||||
  return {
 | 
			
		||||
    file: Buffer.from(buffer),
 | 
			
		||||
    file: buffer,
 | 
			
		||||
    name: "retro.png"
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue