2019-09-13 20:02:41 +00:00
const RetroText = require ( "retrotext" ) ;
2021-03-18 14:29:03 +00:00
const { TextStyle , BackgroundStyle } = RetroText ;
2019-09-13 20:02:41 +00:00
exports . run = async ( message , args ) => {
if ( args . length === 0 ) return ` ${ message . author . mention } , you need to provide some text to generate some retro text! ` ;
2019-12-02 20:47:22 +00:00
message . channel . sendTyping ( ) ;
2019-09-13 20:02:41 +00:00
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 ) {
2021-03-18 14:29:03 +00:00
text = new RetroText . default ( ) . setLine1 ( line1 ) . setLine2 ( line2 ) . setLine3 ( line3 ) . setBackgroundStyle ( BackgroundStyle . OUTLINE _TRIANGLE ) . setTextStyle ( TextStyle . CHROME ) ;
2019-09-13 20:02:41 +00:00
} else if ( line2 ) {
2021-03-18 14:29:03 +00:00
text = new RetroText . default ( ) . setLine1 ( line1 ) . setLine2 ( line2 ) . setBackgroundStyle ( BackgroundStyle . OUTLINE _TRIANGLE ) . setTextStyle ( TextStyle . CHROME ) ;
2019-09-13 20:02:41 +00:00
} else {
2021-03-18 14:29:03 +00:00
text = new RetroText . default ( ) . setLine2 ( line1 ) . setBackgroundStyle ( BackgroundStyle . OUTLINE _TRIANGLE ) . setTextStyle ( TextStyle . CHROME ) ;
2019-09-13 20:02:41 +00:00
}
2021-03-18 14:29:03 +00:00
const buffer = await text . fetchBuffer ( ) ;
2020-04-12 19:51:48 +00:00
return {
2021-03-18 14:29:03 +00:00
file : Buffer . from ( buffer ) ,
2019-09-13 20:02:41 +00:00
name : "retro.png"
2020-04-12 19:51:48 +00:00
} ;
2019-12-02 20:47:22 +00:00
} ;
exports . category = 4 ;
2019-12-05 16:58:46 +00:00
exports . help = "Generates a retro text image (separate lines with a comma)" ;
exports . params = "[top text], {middle text}, {bottom text}" ;