2020-01-25 11:18:38 +00:00
exports . run = async ( client , message , [ action , ... member ] ) => {
const settings = message . settings ;
if ( settings . blacklisted == "ARRAY" ) {
await client . settings . set ( message . guild . id , [ ] , "blacklisted" ) ;
}
if ( ! action ) {
return message . channel . send (
2020-08-16 08:19:28 +00:00
` <:error:466995152976871434> You didn't tell me if I was meant to add or remove someone from the blocklist! Usage: \` ${ client . commands . get ( ` blocklist ` ) . help . usage } \` `
2020-01-25 11:18:38 +00:00
)
}
member = member . join ( " " )
if ( ! member ) {
return message . channel . send (
2020-08-16 08:19:28 +00:00
` <:error:466995152976871434> You didn't tell me who to add to the blocklist! Usage: \` ${ client . commands . get ( ` blocklist ` ) . help . usage } \` `
2020-01-25 11:18:38 +00:00
) ;
} ;
let user = message . mentions . members . first ( ) ;
if ( action == "add" ) {
if ( ! user ) {
let users ;
users = client . searchForMembers ( message . guild , member ) ;
if ( users . length > 1 )
return message . channel . send (
"<:error:466995152976871434> Found multiple users! Please be more specific or mention the user instead."
) ;
else if ( users . length == 0 )
return message . channel . send (
"<:error:466995152976871434> That user doesn't seem to exist. Try again!"
) ;
user = users [ 0 ] ;
} ;
if ( user . id === client . user . id ) {
return message . channel . send ( 'lol no' ) ;
} ;
2020-01-25 11:36:54 +00:00
if ( user . id === message . guild . owner . id ) {
2020-08-16 08:19:28 +00:00
return message . channel . send ( "<:error:466995152976871434> You can't add the owner to the blocklist!" )
2020-01-25 11:36:54 +00:00
} ;
let admin = message . guild . member ( message . author )
2020-03-09 01:11:33 +00:00
if ( user . roles . highest . position >= admin . roles . highest . position && admin . user . id !== message . guild . ownerID ) {
2020-01-25 11:36:54 +00:00
return message . channel . send (
2020-08-16 08:19:28 +00:00
` <:error:466995152976871434> You can't add people higher ranked than yourself to the blocklist! `
2020-01-25 11:36:54 +00:00
) ;
} ;
2020-01-25 11:18:38 +00:00
if ( user . id === message . member . id ) {
2020-08-16 08:19:28 +00:00
return message . channel . send ( '<:error:466995152976871434> You can\'t add yourself to the blocklist!' ) ;
2020-01-25 11:18:38 +00:00
} ;
let blacklisted = false ;
if ( settings . blacklisted . length > 0 ) {
settings . blacklisted . forEach ( function ( ID ) {
if ( ID == user . id ) {
blacklisted = true ;
}
} ) ;
if ( blacklisted == true ) {
2020-08-16 08:19:28 +00:00
return message . channel . send ( '<:error:466995152976871434> This person is already on the blocklist!' ) ;
2020-01-25 11:18:38 +00:00
} ;
} ;
client . settings . push ( message . guild . id , user . id , "blacklisted" )
2020-08-16 08:19:28 +00:00
return message . channel . send ( ` <:success:466995111885144095> Added \` ${ user . user . tag } \` to the blocklist. ` )
2020-01-25 11:18:38 +00:00
} ;
if ( action == "remove" ) {
if ( ! user ) {
let users ;
users = client . searchForMembers ( message . guild , member ) ;
if ( users . length > 1 )
return message . channel . send (
"<:error:466995152976871434> Found multiple users! Please be more specific or mention the user instead."
) ;
else if ( users . length == 0 )
return message . channel . send (
"<:error:466995152976871434> That user doesn't seem to exist. Try again!"
) ;
user = users [ 0 ] ;
} ;
let blacklisted = false ;
settings . blacklisted . forEach ( function ( ID ) {
if ( ID == user . id ) {
blacklisted = true ;
}
} ) ;
if ( blacklisted != true ) {
2020-08-16 08:19:28 +00:00
return message . channel . send ( '<:error:466995152976871434> This user isn\'t on the blocklist!' ) ;
2020-01-25 11:18:38 +00:00
} ;
client . settings . remove ( message . guild . id , user . id , "blacklisted" )
2020-08-16 08:19:28 +00:00
return message . channel . send ( ` <:success:466995111885144095> Removed \` ${ user . user . tag } \` from the blocklist. ` )
2020-01-25 11:18:38 +00:00
} ;
} ;
exports . conf = {
enabled : true ,
guildOnly : true ,
2020-08-16 08:19:28 +00:00
aliases : [ 'bl' ] ,
2020-01-25 11:18:38 +00:00
permLevel : "Administrator" ,
requiredPerms : [ ]
} ;
exports . help = {
2020-08-16 08:19:28 +00:00
name : "blocklist" ,
2020-01-25 11:18:38 +00:00
category : "Moderation" ,
2020-08-16 08:19:28 +00:00
description : "Allows you to configure Woomy's blocklist. Users on the blocklist cannot use commands." ,
usage : "blocklist [add/remove] [member]"
2020-01-25 11:18:38 +00:00
} ;