2022-07-30 21:00:09 +00:00
import ImageCommand from "../../classes/imageCommand.js" ;
2022-09-11 04:48:44 +00:00
import { random , textEncode } from "../../utils/misc.js" ;
2022-07-30 21:00:09 +00:00
import { readdirSync } from "fs" ;
import { resolve , dirname } from "path" ;
import { fileURLToPath } from "url" ;
const prompts = [ "you found:" , "your dad is:" , "you ate:" , "your mom is:" , "your sister is:" , "you saw:" , "you get lost in:" , "you find:" , "you grab:" , "you pull out of your pocket:" , "you fight:" , "it's in your room:" ] ;
const names = readdirSync ( resolve ( dirname ( fileURLToPath ( import . meta . url ) ) , "../../assets/images/uncanny/" ) ) . map ( ( val ) => {
return val . split ( "." ) [ 0 ] ;
} ) ;
class UncannyCommand extends ImageCommand {
params ( url , name = "unknown" ) {
2022-08-04 01:54:07 +00:00
const newArgs = this . options . text ? ? this . args . join ( " " ) ;
2022-07-30 21:00:09 +00:00
// eslint-disable-next-line prefer-const
2022-08-04 01:54:07 +00:00
let [ text1 , text2 ] = newArgs . replaceAll ( url , "" ) . split ( /(?<!\\),/ ) . map ( elem => elem . trim ( ) ) ;
2022-07-30 21:00:09 +00:00
if ( ! text2 ? . trim ( ) ) text2 = name ;
return {
2022-09-11 04:48:44 +00:00
caption : text1 ? . trim ( ) ? textEncode ( text1 ) : random ( prompts ) ,
caption2 : textEncode ( text2 ) ,
2022-07-31 01:21:06 +00:00
path : ` ./assets/images/uncanny/ ${ typeof this . options . phase === "string" && names . includes ( this . options . phase . toLowerCase ( ) ) ? this . options . phase . toLowerCase ( ) : random ( names . filter ( ( val ) => val !== "goated" ) ) } .png ` ,
2022-07-30 21:00:09 +00:00
font : typeof this . options . font === "string" && this . constructor . allowedFonts . includes ( this . options . font . toLowerCase ( ) ) ? this . options . font . toLowerCase ( ) : "helvetica"
} ;
}
static init ( ) {
super . init ( ) ;
this . flags . push ( {
name : "font" ,
type : 3 ,
choices : ( ( ) => {
const array = [ ] ;
for ( const font of this . allowedFonts ) {
array . push ( { name : font , value : font } ) ;
}
return array ;
} ) ( ) ,
description : "Specify the font you want to use (default: helvetica)"
} , {
name : "phase" ,
type : 3 ,
choices : ( ( ) => {
const array = [ ] ;
for ( const name of names ) {
array . push ( { name , value : name } ) ;
}
return array ;
} ) ( ) ,
description : "Specify the uncanny image you want to use"
} ) ;
return this ;
}
2022-07-31 01:21:06 +00:00
static textOptional = true ;
2022-07-30 21:00:09 +00:00
static description = "Makes a Mr. Incredible Becomes Uncanny image (separate left/right text with a comma)" ;
static aliases = [ "canny" , "incredible" , "pain" ] ;
static arguments = [ "{left text}" , "{right text}" ] ;
static noImage = "You need to provide an image/GIF to create an uncanny image!" ;
static command = "uncanny" ;
}
export default UncannyCommand ;