SHARE
TWEET

warn

mal-codes May 19th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.   let warns = JSON.parse(fs.readFileSync("./warnings.json"));;
  3.  
  4.    
  5.    
  6.   client.on('message', async message => {
  7.    
  8.     if (message.author.x5bz) return;
  9.     if (!message.content.startsWith(prefix)) return;
  10.    
  11.    //////////////////////mal ahmed ///////////////mal codes
  12.     let command = message.content.split(" ")[0];
  13.     command = command.slice(prefix.length);
  14.       //////////////////////mal ahmed ///////////////mal codes
  15.     let args = message.content.split(" ").slice(1);
  16.       //////////////////////mal ahmed ///////////////mal codes
  17.     if (command == "warn") {
  18.       //////////////////////mal ahmed ///////////////mal codes
  19.                  if(!message.channel.guild) return message.reply('** This command only for servers**');
  20.               //////////////////////mal ahmed ///////////////mal codes
  21.     if(!message.guild.member(message.author).hasPermission("BAN_MEMBERS")) return message.reply("**You Don't Have ` BAN_MEMBERS ` Permission**");
  22.     let user = message.mentions.users.first();
  23.     let reason = message.content.split(" ").slice(2).join(" ");
  24.    
  25.     if (message.mentions.users.size < 1) return message.reply("**???? ???**");
  26.     if(!reason) return message.reply ("**???? ??? ?????**");
  27.    
  28.       //////////////////////mal ahmed ///////////////mal codes
  29.     if(!warns[user.id]) warns[user.id] = {
  30.       warns: 0
  31.     };
  32.       //////////////////////mal ahmed ///////////////mal codes
  33.     warns[user.id].warns++;
  34.    
  35.     fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
  36.       if (err) console.log(err)
  37.     });
  38.    
  39.       //////////////////////mal ahmed ///////////////mal codes
  40.     const banembed = new Discord.RichEmbed()
  41.     .setAuthor(`WARNED!`, user.displayAvatarURL)
  42.     .setColor("RANDOM")
  43.     .setTimestamp()
  44.     .addField("**User:**",  '**[ ' + `${user.tag}` + ' ]**')
  45.     .addField("**By:**", '**[ ' + `${message.author.tag}` + ' ]**')
  46.     .addField("**Reason:**", '**[ ' + `${reason}` + ' ]**')
  47.      client.channels.find('name', 'log').send({
  48.       embed : banembed
  49.     })
  50.       //////////////////////mal ahmed ///////////////mal codes
  51.       if(warns[user.id].warns == 2){ //??? ???????? ??????
  52.       let muterole = message.guild.roles.find(`name`, "Muted");
  53.       if(!muterole){
  54.         try{
  55.           muterole = await message.guild.createRole({
  56.             name: "Muted",
  57.             color: "#000000",
  58.             permissions:[]
  59.           })   //////////////////////mal ahmed ///////////////mal codes
  60.           message.guild.channels.forEach(async (channel, id) => {
  61.             await channel.overwritePermissions(muterole, {
  62.               SEND_MESSAGES: false,
  63.               ADD_REACTIONS: false
  64.             });
  65.           });
  66.         }catch(e){
  67.           console.log(e.stack);
  68.         }
  69.       }   //////////////////////mal ahmed ///////////////mal codes
  70.      
  71.       let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  72.       if(!tomute) return message.reply("**??? ???? ?????? ?????**:x: ") .then(m => m.delete(5000));
  73.         //////////////////////mal ahmed ///////////////mal codes
  74.       let mutetime = "60s";
  75.       await(tomute.addRole(muterole.id));
  76.       message.channel.send(`<@${user.id}> has been temporarily muted`);
  77.    
  78.       setTimeout(async function(){
  79.       await(tomute.removeRole(muterole.id));
  80.         message.reply(`<@${user.id}> has been unmuted.`)
  81.       }, ms(mutetime))
  82.     }   //////////////////////mal ahmed ///////////////mal codes
  83.     if(warns[user.id].warns == 3){  //??? ???????? ??????
  84.       message.guild.member(user).ban(reason);
  85.       message.reply(`<@${user.id}> has been banned.`)
  86.     }   //////////////////////mal ahmed ///////////////mal codes
  87.    
  88.   }
  89.   }   //////////////////////mal ahmed ///////////////mal codes
  90.   );   //////////////////////mal ahmed ///////////////mal codes
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
 
Top