2021-08-23 05:37:09 +00:00
import Command from "../../classes/command.js" ;
2021-10-05 21:48:26 +00:00
import imagedetect from "../../utils/imagedetect.js" ;
2021-08-23 05:37:09 +00:00
class StickerCommand extends Command {
async run ( ) {
2022-03-31 05:42:03 +00:00
const result = await imagedetect ( this . client , this . message , this . interaction , this . options , false , false , true ) ;
2022-09-01 01:00:34 +00:00
this . success = false ;
2021-10-05 21:48:26 +00:00
if ( ! result ) return "You need to provide a sticker!" ;
if ( result . format _type === 1 ) { // PNG
2022-09-01 01:00:34 +00:00
this . success = true ;
2021-10-05 21:48:26 +00:00
return ` https://cdn.discordapp.com/stickers/ ${ result . id } .png ` ;
} else if ( result . format _type === 2 ) { // APNG
2022-09-01 01:00:34 +00:00
this . success = true ;
2021-08-23 05:37:09 +00:00
return {
2021-11-10 04:09:10 +00:00
embeds : [ {
2021-08-23 05:37:09 +00:00
color : 16711680 ,
2021-10-05 21:48:26 +00:00
description : ` [This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/ ${ result . id } .png) ` ,
2021-08-23 05:37:09 +00:00
image : {
2021-10-05 21:48:26 +00:00
url : ` https://cdn.discordapp.com/stickers/ ${ result . id } .png `
2021-08-23 05:37:09 +00:00
}
2021-11-10 04:09:10 +00:00
} ]
2021-08-23 05:37:09 +00:00
} ;
2021-10-05 21:48:26 +00:00
} else if ( result . format _type === 3 ) { // Lottie
2022-09-01 01:00:34 +00:00
this . success = true ;
2021-10-05 21:48:26 +00:00
return ` I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/ ${ result . id } .json ` ;
2021-08-23 05:37:09 +00:00
} else {
return "I don't recognize that sticker format!" ;
}
}
static description = "Gets a raw sticker image" ;
2022-08-27 18:27:42 +00:00
static aliases = [ "stick" ] ;
2021-08-23 05:37:09 +00:00
static arguments = [ "[sticker]" ] ;
}
export default StickerCommand ;