const Discord = module. require ( "discord.js" ) ;

module. exports . run = async ( bot , message , args ) => {

if ( ! message. member . hasPermission ( "MANAGE_ROLES_OR_PERMISSIONS" ) ) return message. reply ( "Sorry buddy, but you can't do that." ) ;

let rMember = message. guild . member ( message. mentions . users . first ( ) ) || message. guild . members . get ( args [ 0 ] ) ;

if ( ! rMember ) return message. reply ( "Couldn't find that user." ) ;

let role = args. join ( " " ) . slice ( 22 ) ;

if ( ! role ) return message. reply ( "please specify a role." ) ;

let gRole = message. guild . roles . find ( `name` , role ) ;

if ( ! gRole ) return message. reply ( "Couldn't find that role." ) ;

if ( rMember. roles . has ( gRole. id ) ) return message. reply ( "They already have that role." ) ;

await ( rMember. addRole ( gRole. id ) ) ;

try {

await rMember. send ( `$ { gRole. name } has been given to you.` )

} catch ( e ) {

message. channel . send ( `$ { rMember. id } has been given role : $ { gRole. name } . We tried to send it to your DMs but they were locked` )

}

}

module. exports . help = {

name : "addrole"