2022-01-18 19:05:39 +00:00
import Command from "../../classes/command.js" ;
class BannerCommand extends Command {
async run ( ) {
if ( this . message . mentions [ 0 ] ) {
return this . message . mentions [ 0 ] . banner ? this . message . mentions [ 0 ] . dynamicBannerURL ( null , 1024 ) : "This user doesn't have a banner!" ;
} else if ( await this . ipc . fetchUser ( this . args [ 0 ] ) ) {
const user = await this . ipc . fetchUser ( this . args [ 0 ] ) ;
return user . banner ? this . client . _formatImage ( ` /banners/ ${ user . id } / ${ user . banner } ` , null , 1024 ) : "This user doesn't have a banner!" ;
} else if ( this . args [ 0 ] && this . args [ 0 ] . match ( /^<?[@#]?[&!]?\d+>?$/ ) && this . args [ 0 ] >= 21154535154122752 n ) {
try {
const user = await this . client . getRESTUser ( this . args [ 0 ] ) ;
return user . banner ? this . client . _formatImage ( ` /banners/ ${ user . id } / ${ user . banner } ` , null , 1024 ) : "This user doesn't have a banner!" ;
} catch {
2022-03-31 05:42:03 +00:00
return this . author . banner ? this . author . dynamicBannerURL ( null , 1024 ) : "You don't have a banner!" ;
2022-01-18 19:05:39 +00:00
}
2022-03-31 05:42:03 +00:00
} else if ( this . args . join ( " " ) !== "" && this . channel . guild ) {
2022-01-18 19:05:39 +00:00
const userRegex = new RegExp ( this . args . join ( "|" ) , "i" ) ;
2022-03-31 05:42:03 +00:00
const member = this . channel . guild . members . find ( element => {
2022-01-18 19:05:39 +00:00
return userRegex . test ( element . nick ) ? ? userRegex . test ( element . username ) ;
} ) ;
2022-03-31 05:42:03 +00:00
return member && member . user . banner ? member . user . dynamicBannerURL ( null , 1024 ) : ( this . author . banner ? this . author . dynamicBannerURL ( null , 1024 ) : "This user doesn't have a banner!" ) ;
2022-01-18 19:05:39 +00:00
} else {
2022-03-31 05:42:03 +00:00
return this . author . banner ? this . author . dynamicBannerURL ( null , 1024 ) : "You don't have a banner!" ;
2022-01-18 19:05:39 +00:00
}
}
static description = "Gets a user's banner" ;
static aliases = [ "userbanner" ] ;
static arguments = [ "{mention/id}" ] ;
2022-03-31 19:53:22 +00:00
static slashAllowed = false ;
2022-01-18 19:05:39 +00:00
}
export default BannerCommand ;