SHARE
TWEET

for steve ily

a guest Nov 22nd, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const blacklistjson = JSON.parse(fs.readFileSync('./blacklist.json', 'utf8'));
  3.  
  4. client.on('message', message => {
  5.   if(!blacklistjson[message.guild.id])blacklistjson[message.guild.id] = {
  6.     toggled: "off",
  7.   }
  8.   saveBlacklist();
  9.   var command = message['content'].split(" ")[0],
  10.   newtoggle = message['content'].split(" ")[2],
  11.   toggles = ["on", "off"],
  12.   mention = message['mentions'].users.first(),
  13.   getid = message['content'].split(" ")[2];
  14.  
  15.   switch(command){
  16.     case prefix+'blacklist':
  17.      checkPerms(message, message.author, "MANAGE_GUILD", "You dont have ``MANAGE_SERVER`` permission.");
  18.      if(!message.mentions.users == 1)return message.reply('You have to mention the user or specify a user id.')
  19.      if(!mention){
  20.      //  if(isNaN(getid))return message.reply('User id must be numbers only.')
  21.        var user = client.users.get(getid);
  22.        if(!user)return message.reply('I cant find this user. 😴');
  23.        blacklistjson[message.guild.id+message.author.id] = {
  24.          blacklisted: "yes",
  25.        }
  26.        saveBlacklist();
  27.        message.channel.send(user.tag, " has been blacklisted by "+message.author.tag + ` (ID: ${message.author.id})`)
  28.      }else{
  29.        if(mention == undefined || mention == null)return message.reply('I cant find this user. specify the id of the user.');
  30.        if(message.guild.member(mention).hasPermission("MANAGE_GUILD") && !message.author.id == message.guild.owner.id)return message.reply('Only the ownership can blacklist ADMINISTRATORS members.');
  31.        blacklistjson[message.guild.id+mention.id] = {
  32.          blacklist: "yes",
  33.        }
  34.        saveBlacklist();
  35.      }
  36.      
  37.       break;
  38.     case prefix+'blacklist toggle':
  39.       if(!newtoggle)return message.channel.send("Usage: "+prefix+"blacklist toggle <on/off>");
  40.       checkPerms(message, message.author, "MANAGE_GUILD", "You dont have `MANAGE SERVER` Permission.");
  41.       if(!toggles.includes(newtoggle.toLowerCase()))return message.channel.send("Usage: "+prefix+"blacklist toggle <on/off>");
  42.       blacklistjson[message.guild.id] = {
  43.         toggled: newtoggle,
  44.       }
  45.       message.channel.send("Done toggled blacklist mode to ``"+newtoggle+"``");
  46.       break;
  47.   }
  48. })
  49. client.on('guildMemberAdd', async (member) => {
  50.   if(!blacklistjson[member.guild.id])blacklistjson[member.guild.id] = {
  51.     toggled: "off",
  52.   }
  53.   saveBlacklist();
  54.   if(blacklistjson[member.guild.id].toggled == "on"){
  55.     if(blacklistjson[member.guild.id+member.id].blacklisted == "yes"){
  56.        member.guild.owner.send("The user "+member.user.tag+ " tried to join the serevr but he is blacklisted.").catch(e => console.log(e));
  57.       return member.ban("Blacklisted.");
  58.     }else return;
  59.   }else return;
  60. })
  61.  
  62. function checkPerms(message, member, String, replymessage){
  63.   if(!message.guild.member(member).hasPermission(String))return message.channel.send(replymessage);
  64. }
  65.  
  66. function saveBlacklist(){
  67.   fs.writeFile("./blacklist.json", JSON.stringify(blacklist, null, 2), function (e) {
  68.     if (e) throw e;
  69.   })
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top