2019-09-13 20:02:41 +00:00
const client = require ( "../utils/client.js" ) ;
2020-07-23 20:56:03 +00:00
exports . run = async ( message , args ) => {
2020-09-01 22:10:19 +00:00
if ( ! message . channel . guild ) return ` ${ message . author . mention } , this command only works in servers! ` ;
2019-09-13 20:02:41 +00:00
if ( ! message . member . permission . has ( "banMembers" ) ) return ` ${ message . author . mention } , you need to have the \` Ban Members \` permission on this server to ban people! ` ;
if ( ! message . channel . guild . members . get ( client . user . id ) . permission . has ( "banMembers" ) && ! message . channel . permissionsOf ( client . user . id ) . has ( "banMembers" ) ) return ` ${ message . author . mention } , I don't have the \` Ban Members \` permission! ` ;
const member = message . mentions [ 0 ] ;
if ( member ) {
try {
2020-07-23 20:56:03 +00:00
await message . channel . guild . banMember ( member . id , 0 , ` Ban command used by @ ${ message . author . username } # ${ message . author . discriminator } ` ) ;
2019-09-13 20:02:41 +00:00
return ` Successfully banned ${ member . mention } . ` ;
2020-01-13 16:31:01 +00:00
} catch ( e ) {
2020-07-23 20:56:03 +00:00
return ` ${ message . author . mention } , I was unable to ban the member. They might not exist or I don't have the permissions to do so. ` ;
}
} else if ( args [ 0 ] . match ( /^<?[@#]?[&!]?\d+>?$/ ) && args [ 0 ] >= 21154535154122752 ) {
try {
2020-11-20 21:16:52 +00:00
const id = args [ 0 ] . replace ( /@/g , "" ) . replace ( /#/g , "" ) . replace ( /!/g , "" ) . replace ( /&/g , "" ) . replace ( /</g , "" ) . replace ( />/g , "" ) ;
2020-07-23 20:56:03 +00:00
await message . channel . guild . banMember ( id , 0 , ` Banned by ID, command used by @ ${ message . author . username } # ${ message . author . discriminator } ` ) ;
return ` Successfully banned user with ID \` ${ id } \` . ` ;
} catch ( e ) {
return ` ${ message . author . mention } , I was unable to ban the member. They might not exist or I don't have the permissions to do so. ` ;
2019-09-13 20:02:41 +00:00
}
} else {
return ` ${ message . author . mention } , you need to provide a member to ban! ` ;
}
} ;
2019-12-02 20:47:22 +00:00
2020-07-23 20:56:03 +00:00
exports . aliases = [ "hackban" , "prevent" , "preban" ] ;
2019-12-02 20:47:22 +00:00
exports . category = 2 ;
2019-12-05 16:58:46 +00:00
exports . help = "Bans a server member" ;
2020-07-23 20:56:03 +00:00
exports . params = "[mention/id]" ;