import type { Message , Role , TextChannel } from "eris" ; import { Command } from "../../classes/Command" ; import { defaultAvatar } from "../../utils/constants" ; import { dateFormat } from "../../utils/format" ; export class RoleinfoCommand extends Command { description = "Gets information for a role." ; args = "<role:role>" ; aliases = [ "rinfo" ] ; async run ( msg , pargs ) { const role = pargs [ 0 ] . value as Role ; const fields = [ ] ; let membersWithRole = 0 ; msg . channel . guild . members . forEach ( ( m ) => { if ( m . roles . includes ( role . id ) ) membersWithRole ++ ; } ) ; const settings = [ ] ; if ( role . mentionable ) settings . push ( msg . string ( "utility.ROLEINFO_MENTIONABLE" ) ) ; if ( role . hoist ) settings . push ( msg . string ( "utility.ROLEINFO_HOISTED" ) ) ; if ( role . managed ) settings . push ( msg . string ( "utility.ROLEINFO_MANAGED" ) ) ; fields . push ( { name : msg . string ( "global.ID" ) , value : role . id , inline : true , } ) ; if ( role . color !== 0 ) fields . push ( { name : msg . string ( "global.COLOR" ) , value : `#${ role . color . toString ( 16 ) }` , inline : true , } ) ; fields . push ( { name : msg . string ( "global.CREATED" ) , value : `${ dateFormat ( role . createdAt , msg . string ) }` , } ) ; if ( settings . length ) fields . push ( { name : msg . string ( "global.SETTINGS" ) , value : `${ settings . join ( ", " ) }` , } ) ; fields . push ( { name : msg . string ( "global.INFO" ) , value : `${ msg . string ( "utility.ROLEINFO_INFO" , { members : membersWithRole , position : role . position , } ) }` , } ) ; msg . channel . createMessage ( { embed : { color : role . color === 0 ? msg . convertHex ( "general" ) : role . color , fields : fields , author : { icon_url : msg . channel . guild . iconURL || `${ defaultAvatar }` , name : `@${ role . name }` , } , footer : { text : `${ msg . string ( "global.RAN_BY" , { author : msg . tagUser ( msg . author ) } ) }` , icon_url : msg . author . dynamicAvatarURL ( ) , } , } , } ) ; } }