text: const http = require('http');
  const express = require('express');
  const app = express();
  app.get("/", (request, response) => {
    response.sendStatus(200);
  });
  app.listen(process.env.PORT);
  setInterval(() => {
    http.get(`http://.glitch.me/`);
  }, 280000);
  
  const Discord = require('discord.js');  
  const client = new Discord.Client();  
  const moment = require('moment');
  const zalgo = require('zalgolize');  
  const math = require('math-expression-evaluator');   
  const figlet = require('figlet');   
  const fs = require('fs');  
  const ms = require('ms');  
  const canvas = require("canvas");
  const convert = require("hh-mm-ss");
  const fetchVideoInfo = require("youtube-info");
  const simpleytapi = require('simple-youtube-api')
  const util = require("util")
  const gif = require("gif-search");
  const jimp = require("jimp");
  const guild = require('guild');
  const request = require('request');
  const dateFormat = require('dateformat');
  const hastebins = require('hastebin-gen');
  const { get } = require('snekfetch');
  const opus = require("node-opus");
  const getYoutubeID = require('get-youtube-id');
  const pretty = require("pretty-ms");
  const { prefix, devs } = require("./config");
  client.login(process.env.TOKEN);
  
  
  
  
  //كود تغيير الحالة
  client.on("ready", () => {
    console.log(`Logged in as ${client.user.tag}!`);
    console.log(client.guilds.map(c => `${c.name} : ${c.me.hasPermission(8)}`));
    client.user.setStatus("online");
  
    client.user.setActivity(`${prefix}help`, { type: "WATCHING" });
  });
  
  
  //برود كاست
  client.on('message', message => {
    if(!message.channel.guild) return;
  if (message.content.startsWith(prefix + "bk")) {
  if(!message.channel.guild) return message.channel.send('**هذا الأمر فقط للسيرفرات**').then(m => m.delete(5000));
  if(!message.member.hasPermission('ADMINISTRATOR')) return      message.channel.send('**للأسف لا تمتلك صلاحية** `ADMINISTRATOR`' );
  let args = message.content.split(" ").join(" ").slice(2 + prefix.length);
  let copy = "ScrpitBot";
  let request = `Requested By ${message.author.username}`;
  if (!args) return message.reply('**يجب عليك كتابة كلمة او جملة لإرسال البرودكاست**');message.channel.send(`**هل أنت متأكد من إرسالك البرودكاست؟ \nمحتوى البرودكاست:** \` ${args}\``).then(msg => {
  msg.react('✅')
  .then(() => msg.react('❌'))
  .then(() =>msg.react('✅'))
  
  let reaction1Filter = (reaction, user) => reaction.emoji.name === '✅' && user.id === message.author.id;
  let reaction2Filter = (reaction, user) => reaction.emoji.name === '❌' && user.id === message.author.id;
  let reaction1 = msg.createReactionCollector(reaction1Filter, { time: 12000 });
  let reaction2 = msg.createReactionCollector(reaction2Filter, { time: 12000 });
  reaction1.on("collect", r => {
  message.channel.send(`☑ | Done ... The Broadcast Message Has Been Sent For ${message.guild.members.size} Members`).then(m => m.delete(5000));
  message.guild.members.forEach(m => {
  var bc = new
  Discord.RichEmbed()
  .setColor('RANDOM')
  .setTitle('Broadcast')
  .addField('Server', message.guild.name)
  .addField('Sender', message.author.username)
  .addField('Message', args)
  .setThumbnail(message.author.avatarURL)
  .setFooter(copy, client.user.avatarURL);
  m.send({ embed: bc })
  msg.delete();
  })
  })
  reaction2.on("collect", r => {
  message.channel.send(`**Broadcast Canceled.**`).then(m => m.delete(5000));
  msg.delete();
  })
  })
  }
  });
  client.on('message', message => {
     if(!message.channel.guild) return;
  if(message.content.startsWith(prefix + 'bc')) {
  if(!message.channel.guild) return message.channel.send('**هذا الأمر فقط للسيرفرات**').then(m => m.delete(5000));
  if(!message.member.hasPermission('ADMINISTRATOR')) return      message.channel.send('**للأسف لا تمتلك صلاحية** `ADMINISTRATOR`' );
  let args = message.content.split(" ").join(" ").slice(2 + prefix.length);
  let BcList = new Discord.RichEmbed()
  .setThumbnail(message.author.avatarURL)
  .setAuthor(`محتوى الرساله ${args}`)
  .setDescription(`برودكاست بـ امبد 📝\nبرودكاست بدون امبد✏ \nلديك دقيقه للأختيار قبل الغاء البرودكاست`)
  if (!args) return message.reply('**اكتب شي للارسال اولا**');message.channel.send(BcList).then(msg => {
  msg.react('📝')
  .then(() => msg.react('✏'))
  .then(() =>msg.react('📝'))
   
  let EmbedBcFilter = (reaction, user) => reaction.emoji.name === '📝' && user.id === message.author.id;
  let NormalBcFilter = (reaction, user) => reaction.emoji.name === '✏' && user.id === message.author.id;
   
  let EmbedBc = msg.createReactionCollector(EmbedBcFilter, { time: 60000 });
  let NormalBc = msg.createReactionCollector(NormalBcFilter, { time: 60000 });
   
  EmbedBc.on("collect", r => {
  message.channel.send(`:ballot_box_with_check: تم ارسال الرساله بنجاح`).then(m => m.delete(5000));
  message.guild.members.forEach(m => {
  var bc = new
  Discord.RichEmbed()
  .setColor('RANDOM')
  .setDescription(`Message : ${args}`)
  .setAuthor(`Server : ${message.guild.name}`)
  .setFooter(`Sender : ${message.author.username}`)
  .setThumbnail(message.author.avatarURL)
  m.send({ embed: bc })
  msg.delete();
  })
  })
  NormalBc.on("collect", r => {
    message.channel.send(`:ballot_box_with_check: تم ارسال الرساله بنجاح`).then(m => m.delete(5000));
  message.guild.members.forEach(m => {
  m.send(args);
  msg.delete();
  })
  })
  })
  }
  });
  
  
  
  
  //تقديمات
  client.on('message',async message => {
  	if(!message.channel.guild) return;
    if(message.content.startsWith(prefix + "تقديم")) {
   
  if(!message.channel.guild) return message.reply('');
   
   
    let submite = message.guild.channels.find(`name`, "「𝐀𝐇」𝐒𝐔𝐁𝐌𝐈𝐓");
   
    if(!submite) return message.channel.send("❌لم اجد الروم الخاص بالتقديمات");
   
      let filter = m => m.author.id === message.author.id;
   
      let thisMessage;
   
      let thisFalse;
   
      message.channel.send('📝 **| من فضلك اكتب اسمك الأن... ✏ **').then(msg => {
   
   
   
      message.channel.awaitMessages(filter, {
   
        max: 1,
   
        time: 90000,
   
        errors: ['time']
   
      })
   
      .then(collected => {
   
        collected.first().delete();
   
        thisMessage = collected.first().content;
   
        let boi;
   
        msg.edit('📜 **| هل ستحترم القوانين؟... ✏ **').then(msg => {
   
   
   
            message.channel.awaitMessages(filter, {
   
              max: 1,
   
              time: 90000,
   
              errors: ['time']
   
            })
   
            .then(collected => {
   
              collected.first().delete();
   
              boi = collected.first().content;
   
              let boi2;
   
              msg.edit('🤵 **| ما اسم ارتبه التى تريد الحصول عليها ولماذا؟... ✏ **').then(msg => {
   
   
   
                message.channel.awaitMessages(filter, {
   
                  max: 1,
   
                  time: 90000,
   
                  errors: ['time']
   
                })
   
                .then(collected => {
   
                  collected.first().delete();
   
                boi2 = collected.first().content;
   
        msg.edit('🛡 **| [ هل انت متأكد من تقديمك؟ | [ نعم ] او [ لا**');
   
   message.channel.awaitMessages(response => response.content === 'نعم' || 'لا' && filter,{
   
          max: 1,
   
          time: 90000,
   
          errors: ['time']
   
        })
   
        .then(collected => {
   
          if(collected.first().content === 'لا') {
   
            msg.delete();
   
            message.delete();
   
            thisFalse = false;
   
          }
   
          if(collected.first().content === 'نعم') {
   
            if(thisFalse === false) return;
   
            msg.edit('🕊 **| Done ✅, تم بنجاح نشر تقديم في روم التقديمات**');
   
            collected.first().delete();
   
            submite.send(`**تم ارسال تقديمك انتظر**
  =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  **[ ${message.guild.name}:arrow_down: ] Submite⬇**
   
  [**اسم المقدم**]:
  ${thisMessage}
   
  [**هل سيحترم القوانين؟**]:
  ${boi}
   
  [**اسم الرتبه والسبب**]:
  ${boi2}
   
  [**تم التقديم بواسطة**]:
  ${message.author}
   
  [**ايدي المقدم**]:
  ${message.author.id}`);
   
          }
   
        }
   
    );
   
  });
   
      });
   
    }
   
      );
   
    });
   
  }
   
  );
   
      })}});
  
  
  //رانك
  client.on('message', message => {
    if(!message.channel.guild) return;
      if (message.content.startsWith(prefix + 'rank')) {
   
          const Rank = message.guild.roles.map(e => e.toString()).join(" ");
   
          const RankList = new Discord.RichEmbed()
              .setTitle('➠ Roles.')
              .setAuthor(message.guild.name, message.guild.iconURL)
              .setColor('RANDOM')
              .setDescription(Rank)
              .setFooter(message.guild.name)
          message.channel.send(RankList)
      }
  });
  
  
  
  //بوتات
   client.on('message', message => {
       if(!message.channel.guild) return;
  
        if(message.content.startsWith(prefix + 'allbots')) {
       if(!message.channel.guild) return;
      
      if (message.author.bot) return;
      let i = 1;
          const botssize = message.guild.members.filter(m=>m.user.bot).map(m=>`${i++} - <@${m.id}>`);
            const embed = new Discord.RichEmbed()
            .setAuthor(message.author.tag, message.author.avatarURL)
            .setDescription(`**Found ${message.guild.members.filter(m=>m.user.bot).size} bots in this Server**
  ${botssize.join('\n')}`)
  .setFooter(client.user.username, client.user.avatarURL)
  .setTimestamp();
  message.channel.send(embed)
  
  }
  
  
  });
  
  
  
  
  //سيرفر
  client.on('message', function(msg) {
    if(msg.content.startsWith (prefix + 'server')) {
      if(!msg.channel.guild) return msg.reply('');         
      let embed = new Discord.RichEmbed()
      .setColor('RANDOM')
      .setThumbnail(msg.guild.iconURL)
      .addField(':globe_with_meridians: **اسم السيرفر : **' , `**[ ${msg.guild.name} ]**`,true)
      .addField(':earth_africa: ** موقع السيرفر :**',`**[ ${msg.guild.region} ]**`,true)
      .addField(':military_medal:** الرتب :**',`**[ ${msg.guild.roles.size} ]**`,true)
      .addField(':bust_in_silhouette:** عدد الاعضاء :**',`**[ ${msg.guild.memberCount} ]**`,true)
      .addField(':white_check_mark:** عدد الاعضاء الاونلاين :**',`**[ ${msg.guild.members.filter(m=>m.presence.status == 'online').size} ]**`,true)
      .addField(':pencil:** الرومات الكتابية :**',`**[ ${msg.guild.channels.filter(m => m.type === 'text').size} ]**`,true)
      .addField(':loud_sound:** رومات الصوت :**',`**[ ${msg.guild.channels.filter(m => m.type === 'voice').size} ]**`,true)
      .addField(':crown:** صاحب السيرفر :**',`**[ ${msg.guild.owner} ]**`,true)
      .addField(':id:** ايدي السيرفر :**',`**[ ${msg.guild.id} ]**`,true)
      .addField(':date:** تم عمل السيرفر في : **',msg.guild.createdAt.toLocaleString())
      msg.channel.send({embed:embed});
    }
  });
  
  
  
  
  
  //تحدث
  client.on('message',message =>   {
    if(!message.channel.guild) return;
    if(message.channel.type == 'dm') return;
    if(message.content.startsWith(prefix + "talk")) {
       if(!message.channel.guild) return;
        var attentions = {};
        attentions[message.guild.id] = { };
        message.channel.send( message.author + ', **Wait , PuP System**').then( (m) =>{
        m.edit( message.author + ', **أرسل أيدي الروم**' )
        m.channel.awaitMessages( m1 => m1.author == message.author,{ maxMatches: 1, time: 600000 } ).then ( (m1) => {
        m1 = m1.first();
        attentions[message.guild.id]['id'] = m1.content;
        m1.delete();
  m1 = message.guild.channels.get(`${attentions[message.guild.id]['id']}`)
  if(!m1) return message.reply(`**الأيدي هذا غير صحيح \`${attentions[message.guild.id]['id']}\`**`);
   
        m.edit(message.author+"**أرسل الرساله المراد توجيهها للروم**")
        m.channel.awaitMessages( m2 => m2.author == message.author,{ maxMatches: 1, time: 600000 }).then ( (m2) => {
        m2 = m2.first();
        attentions[message.guild.id]['msg'] = m2.content;
        m2.delete();
        m.delete();
        message.channel.send(`**هل تريد إرسال في روم <#${attentions[message.guild.id]['id']}>
  ${attentions[message.guild.id]['msg']}**`).then(msge => {
        msge.react('✅').then( r => {
        msge.react('❌')
        const oneFilterBB = (reaction, user) => reaction.emoji.name === '✅' && user.id === message.author.id;
        const threeFilterBB = (reaction, user) => reaction.emoji.name === '❌' && user.id === message.author.id;
        const oneBY = msge.createReactionCollector(oneFilterBB, {maxMatches : 1,time : 400000,});
        const threeBY = msge.createReactionCollector(threeFilterBB, {maxMatches : 1,time : 400000,});
        oneBY.on('collect', r => {
        msge.delete();
        message.guild.channels.get(`${attentions[message.guild.id]['id']}`).send(`${attentions[message.guild.id]['msg']}`)
        }).catch(RebeL =>{ console.log('`Error`: ' + RebeL)});
            threeBY.on('collect', r => {
        msge.delete();
        })
        })
    })
        });
        });
        });
       
      }
      });
  
  
  
  //ميمبر
  client.on('message', message => {
    if(!message.channel.guild) return;
      if(message.content.startsWith(prefix + "member")) {
         if(!message.channel.guild) return;
      const embed = new Discord.RichEmbed()
      .setDescription(`**حالات الاعضاء🔋
  :green_heart: اونلاين   ${message.guild.members.filter(m=>m.presence.status == 'online').size}
  :heart:مشغول       ${message.guild.members.filter(m=>m.presence.status == 'dnd').size}
  :yellow_heart: خامل      ${message.guild.members.filter(m=>m.presence.status == 'idle').size}   
  :black_heart: اوفلاين   ${message.guild.members.filter(m=>m.presence.status == 'offline').size} 
  :blue_heart:   الكل  ${message.guild.memberCount}**`)         
           message.channel.send({embed});
  
      }
    });
  
  
  
  
  //بينج
  client.on('message', message => { 
                                  if(!message.channel.guild) return;
                          if (message.content.startsWith(prefix + 'ping')) {
                              if(!message.channel.guild) return;
                              var msg = `${Date.now() - message.createdTimestamp}`
                              var api = `${Math.round(client.ping)}`
                              if (message.author.bot) return;
                          let embed = new Discord.RichEmbed()
                          .setAuthor(message.author.username,message.author.avatarURL)
                          .setColor('#5016f3')
                          .addField('**Time Taken:**',msg + " ms :signal_strength: ")
                          .addField('**WebSocket:**',api + " ms :signal_strength: ")
                          .setTimestamp()
          message.channel.send({embed:embed});
                          }
                      });
  
  
  //ترحيب
  client.on("guildMemberAdd", member => {
    member.createDM().then(function (channel) {
    return channel.send(`
  :rose:  **ولكم نورت السيرفر**:rose: 
  :crown:**اسم العضو **:crown:  ${member} 
  :zap:**انت العضو رقم** ${member.guild.memberCount} :zap:
  :closed_lock_with_key:  **تم تسجيلك في بيانات السيرفر** :closed_lock_with_key:  `) 
  }).catch(console.error)
  })
  
  
  // خروج
  client.on('guildMemberRemove', member => {
              var embed = new Discord.RichEmbed()
              .setAuthor(member.user.username, member.user.avatarURL)
              .setThumbnail(member.user.avatarURL)
              .setTitle(`شخص خرج من السيرفر -1`)
              .addField('👤   تبقي',`**[ ${member.guild.memberCount} ]**`,true)
              .setColor('RANDOM')
              .setFooter(`==== نــتــمــنــآ لــكــم آلاســتــمـــتــآع ====`, 'https://cdn.discordapp.com/attachments/397818254439219217/399292026782351381/shy.png')
          
          var channel =member.guild.channels.find('name', 'leave')
          if (!channel) return;
          channel.send({embed : embed});
          })
  
  
  //ابلاغ
  client.on('message', function(message) {
    if(!message.channel.guild) return;
      if(message.content.startsWith(prefix + "warn")) {
         if (!message.channel.guild)
        return message.reply("");
          let messageArgs = message.content.split(" ").slice(1).join(" ");
          let messageReason = message.content.split(" ").slice(2).join(" ");
          if(!messageReason) return message.reply("**منشن الشخص واكتب سبب الابلاغ**");
      let mUser = message.mentions.users.first();
      if(!mUser) return message.channel.send("Couldn't find user.");
      let Rembed = new Discord.RichEmbed()
      .setTitle("`ابلاغ جديد!`")
      .setThumbnail(message.author.avatarURL)
      .addField("**# - صاحب الابلاغ:**",mUser,true)
      .addField("**# - سبب الابلاغ:**",messageReason,true)
      .addField("**# - روم الابلاغ:**",message.channel,true)
      .addField("**# - وقت الابلاغ:**",message.createdAt,true)
      .setFooter("اذا كان البلاغ مزيف سوف يتعرض صاحب الابلاغ الي العقوبه")
  message.channel.send(Rembed)
  message.channel.send("__هل انت متاكد انك تريد ارسالها للاداره__").then(msg => {
      msg.react("✅")
      msg.react("❌")
  .then(() => msg.react('❌'))
  .then(() =>msg.react('✅'))
  let reaction1Filter = (reaction, user) => reaction.emoji.name === '✅' && user.id === message.author.id;
  let reaction2Filter = (reaction, user) => reaction.emoji.name === '❌' && user.id === message.author.id;
  
  let reaction1 = msg.createReactionCollector(reaction1Filter, { time: 12000 });
  let reaction2 = msg.createReactionCollector(reaction2Filter, { time: 12000 });
  reaction1.on("collect", r => {
      message.guild.owner.send(Rembed)
      message.reply("**# - تم الارسال! 🎇**");
  })
  reaction2.on("collect", r => {
      message.reply("**# - تم الالغاء!**");
  })
  })
  }
  });
  
  
  //بوت
  client.on("message", message => {
    if(!message.channel.guild) return;
    if (message.content === prefix + "bot") {
       if (!message.channel.guild)
        return message.reply("");
      const bot = new Discord.RichEmbed()
        .setAuthor(client.user.username, client.user.avatarURL)
        .setColor("#00000")
        .addField(
          "✽ **Bot Ping** : ",
          `» ${Date.now() - client.createdTimestamp}` + "ms",
          true
        )
        .addField("**Servers** :  ", `» ${client.guilds.size}`, true)
        .addField("**Channels** : ", `» ${client.channels.size} `, true)
        .addField("**Users** : ", `» ${client.users.size} `, true)
        .addField("**Bot Name** :  ", `» ${client.user.tag} `, true)
        .addField("**Bot Owner** :  ", `» <@735571966815240202>`, true) // تعديل اساسي غير الايدي لايدي حسابك
        .setImage("")
        .setFooter(message.author.username, message.client.avatarURL);
      message.channel.send(bot);
    }
  });
  
  
  
  
  
  
  
  //انفايت
  client.on("message", async message => {
    if(!message.channel.guild) return;
    if (message.content.startsWith(prefix + "inf")) {
      if(!message.channel.guild) return;
      //// وهون الامر طبعا
      let oi = message.mentions.users.first()
        ? message.mentions.users.first().id
        : message.author.id;
      let Tag = message.mentions.users.first()
        ? message.mentions.users.first().tag
        : message.author.tag;
      let Username = message.mentions.users.first()
        ? message.mentions.users.first().username
        : message.author.username;
      let Avatar = message.mentions.users.first()
        ? message.mentions.users.first().avatarURL
        : message.author.avatarURL;
  
      message.guild.fetchInvites().then(invs => {
        let member = client.guilds.get(message.guild.id).members.get(oi);
        let personalInvites = invs.filter(i => i.inviter.id === oi);
        let urll = invs.filter(i => i.inviter.id === oi);
        let link = urll.reduce(
          (p, v) =>
            v.url + ` , Total de membros recrutados no convite: ${v.uses}.\n` + p,
          `\nServidor: ${message.guild.name} \n `
        );
        let inviteCount = personalInvites.reduce((p, v) => v.uses + p, 0);
        let inviteCode = personalInvites.reduce((p, v) => v.code);
        let possibleInvites = [["Total de membros recrutados:"]];
        possibleInvites.push([inviteCount, inviteCode]);
        let user = message.mentions.users.first() || message.author;
        let mem = message.guild.member(user);
        let millisJoined = new Date().getTime() - mem.joinedAt.getTime();
        let daysJoined = millisJoined / 1000 / 60 / 60 / 24;
        console.log(inviteCode);
        var inviteInfo = new Discord.RichEmbed()
          .setTitle(`:incoming_envelope: **[INVITE INFO]** ${Username}`)
          .addField(
            "**عدد الدعوات للسيرفر**",
            `[ شخص **${Number(inviteCount)}** ]   `
          )
          .addField(
            "**تاريخ انضمامك لسيرفرنا **",
            ` [ منذ  **${daysJoined.toFixed(0)}** يوم ]   `
          )
          .addField(
            "**رابط الدعوة الذي دخلت منه**  ",
            `[ **${
              inviteCode &&
              inviteCode.code &&
              inviteCode.code.includes("discord.gg")
                ? inviteCode.code
                : `https://discord.gg/${inviteCode.code || "vHmbKTE"}`
            }** ]   `
          )
          .setImage("")
          .setColor("RANDOM")
          .setTimestamp()
          .setFooter(Tag, Avatar);
  
        message.channel.send(inviteInfo);
      });
    }
  });
  
  
  
  
  
  
  ////كود ميوت او اسكات
  client.on("message", message => {
    if(!message.channel.guild) return;
    if (message.author.bot) return;
  
    let command = message.content.split(" ")[0];
  
    if (command === prefix + "mute") {
      if(!message.channel.guild) return;
      if (message.author.bot) return;
      if (!message.member.hasPermission("MANAGE_ROLES"))
        return message
          .reply("** لا يوجد لديك برمشن 'Manage Roles' **")
          .catch(console.error);
      let user = message.mentions.users.first();
      let modlog = client.channels.find(gg => gg.name === "log");
      let muteRole = client.guilds
        .get(message.guild.id)
        .roles.find(gg => gg.name === "Muted");
      if (!muteRole)
        return message
          .reply("** لا يوجد رتبة الميوت 'Muted' **")
          .catch(console.error);
      if (message.mentions.users.size < 1)
        return message
          .reply("** يجب عليك منشنت شخص اولاً**")
          .catch(console.error);
  
      const embed = new Discord.RichEmbed()
        .setColor(0x00ae86)
        .setTimestamp()
        .addField("الأستعمال:", "mute/unmute")
        .addField(
          "تم ميوت:",
          `${user.username}#${user.discriminator} (${user.id})`
        )
        .addField(
          "بواسطة:",
          `${message.author.username}#${message.author.discriminator}`
        );
  
      if (
        !message.guild
          .member(client.user)
          .hasPermission("MANAGE_ROLES_OR_PERMISSIONS")
      )
        return message
          .reply("** لا يوجد لدي برمشن Manage Roles **")
          .catch(console.error);
  
      if (message.guild.member(user).roles.has(muteRole.id)) {
        return message
          .reply("**:white_check_mark: .. تم اعطاء العضو ميوت**")
          .catch(console.error);
      } else {
        message.guild
          .member(user)
          .addRole(muteRole)
          .then(() => {
            return message
              .reply("**:white_check_mark: .. تم اعطاء العضو ميوت كتابي**")
              .catch(console.error);
          });
      }
    }
  });
  
  
  //// كود فتح واغلاق الروم
  client.on("message", message => {
    if (message.content === prefix + "lock") {
      if (!message.channel.guild)
        if(!message.channel.guild) return;
  
      if (!message.member.hasPermission("MANAGE_MESSAGES"))
        return message.reply(" ليس لديك صلاحيات");
      message.channel
        .overwritePermissions(message.guild.id, {
          SEND_MESSAGES: false
        })
        .then(() => {
          message.reply("**تم قفل الشات :no_entry: **");
        });
    }
    if (message.content === prefix + "unlock") {
      if (!message.channel.guild)
        if(!message.channel.guild) return;
  
      if (!message.member.hasPermission("MANAGE_MESSAGES"))
        return message.reply("ليس لديك صلاحيات");
      message.channel
        .overwritePermissions(message.guild.id, {
          SEND_MESSAGES: true
        })
        .then(() => {
          message.reply("**تم فتح الشات :white_check_mark:**");
        });
    }
  });
  
  
  
  ////كود سحب شخص
  client.on("message", message => {
    if (!message.channel.guild) return;
    if (message.content.startsWith(prefix + "move")) {
      if (message.member.hasPermission("MOVE_MEMBERS")) {
        if (message.mentions.users.size === 0) {
          return message.channel.send("``Use : " + prefix + "move @User``");
        }
        if (message.member.voiceChannel != null) {
          if (message.mentions.members.first().voiceChannel != null) {
            var authorchannel = message.member.voiceChannelID;
            var usermentioned = message.mentions.members.first().id;
            var embed = new Discord.RichEmbed()
              .setTitle("Succes!")
              .setColor("#000000")
              .setDescription(
                `✅ You Have Moved <@${usermentioned}> To Your Channel `
              );
            var embed = new Discord.RichEmbed()
              .setTitle(`You are Moved in ${message.guild.name} `)
              .setColor("RANDOM")
              .setTitle(`✽ **Premium**`)
  
              .setDescription(
                `**<@${message.author.id}> Moved You To His Channel!\nServer --> ${message.guild.name}**`
              );
            message.guild.members
              .get(usermentioned)
              .setVoiceChannel(authorchannel)
              .then(m => message.channel.send(embed));
            message.guild.members.get(usermentioned).send(embed);
          } else {
            message.channel.send(
              "`You Cant Move" +
                message.mentions.members.first() +
                " `The User Should Be In channel To Move It`"
            );
          }
        } else {
          message.channel.send(
            "**``You Should Be In Room Voice To Move SomeOne``**"
          );
        }
      } else {
        message.react("❌");
      }
    }
  });
  
  
  
  
  
  //مسح الشات
  client.on('message', message => {
    
     if(!message.channel.guild) return;
  if(message.content.startsWith(prefix + 'clear')) {
    if(!message.channel.guild) return;
  if(!message.channel.guild) return message.channel.send('**This Command is Just For Servers**').then(m => m.delete(5000));
  if(!message.member.hasPermission('MANAGE_MESSAGES')) return      message.channel.send('**You Do not have permission** `MANAGE_MESSAGES`' );
  let args = message.content.split(" ").join(" ").slice(2 + prefix.length);
  let request = `Requested By ${message.author.username}`;
  message.channel.send(`**Are You sure you want to clear the chat?**`).then(msg => {
  msg.react('✅')
  .then(() => msg.react('❌'))
  .then(() =>msg.react('✅'))
   
  let reaction1Filter = (reaction, user) => reaction.emoji.name === '✅' && user.id === message.author.id;
  let reaction2Filter = (reaction, user) => reaction.emoji.name === '❌' && user.id === message.author.id;
   
  let reaction1 = msg.createReactionCollector(reaction1Filter, { time: 12000 });
  let reaction2 = msg.createReactionCollector(reaction2Filter, { time: 12000 });
  reaction1.on("collect", r => {
  message.channel.send(`Chat will delete`).then(m => m.delete(5000));
  var msg;
          msg = parseInt();
   
        message.channel.fetchMessages({limit: msg}).then(messages => message.channel.bulkDelete(messages)).catch(console.error);
        message.channel.sendMessage("", {embed: {
          title: "`` Chat Deleted ``",
          color: 0x06DF00,
          footer: {
   
          }
        }}).then(msg => {msg.delete(3000)});
   
  })
  reaction2.on("collect", r => {
  message.channel.send(`**Chat deletion cancelled**`).then(m => m.delete(5000));
  msg.delete();
  })
  })
  }
  });
  
  
  
  
  
  
  
  
  ////كود قيف اوي
  client.on("message", async message => {
    if(!message.channel.guild) return;
    var room;
    var title; 
    var duration; 
    var gMembers;
    var filter = m => m.author.id === message.author.id;
    if (message.content.startsWith(prefix + "giveaway")) {
      if(!message.channel.guild) return;
      if (!message.guild.member(message.author).hasPermission("MANAGE_GUILD"))
        return message.channel.send(
          ":heavy_multiplication_x:| **يجب أن يكون لديك خاصية التعديل على السيرفر**"
        );
      message.channel
        .send(`**من فضلك اكتب اسم الروم بدون منشن ( # )**`)
        .then(msgg => {
          message.channel
            .awaitMessages(filter, {
              max: 1, //HactorMC
              time: 20000,
              errors: ["time"]
            })
            .then(collected => {
              let room = message.guild.channels.find(
                gg => gg.name === collected.first().content
              );
              if (!room)
                return message.channel.send(
                  "**لم اقدر علي ايجاد الروم | اعد المحاوله لاحقا**"
                );
              room = collected.first().content;
              collected.first().delete();
              msgg.edit("**اكتب مدة القيف اواي بالدقائق**").then(msg => {
                message.channel
                  .awaitMessages(filter, {
                    max: 1, //HactorMC
                    time: 20000,
                    errors: ["time"]
                  })
                  .then(collected => {
                    if (isNaN(collected.first().content))
                      return message.channel.send(
                        ":heavy_multiplication_x:| **يجب عليك ان تحدد وقت زمني صحيح.. ``يجب عليك اعادة كتابة الامر``**"
                      );
                    duration = collected.first().content * 60000;
                    collected.first().delete();
                    msgg
                      .edit(
                        ":eight_pointed_black_star:| **اكتب على ماذا تريد القيف اواي**"
                      )
                      .then(msg => {
                        message.channel
                          .awaitMessages(filter, {
                            max: 1,
                            time: 20000,
                            errors: ["time"]
                          })
                          .then(collected => {
                            title = collected.first().content;
                            collected.first().delete();
                            try {
                              let giveEmbed = new Discord.RichEmbed()
                                .setAuthor(
                                  message.guild.name,
                                  message.guild.iconURL
                                )
                                .setTitle(title)
                                .setDescription(
                                  `المدة : ${duration / 60000} دقائق`
                                )
                                .setFooter(
                                  message.author.username,
                                  message.author.avatarURL
                                );
                              message.guild.channels
                                .find(gg => gg.name === room)
                                .send(giveEmbed)
                                .then(m => {
                                  let re = m.react("🎉");
                                  setTimeout(() => {
                                    let users = m.reactions.get("🎉").users;
                                    let list = users
                                      .array()
                                      .filter(u => u.id !== m.author.id);
                                    let gFilter =
                                      list[
                                        Math.floor(Math.random() * list.length) +
                                          0
                                      ];
                                    if (users.size === 1)
                                      gFilter = "**لم يتم التحديد**";
                                    let endEmbed = new Discord.RichEmbed()
                                      .setAuthor(
                                        message.author.username,
                                        message.author.avatarURL
                                      )
                                      .setTitle(title)
                                      .addField(
                                        "انتهى القيف اواي !",
                                        `الفائز هو : ${gFilter}`
                                      )
                                      .setFooter(
                                        message.guild.name,
                                        message.guild.iconURL
                                      );
                                    m.edit(endEmbed);
                                  }, duration);
                                });
                              msgg.edit(
                                `:heavy_check_mark:| **تم اعداد القيف اواي**`
                              );
                            } catch (e) {
                              msgg.edit(
                                `:heavy_multiplication_x:| **لم اقدر علي اعداد القيف اواي بسبب عدم توفر البرمشن المطلوب**`
                              );
                              console.log(e);
                            }
                          });
                      });
                  });
              });
            });
        });
    }
  });
  
  
  
  
  //قائمه البان
  client.on('message',async message => {
       
       const arraySort = require('array-sort');
  const table = require('table');
  if (message.content.toLowerCase().startsWith(prefix + 'banlist')){
       let ban = await message.guild.fetchBans().catch(error => {
          return message.channel.send('Sorry, I don\'t have the proper permissions to view bans!');
      });
  
      ban = ban.array();
      let users = message.guild.fetchBans().id;
      message.channel.send(`**${message.guild.name} Bans List :**`)
      ban.forEach(function(ban) {
           message.channel.send(`${ban}`)
      })
  }
   });
  
  
  
  
  
  
  
  //نيكنم
  client.on("message", message => {
    if (message.content.startsWith(prefix + "nick")) {
      if (!message.guild.member(message.author).hasPermission("MANAGE_NICKNAMES"))
        return message.channel.send("Please Check Your Permission.");
      if (!message.guild.member(client.user).hasPermission("MANAGE_NICKNAMES"))
        return message.channel.send("Please Check My Permission.");
      let user = message.mentions.users.first();
      
      if (!user) return message.channel.send(`**>>> ${prefix}nick @mention nickname**`);
      let args = message.content
        .split(" ")
        .slice(2)
        .join(" ");
      if (!args)
        message.guild
          .member(user)
          .setNickname("")
          .then(m => {
          })
          .catch(error => {
            message.channel.send("Error: **" + error.message + "**");
          });
      message.guild
        .member(user)
        .setNickname(args)
        .then(m => {
          let embed = new Discord.MessageEmbed()
            .setTitle("Nicknamed User!")
            .setDescription(
              "User: ```" +
                user.username +
                "```\nBy: ```" +
                message.author.username +
                "```\nNickname: ```" +
                args +
                "``` "
            );
          message.channel.send(embed);
        })
        
    }
    
    }
  );
  
  
  
  
  
  
  //يوزر
  client.on("message", pixelbot => {
    if (pixelbot.content.startsWith(prefix + "user")) {
     
      if (pixelbot.author.bot) return;
      if (!pixelbot.guild)
        return pixelbot.reply("");
      pixelbot.guild.fetchInvites().then(invites => {
       
        let personalInvites = invites.filter(
          i => i.inviter.id === pixelbot.author.id
        );
        let inviteCount = personalInvites.reduce((p, v) => v.uses + p, 0);
        var roles = pixelbot.member.roles
          .map(roles => `**__${roles.name}__ |**`)
          .join(` `);
        let pixeluser = new Discord.RichEmbed() 
          .setColor("#00000")
          .setTitle(" :beginner: :heartpulse:   | User Info") 
          .setAuthor(pixelbot.author.username, pixelbot.author.avatarURL)
          .addField("**✽ Name :**   ", pixelbot.author.username, true)
          .addField("**✽ Tag :**   ", pixelbot.author.discriminator, true)
          .addField("**✽ ID :** ", pixelbot.author.id, true) 
          .addField(
            "**✽ Joined At :**   ",
            moment(pixelbot.joinedAt).format("D/M/YYYY h:mm a "),
            true
          )
          .addField(
            "**✽ Created At :**    ",
            moment(pixelbot.author.createdAt).format("D/M/YYYY h:mm a "),
            true
          )
          .addField("**✽ Total invites :**    ", inviteCount, true)
          .setTimestamp(); 
  
        pixelbot.channel.sendEmbed(pixeluser).then(c => {}); 
      });
    }
  }); 
  
  
  //فك الميوت
  client.on("message", message => {
    if (message.author.bot) return;
  
    let command = message.content.split(" ")[0];
  
    if (command === prefix + "unmute") {
      if (message.author.bot) return;
      if (!message.member.hasPermission("MANAGE_ROLES"))
        return message
          .reply("** لا يوجد لديك برمشن 'Manage Roles' **")
          .catch(console.error);
      let user = message.mentions.users.first();
      let modlog = client.channels.find(gg => gg.name === "log");
      let muteRole = client.guilds
        .get(message.guild.id)
        .roles.find(gg => gg.name === "Muted");
      if (!muteRole)
        return message
          .reply("** لا يوجد لديك رتبه الميوت 'Muted' **")
          .catch(console.error);
      if (message.mentions.users.size < 1)
        return message
          .reply("** يجب عليك منشنت شخص اولاً**")
          .catch(console.error);
      const embed = new Discord.RichEmbed()
        .setColor(0x00ae86)
        .setTimestamp()
        .addField("الأستعمال:", "اسكت/احكي")
        .addField(
          "تم فك الميوت عن:",
          `${user.username}#${user.discriminator} (${user.id})`
        )
        .addField(
          "بواسطة:",
          `${message.author.username}#${message.author.discriminator}`
        );
  
      if (
        !message.guild
          .member(client.user)
          .hasPermission("MANAGE_ROLES_OR_PERMISSIONS")
      )
        return message
          .reply("** لا يوجد لدي برمشن Manage Roles **")
          .catch(console.error);
  
      if (message.guild.member(user).removeRole(muteRole.id)) {
        return message
          .reply("**:white_check_mark: .. تم فك الميوت عن الشخص **")
          .catch(console.error);
      } else {
        message.guild
          .member(user)
          .removeRole(muteRole)
          .then(() => {
            return message
              .reply("**:white_check_mark: .. تم فك الميوت عن الشخص **")
              .catch(console.error);
          });
      }
    }
  });
  
  
  
  
  
  
  
  //رابط
  client.on("message", message => {
    if (message.content.split(" ")[0] === prefix + "link") {
      message.channel
        .createInvite({
          thing: true,
          maxUses: 5,
          maxAge: 86400
        })
        .then(invite => message.author.send(invite.url));
      const embed = new Discord.RichEmbed()
        .setColor("RANDOM")
        .setDescription(
          "** تم ارسال الرابط على الخاص ، اذا لم يصلك افتح الخاص  **"
        )
        .setAuthor(client.user.username, client.user.avatarURL)
        .setAuthor(client.user.username, client.user.avatarURL)
        .setFooter("طلب بواسطة: " + message.author.tag);
  
      message.channel.sendEmbed(embed).then(message => {
        message.delete(10000);
      });
      const Embed11 = new Discord.RichEmbed().setColor("RANDOM")
        .setDescription(`** مدة الرابط : يوم 
   عدد استخدامات الرابط : 5 **`);
  
      message.author.sendEmbed(Embed11);
    }
  });
  
  
  
  
  
  
  
  //الحمايه
  let anti = JSON.parse(fs.readFileSync("./antigrefff.json", "UTF8"));
  let config = JSON.parse(fs.readFileSync("./server.json", "UTF8"));
  client.on("message", message => {
    if (!message.channel.guild) return;
    let user = anti[message.guild.id + message.author.id];
    let num = message.content
      .split(" ")
      .slice(2)
      .join(" ");
    if (!anti[message.guild.id + message.author.id])
      anti[message.guild.id + message.author.id] = {
        actions: 0
      };
    if (!config[message.guild.id])
      config[message.guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    if (message.content.startsWith(prefix + "1")) {
      if (message.author.id !== message.guild.owner.user.id)
        return message.channel.send(
          "**:closed_lock_with_key: لأسباب تتعلق بالحماية تم حصر أوامر الحماية فقط للأونر**"
        );//عدد البان
      if (message.content.startsWith(prefix + "1limit ban")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].banLimit = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].banLimit} **`
        );
      }//عدد الكيك
      if (message.content.startsWith(prefix + "1limit kick")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].kickLimits = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].kickLimits}**`
        );
      }//مسح الرول
      if (message.content.startsWith(prefix + "1limit roleD")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].roleDelLimit = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].roleDelLimit}**`
        );
      }//صنع رول
      if (message.content.startsWith(prefix + "limit roleC")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].roleCrLimits = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].roleCrLimits}**`
        );
      }//مسح روم
      if (message.content.startsWith(prefix + "1limit channeD")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].chaDelLimit = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].chaDelLimit}**`
        );
      }//اضاف روم
      if (message.content.startsWith(prefix + "1limit channelC")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].chaCrLimit = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].chaCrLimit}**`
        );
      }//وقت التبنيد
      if (message.content.startsWith(prefix + "1limit time")) {
        if (!num) return message.channel.send("**:1234: | أرسل رقم ! **");
        if (isNaN(num)) return message.channel.send("**:1234: | أرقام فقط ! **");
        config[message.guild.id].time = num;
        message.channel.send(
          `**:lock: | تم التغيير اِلي : ${config[message.guild.id].time}**`
        );
      }
    }
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
      if (e) throw e;
    });
    fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(e) {
      if (e) throw e;
    });
  });
  client.on("channelDelete", async channel => {
    const entry1 = await channel.guild
      .fetchAuditLogs({
        type: "CHANNEL_DELETE"
      })
      .then(audit => audit.entries.first());
    console.log(entry1.executor.username);
    const entry = entry1.executor;
    if (!config[channel.guild.id])
      config[channel.guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    if (!anti[channel.guild.id + entry.id]) {
      anti[channel.guild.id + entry.id] = {
        actions: 1
      };
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
    } else {
      anti[channel.guild.id + entry.id].actions = Math.floor(
        anti[channel.guild.id + entry.id].actions + 1
      );
      console.log("TETS");
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
      if (
        anti[channel.guild.id + entry.id].actions >=
        config[channel.guild.id].chaDelLimit
      ) {
        channel.guild.members
          .get(entry.id)
          .ban()
        anti[channel.guild.id + entry.id].actions = "0";
        fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
        fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
      }
    }
  
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
      if (e) throw e;
    });
    fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(e) {
      if (e) throw e;
    });
  });
  
  client.on("channelCreate", async channel => {
    if (!["text", "category", "voice"].includes(channel.type.toLowerCase()))
      return;
    if (!config[channel.guild.id])
      config[channel.guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    const entry1 = await channel.guild
      .fetchAuditLogs({
        type: "CHANNEL_CREATE"
      })
      .then(audit => audit.entries.first());
    console.log(entry1.executor.username);
    const entry = entry1.executor;
  
    if (!anti[channel.guild.id + entry.id]) {
      anti[channel.guild.id + entry.id] = {
        actions: 1
      };
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
    } else {
      anti[channel.guild.id + entry.id].actions = Math.floor(
        anti[channel.guild.id + entry.id].actions + 1
      );
      console.log("TETS");
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
      if (
        anti[channel.guild.id + entry.id].actions >=
        config[channel.guild.id].chaCrLimit
      ) {
        channel.guild.members
          .get(entry.id)
          .ban()
          
        anti[channel.guild.id + entry.id].actions = "0";
        fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
        fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
      }
  
      fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
        if (e) throw e;
      });
      fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
        e
      ) {
        if (e) throw e;
      });
    }
  });
  client.on("roleDelete", async channel => {
    const entry1 = await channel.guild
      .fetchAuditLogs({
        type: "ROLE_DELETE"
      })
      .then(audit => audit.entries.first());
    console.log(entry1.executor.username);
    const entry = entry1.executor;
    if (!config[channel.guild.id])
      config[channel.guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    if (!anti[channel.guild.id + entry.id]) {
      anti[channel.guild.id + entry.id] = {
        actions: 1
      };
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
    } else {
      anti[channel.guild.id + entry.id].actions = Math.floor(
        anti[channel.guild.id + entry.id].actions + 1
      );
      console.log("TETS");
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
      if (
        anti[channel.guild.id + entry.id].actions >=
        config[channel.guild.id].roleDelLimit
      ) {
        channel.guild.members
          .get(entry.id)
          .ban()
          .catch(e =>
            channel.guild.owner.send(
              `**⇏ | ${entry.username} قام بمسح الكثير من الرتب **`
            )
          );
        anti[channel.guild.id + entry.id].actions = "0";
        fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
        fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
      }
    }
  
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
      if (e) throw e;
    });
    fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(e) {
      if (e) throw e;
    });
  });
  
  client.on("roleCreate", async channel => {
    const entry1 = await channel.guild
      .fetchAuditLogs({
        type: "ROLE_CREATE"
      })
      .then(audit => audit.entries.first());
    console.log(entry1.executor.username);
    const entry = entry1.executor;
    if (!config[channel.guild.id])
      config[channel.guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    if (!anti[channel.guild.id + entry.id]) {
      anti[channel.guild.id + entry.id] = {
        actions: 1
      };
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
    } else {
      anti[channel.guild.id + entry.id].actions = Math.floor(
        anti[channel.guild.id + entry.id].actions + 1
      );
      console.log("TETS");
      setTimeout(() => {
        anti[channel.guild.id + entry.id].actions = "0";
      }, config[channel.guild.id].time * 1000);
      if (
        anti[channel.guild.id + entry.id].actions >=
        config[channel.guild.id].roleCrLimits
      ) {
        channel.guild.members
          .get(entry.id)
          .ban()
          .catch(e =>
            channel.guild.owner.send(
              `**⇏ | ${entry.username} قام بأنشاء الكثير من الرتب **`
            )
          );
        anti[channel.guild.id + entry.id].actions = "0";
        fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
        fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
      }
    }
  
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
      if (e) throw e;
    });
    fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(e) {
      if (e) throw e;
    });
  });
  
  client.on("guildBanAdd", async (guild, user) => {
    const entry1 = await guild
      .fetchAuditLogs({
        type: "MEMBER_BAN_ADD"
      })
      .then(audit => audit.entries.first());
    console.log("ban: " + entry1.executor.username);
    const entry = entry1.executor;
    if (!config[guild.id])
      config[guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    if (!anti[guild.id + entry.id]) {
      anti[guild.id + entry.id] = {
        actions: 1
      };
      setTimeout(() => {
        anti[guild.id + entry.id].actions = 0;
      }, config[guild.id].time * 1000);
    } else {
      anti[guild.id + entry.id].actions = Math.floor(
        anti[guild.id + entry.id].actions + 1
      );
      setTimeout(() => {
        anti[guild.id + entry.id].actions = 0;
      }, config[guild.id].time * 1000);
      if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
        guild.members
          .get(entry.id)
          .ban()
          .catch(e =>
            guild.owner.send(`**⇏ | ${entry.username} حاول حظر جميع الأعضاء **`)
          );
        anti[guild.id + entry.id].actions = 0;
        fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
        fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
      }
    }
  
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
      if (e) throw e;
    });
    fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(e) {
      if (e) throw e;
    });
  });
  
  client.on("guildKickAdd", async (guild, user) => {
    const entry1 = await guild
      .fetchAuditLogs({
        type: "MEMBER_KICK"
      })
      .then(audit => audit.entries.first());
    console.log(entry1.executor.username);
    const entry = entry1.executor;
    if (!config[guild.id])
      config[guild.id] = {
        banLimit: 3,
        chaDelLimit: 3,
        chaCrLimit: 3,
        roleDelLimit: 3,
        kickLimits: 3,
        roleCrLimits: 3,
        time: 30
      };
    if (!anti[guild.id + entry.id]) {
      anti[guild.id + entry.id] = {
        actions: 1
      };
      setTimeout(() => {
        anti[guild.id + entry.id].actions = 0;
      }, config[guild.id].time * 1000);
    } else {
      anti[guild.id + entry.id].actions = Math.floor(
        anti[guild.id + entry.id].actions + 1
      );
      console.log("TETS");
      setTimeout(() => {
        anti[guild.id + entry.id].actions = 0;
      }, config[guild.id].time * 1000);
      if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
        guild.members
          .get(entry.id)
          .ban()
          .catch(e =>
            guild.owner.send(`**⇏ | ${entry.username} حاول حظر جميع الأعضاء **`)
          );
        anti[guild.id + entry.id].actions = 0;
        fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
        fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
          e
        ) {
          if (e) throw e;
        });
      }
    }
  
    fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
      if (e) throw e;
    });
    fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(e) {
      if (e) throw e;
    });
  });
  
  client.on("guildMemberRemove", async member => {
    const entry1 = await member.guild
      .fetchAuditLogs()
      .then(audit => audit.entries.first());
    if (entry1.action === "MEMBER_KICK") {
      const entry2 = await member.guild
        .fetchAuditLogs({
          type: "MEMBER_KICK"
        })
        .then(audit => audit.entries.first());
      const entry = entry2.executor;
      if (!config[member.guild.id])
        config[guild.id] = {
          banLimit: 3,
          chaDelLimit: 3,
          chaCrLimit: 3,
          roleDelLimit: 3,
          kickLimits: 3,
          roleCrLimits: 3,
          time: 30
        };
      if (!anti[member.guild.id + entry.id]) {
        anti[member.guild.id + entry.id] = {
          actions: 1
        };
        setTimeout(() => {
          anti[member.guild.id + entry.id].actions = 0;
        }, config[member.guild.id].time * 1000);
      } else {
        anti[member.guild.id + entry.id].actions = Math.floor(
          anti[member.guild.id + entry.id].actions + 1
        );
        console.log("TETS");
        setTimeout(() => {
          anti[member.guild.id + entry.id].actions = 0;
        }, config[member.guild.id].time * 1000 || 30000);
        if (
          anti[member.guild.id + entry.id].actions >=
          config[member.guild.id].kickLimits
        ) {
          member.guild.members
            .get(entry.id)
            .ban()
            .catch(e =>
              member.owner.send(
                `**⇏ | ${entry.username} حاول حظر جميع الأعضاء **`
              )
            );
          anti[member.guild.id + entry.id].actions = 0;
          fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(
            e
          ) {
            if (e) throw e;
          });
          fs.writeFile(
            "./antigreff.json",
            JSON.stringify(anti, null, 2),
            function(e) {
              if (e) throw e;
            }
          );
        }
      }
  
      fs.writeFile("./config.json", JSON.stringify(config, null, 2), function(e) {
        if (e) throw e;
      });
      fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function(
        e
      ) {
        if (e) throw e;
      });
    }
  });
  
  var antibots = JSON.parse(fs.readFileSync("./KickBots.json", "utf8"));
  let saveSteve = () => {
    fs.writeFileSync(
      "./KickBots.json",
      JSON.stringify(antibots, null, 2),
      err => {
        if (err) throw err;
      }
    );
  };
  client.on("message", message => {
    if (!message.guild) return;
    if (!antibots[message.guild.id])
      config[message.guild.id] = {
        onoff: true
      };//رفض البوت
    if (message.content.startsWith(prefix + "bots on")) {
      if (message.author.bot || !message.channel.guild) return;
      if (message.author.id !== message.guild.owner.user.id)
        return message.channel.send(
          "**:closed_lock_with_key: لأسباب تتعلق بالحماية تم حصر أوامر الحماية فقط للأونر**"
        );
      antibots[message.guild.id] = {
        onoff: true
      };
      saveSteve();
      message.channel.send("**AntiBots Join Is On :closed_lock_with_key: **");
    }//سماح بالبوت
    if (message.content.startsWith(prefix + "bots off")) {
      if (message.author.bot || !message.channel.guild) return;
      if (message.author.id !== message.guild.owner.user.id)
        return message.channel.send(
          "**:closed_lock_with_key: لأسباب تتعلق بالحماية تم حصر أوامر الحماية فقط للأونر**"
        );
      antibots[message.guild.id] = {
        onoff: false
      };
      saveSteve();
      message.channel.send("**AntiBots Join Is Off :unlock: **");
    }
    saveSteve();
  });
  
  client.on("guildMemberAdd", member => {
    if (!antibots[member.guild.id])
      config[member.guild.id] = {
        onoff: true
      };
    if (antibots[member.guild.id].onoff == false) return;
    if (member.user.bot) return member.ban("Protection from Bots.");
    saveSteve();
  });
  
  
  
  
  
  
  
  //رتبه تلقائي
  client.on('guildMemberAdd', member=> {
      member.addRole(member.guild.roles.find("name","𝐀𝐇 | 𝐌𝐄𝐌𝐁𝐄𝐑 ☭"));
      });
  
  
  
  
  
  
  //شوب
  client.on('message', message => {
      if (message.content.startsWith(prefix + "shop")) {
  
    message.channel.send("**تم ارسال الرابط في الخاص**")
  
  message.author.send(`https://discord.gg/X28KbfR`)
  
      }
  });
  
  
  
  
  
  //كيك
  client.on("message", message => {
    if (message.author.x5bz) return;
    if (!message.content.startsWith(prefix)) return;
  
    let command = message.content.split(" ")[0];
    command = command.slice(prefix.length);
  
    let args = message.content.split(" ").slice(1);
  
    if (command == "kick") {
      if (message.author.bot) return;
      if (!message.channel.guild)
        return message.reply("** This command only for servers**");
  
      if (!message.guild.member(message.author).hasPermission("KICK_MEMBERS"))
        return message.reply("**You Don't Have ` KICK_MEMBERS ` Permission**");
      if (!message.guild.member(client.user).hasPermission("KICK_MEMBERS"))
        return message.reply("**I Don't Have ` KICK_MEMBERS ` Permission**");
      let user = message.mentions.users.first();
      let reason = message.content
        .split(" ")
        .slice(2)
        .join(" ");
      if (message.mentions.users.size < 1) return message.reply("**منشن شخص**");
      if (!reason) return message.reply("**اكتب سبب الطرد**");
      if (!message.guild.member(user).kickable)
        return message.reply(
          "**لايمكنني طرد شخص اعلى من رتبتي يرجه اعطاء البوت رتبه عالي**"
        );
      if (
        message.mentions.members.first().highestRole.position >=
        message.member.highestRole.position
      )
        return message.channel.send("ما تقدر تطرد شخص رتبته اعلى منك!");
  
      message.guild.member(user).kick();
  
      const kickembed = new Discord.RichEmbed()
        .setAuthor(`KICKED!`, user.displayAvatarURL)
        .setColor("RANDOM")
        .setTimestamp()
        .addField("**User:**", "**[ " + `${user.tag}` + " ]**")
        .addField("**By:**", "**[ " + `${message.author.tag}` + " ]**")
        .addField("**Reason:**", "**[ " + `${reason}` + " ]**");
      message.channel.send({
        embed: kickembed
      });
    }
  });
  
  //بان
  client.on("message", message => {
    if (message.author.codes) return;
    if (!message.content.startsWith(prefix)) return;
  
    let command = message.content.split(" ")[0];
    command = command.slice(prefix.length);
  
    let args = message.content.split(" ").slice(1);
  
    if (command == "ban") {
      if (message.author.bot) return;
      if (!message.channel.guild)
        return message.reply("** This command only for servers**");
  
      if (!message.guild.member(message.author).hasPermission("BAN_MEMBERS"))
        return message.reply("**انت لا تملك الصلاحيات المطلوبه**");
      if (!message.guild.member(client.user).hasPermission("BAN_MEMBERS"))
        return message.reply("**I Don't Have ` BAN_MEMBERS ` Permission**");
      let user = message.mentions.users.first();
  
      if (message.mentions.users.size < 1) return message.reply("**منشن شخص**");
      if (
        message.mentions.members.first().highestRole.position >=
        message.member.highestRole.position
      )
        return message.channel.send("ما تقدر تبند شخص رتبته اعلى منك!");
      if (!message.guild.member(user).bannable)
        return message.reply(
          "**يجب ان تكون رتبة البوت اعلي من رتبه الشخص المراد تبنيدة**"
        );
  
      message.guild.member(user).ban(7, user);
  
      message.channel.send(
        `**:white_check_mark: ${user.tag} banned from the server ! :airplane: **  `
      );
    }
  });
  
  //رتبه متغيره
  client.on('ready', () => {// افنت التشغيل 
    setInterval(function(){
        client.guilds.forEach(g => { // فور ايرج تدخل للسيرفرات كلها
                    var role = g.roles.find('name', 'color');//Rainbow  اسم الرتبة عشان يسوي ريمبو غيرها اذا تبي
                    if (role) {
                        role.edit({color : "RANDOM"});
                    };
        });
    }, 6000);// وقت الريمبو لا تغيرة لانه الوقت المسموح للتغيير
  })
  
  
  
  
  //ساي
  client.on('message', msg => {
  if (msg.author.bot) return;
  let args = msg.content.split(" ").slice(1).join(" ")
  if (msg.content.startsWith(prefix+"say")) {
  msg.delete(100);
  msg.channel.send(args);
  }
  });
  
  
  
  
  
  
  
  
  
  
  
  //روم مؤقت
  let temp = JSON.parse(fs.readFileSync('./temp.json' , 'utf8'));
  client.on('message', async message => {
   if(message.channel.type === "dm") return;
    if(message.author.bot) return;
   if(message.content == (prefix+'temp on')){
  if(!message.member.hasPermission(`MANAGE_GUILD`)) return;
  if(temp[message.guild.id]) return message.channel.send('**الروم موجود فعليا ✅**')
   message.guild.createChannel('Temporary Channels', 'category').then(cg => {
   message.guild.createChannel('اضغط لإنشاء روم خاص', 'voice').then(ch => {
  ch.setParent(cg)
   message.channel.send('**تم تفعيل الخاصيه ✅**')
   temp[message.guild.id] = {time: "3000", category : cg.id,  channel :ch.id}
  });
   })
   }fs.writeFile("./temp.json", JSON.stringify(temp),(err)=>{if(err)console.error(err)})
      });
  
  client.on('message' , message => {
    if(message.content == prefix+'temp off') {
      if(!temp[message.guild.id])return message.channel.send('**تم إيقاف تفعيل الخاصيه ✅**')
     if(!message.member.hasPermission(`MANAGE_GUILD`)) return;
  let cg = message.guild.channels.get(temp[message.guild.id].category);let ch = message.guild.channels.get(temp[message.guild.id].channel)
  if(cg&&ch) {ch.delete().then(()=>{cg.delete()});message.channel.send('**تم إيقاف تفعيل الخاصيه ✅**')}
  else {message.channel.send('**تم ايقاف تفعيل الخاصيه ✅**')};delete temp[message.guild.id]} });
  
  client.on('message' , message => {
  if (message.content.startsWith(prefix + "temp time")) {
  if(!message.member.hasPermission(`MANAGE_GUILD`)) return;
  let newTime= message.content.split(' ').slice(2);
  if(!newTime) return message.channel.send(`**You Must type the number after the command** ❎`)
  if(isNaN(newTime)) return message.channel.send(`**Please Type The a Correct Number \🔢\❌**`);
  if(newTime < 3) return message.channel.send(`**The Time Must Be More Than \`3s\` ❌**`)
  let Time = Math.floor((newTime*(1000)));
  temp[message.guild.id].time = Time
  message.channel.send(`**✅ The Time Set To: \`${newTime}s\`**`);
  }})
  
  client.on('voiceStateUpdate', (old, neww) => {
  if(!temp[old.guild.id]) return
  if(!neww.guild.member(client.user).hasPermission('ADMINISTRATOR'))return;;
  let newUserChannel = neww.voiceChannel;let oldUserChannel = old.voiceChannel
  if(newUserChannel == oldUserChannel) return;
  let channel = temp[neww.guild.id].channel
  let category = temp[neww.guild.id].category
  let ch = old.guild.channels.get(channel);if(!ch) return
  let ct = old.guild.channels.get(category);if(!ct) return
  
  if(newUserChannel !== undefined && newUserChannel.id == channel) {
  neww.guild.createChannel(neww.displayName , 'voice').then(c => {
  c.setParent(category).then(()=>{c.setParent(category).catch(err=>{return})})
  c.overwritePermissions(neww.user, {MANAGE_CHANNELS:true,MUTE_MEMBERS:true})
  .then(()=>{ch.overwritePermissions(neww,{CONNECT:false})});return neww.setVoiceChannel(c)});}
  if(oldUserChannel !== undefined) {
  setTimeout(()=>{
  let chh = neww.guild.channels.find('name',neww.displayName)
  if(!chh) return
  if(chh.type === 'voice')return[chh.delete(),
  ch.overwritePermissions(neww, {
  CONNECT:null})]
  }, temp[neww.guild.id].time);}
  client.on('channelDelete',channel =>{
    if(oldUserChannel !== undefined) {
      setTimeout(()=>{
      let chh = neww.guild.channels.find('name',neww.displayName)
      if(!chh) return
      if(chh.type === 'voice')return[chh.delete(),
      ch.overwritePermissions(neww, {
      CONNECT:null})]
      }, temp[neww.guild.id].time);}
  })
  });
  
  
  
  
  
  
  //فك البان
  client.on('message' , message => {
      ;
      let user = message.mentions.users.first()|| client.users.get(message.content.split(' ')[1])
      if(message.content.startsWith(prefix + 'unban')) {
          if (!message.guild.member(message.author).hasPermission("BAN_MEMBERS"))
        return message.reply("**انت لا تملك الصلاحيات المطلوبه**");
          if(!user) return  message.channel.send(`Do this ${prefix} <@ID user> \n or \n ${prefix}unban ID user`);
          message.guild.unban(user);
          message.guild.owner.send(`لقد تم فك الباند عن الشخص \n ${user} \n By : <@${message.author.id}>`)
          var embed = new Discord.RichEmbed()
          .setThumbnail(message.author.avatarURl)
          .setColor("RANDOM")
          .setTitle('**●Unban** !')
          .addField('**●User Unban :** ', `${user}` , true)
          .addField('**●By :**' ,       ` <@${message.author.id}> ` , true)
          .setAuthor(message.guild.name)
          message.channel.sendEmbed(embed)
      }
  });
  
  
  //موقع
  //هيلب
  
  
  
  
  
  
  
  //عرض الرتب
  var AsciiTable = require('ascii-data-table').default
  client.on('message', message =>{
  
      if(message.content.startsWith(prefix + "roles")){
          ros=message.guild.roles.size,
          data = [['Rank', 'RoleName']]
          for(let i =0;i<ros;i++){
              if(message.guild.roles.array()[i].id !== message.guild.id){
           data.push([i,`${message.guild.roles.filter(r => r.position == ros-i).map(r=>r.name)}`])
          }}
          let res = AsciiTable.table(data)
  
          message.channel.send(`**\`\`\`xl\n${res}\`\`\`**`);
      }
  });
  
  
  
  
  
  //صوره سيرفر
  client.on("message", message => {
    if(message.author.bot) return;
    if(!message.content.startsWith(prefix)) return;
    if(message.content.startsWith(prefix + "savatar")) {
      let doma = new Discord.RichEmbed()
      .setColor("BLACK")
      .setAuthor(message.guild.name, message.guild.iconURL)
      .setTitle("Avatar Link")
      .setURL(message.guild.iconURL)
      .setImage(message.guild.iconURL)
      .setFooter(`Requested By ${message.author.tag}`, message.author.avatarURL)
      message.channel.send(doma)
    } else if(message.content.startsWith(prefix + "avatar")) {
      let args = message.content.split(" ")[1]
  var avt = args || message.author.id;    
      client.fetchUser(avt).then(user => {
       avt = user;
    let embed = new Discord.RichEmbed() 
    .setColor("BLACK")
    .setAuthor(`${avt.tag}`, avt.avatarURL)
    .setTitle("Avatar Link")
    .setURL(avt.avatarURL)
    .setImage(avt.avatarURL)
    .setFooter(`Requested By ${message.author.tag}`, message.author.avatarURL)
    message.channel.send(embed) 
      })
    }
  })
  
  
  
  
  //رول
  client.on('message', message => { 
      if (message.author.boss) return;
      if (!message.content.startsWith(prefix)) return;
      let command = message.content.split(" ")[0];
      command = command.slice(prefix.length);
      if (command == "role") {
      if (!message.channel.guild) return;
      if(!message.guild.member(message.author).hasPermission("MANAGE_ROLES")) return message.reply("**:no_entry_sign:انت لا تملك صلاحيات **").then(msg => msg.delete(5000));;
      if(!message.guild.member(client.user).hasPermission("MANAGE_ROLES")) return message.reply("البوت لايملك صلاحيات ").then(msg => msg.delete(5000));;
      let user = message.mentions.users.first();
      if (message.mentions.users.size < 1) return message.reply('**ضع منشن الشخص!!**').then(msg => {msg.delete(5000)});
      let MRole = message.content.split(" ").slice(2).join(" ");
      if(!MRole)return message.reply("يجب عليك وضع اسم الرتبة").then(msg => {msg.delete(5000)});
      message.guild.member(user).addRole(message.guild.roles.find("name", MRole));
      message.reply('** Done :white_check_mark:  **').then(msg => {msg.delete(10000)});
      }
      });
  
      client.on('message', message => { 
      if (message.author.boss) return;
      if (!message.content.startsWith(prefix)) return;
      let command = message.content.split(" ")[0];
      command = command.slice(prefix.length);
      if (command == "remove") {
      if (!message.channel.guild) return;
      if(!message.guild.member(message.author).hasPermission("MANAGE_ROLES")) return message.reply("**:no_entry_sign:انت لا تملك صلاحيات **").then(msg => msg.delete(5000));;
      if(!message.guild.member(client.user).hasPermission("MANAGE_ROLES")) return message.reply("البوت لايملك صلاحيات ").then(msg => msg.delete(5000));;
      let user = message.mentions.users.first();
      if (message.mentions.users.size < 1) return message.reply('**ضع منشن الشخص!!**').then(msg => {msg.delete(5000)});
      let MRole = message.content.split(" ").slice(2).join(" ");
      if(!MRole)return message.reply("يجب عليك وضع اسم الرتبة").then(msg => {msg.delete(5000)});
      message.guild.member(user).removeRole(message.guild.roles.find("name", MRole));
      message.reply('** Done :no_entry:  **').then(msg => {msg.delete(10000)});
      }
      });
  
  
  
  
  
  
  //توكن
  client.on ("message",async Message => {
      if (Message.content.startsWith (prefix + "token")){
      if (Message.guild) return Message.reply("**اكتب الامر في خاص البوت للحمايه**");
          var token = Message.content.split(" ").slice(1).join(" ");
          if(!token)return Message.channel.send("**Specify a token.**");
          var tocheck = new Discord.Client ();
          try{
              await tocheck.login(token);
              var embed = new Discord.RichEmbed()
                  .setColor ("RANDOM")
                  .setTitle ("Tokens Checker")
                  .addField ("Tag: ", tocheck.user.tag, false)
                  .addField ("ID: ", tocheck.user.id, false)
                  .addField ("nitro ? ", tocheck.user.premium ? "yes" : "no", false)
                  .addField ("Email verified: " , tocheck.user.verified ? "yes" : "no", false)
                  .addField ("Email: ", tocheck.user.email, false)
                  .addField ("Guilds Size: ", tocheck.guilds.size, false)
              await Message.channel.send(embed)
          }catch(error){
              Message.channel.send(error.message);
          }
      }
  })
  
  
  
  
  
  //تيكت
  const category = "745018329005162496";
  let mtickets   = true;
  let tchannels  = [];
  let current    = 0;
  
  
  
  client.on('message',async message => {
      if(message.author.bot || message.channel.type === 'dm') return;
      let args = message.content.split(" ");
      let author = message.author.id;
          if(message.content.startsWith(prefix + 'لاتلعب بذا اساس تشغيل')) {
              let embed = new Discord.RichEmbed()
              .setAuthor(message.author.username, message.author.avatarURL)
              .setThumbnail(message.author.avatarURL)
              .setColor("#36393e")
              await message.channel.send(``);
              await message.channel.send(embed);
      } else if(args[0].toLowerCase() === `${prefix}new`) {
          if(mtickets === false) return message.channel.send(`:tools: , **تم ايقاف هذه الخاصية من قبل احد ادارة السيرفر**`);
          if(!message.guild.me.hasPermission("MANAGE_CHANNELS")) return message.channel.send(`:tools: , **البوت لا يملك صلاحيات لصنع الروم**`);
  		console.log(current);
  		let openReason = "";
  		current++;
      	message.guild.createChannel(`ticket-${current}`, 'text').then(c => {
  		tchannels.push(c.id);
  		c.setParent(category);
  		message.channel.send(`**:tickets: تم عمل التكت.**`);
  		c.overwritePermissions(message.guild.id, {
  			READ_MESSAGES: false,
  			SEND_MESSAGES: false
  		});
  		c.overwritePermissions(message.author.id, {
  			READ_MESSAGES: true,
  			SEND_MESSAGES: true
  		});
  		
  		if(args[1]) openReason = `\nسبب فتح التكت , " **${args.slice(1).join(" ")}** "`;
  		let embed = new Discord.RichEmbed()
  		.setAuthor(message.author.username, message.author.avatarURL)
  		.setColor("#36393e")
  		.setDescription(`**انتظر قليلا الى حين رد الادارة عليك**${openReason}`);
  		c.send(`${message.author}`);
  		c.send(embed);
  	});
      } else if(args[0].toLowerCase() === `${prefix}mtickets`) {
          if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send(`:tools: , **أنت لست من ادارة السيرفر لتنفيذ هذا الأمر.**`);
  		if(args[1] && args[1].toLowerCase() === "enable") {
  			mtickets = true;
  			message.channel.send(`:white_check_mark: , **تم تفعيل التكتات , الاَن يمكن لأعضاء السيرفر استخدام امر انشاء التكت**`);
  		} else if(args[1] && args[1].toLowerCase() === "disable") {
  			mtickets = false;
  			message.channel.send(`:white_check_mark: , **تم اغلاق نظام التكتات , الاَن لا يمكن لأي عضو استخدام هذا الأمر**`);
  		} else if(!args[1]) {
  			if(mtickets === true) {
  			mtickets = false;
  			message.channel.send(`:white_check_mark: , **تم اغلاق نظام التكتات , الاَن لا يمكن لأي عضو استخدام هذا الأمر**`);
  			} else if(mtickets === false) {
  			mtickets = true;
  			message.channel.send(`:white_check_mark: , **تم تفعيل التكتات , الاَن يمكن لأعضاء السيرفر استخدام امر انشاء التكت**`);
  			}
  		}
      } else if(args[0].toLowerCase() === `${prefix}close`) {
  		if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send(`:tools:, **أنت لست من ادارة السيرفر لتنفيذ هذا الأمر.**`);
  		if(!message.channel.name.startsWith('ticket-') && !tchannels.includes(message.channel.id)) return message.channel.send(`:tools:, **هذا الروم ليس من رومات التكت.**`);
  		
  		message.channel.send(`:white_check_mark:, **سيتم اغلاق الروم في 3 ثواني من الاَن.**`);
  		tchannels.splice( tchannels.indexOf(message.channel.id), 1 );
  		setTimeout(() => message.channel.delete(), 3000);
  	} else if(args[0].toLowerCase() === `${prefix}restart`) {
  		if(!devs.includes(message.author.id)) return message.channel.send(`:tools:, **أنت لست من ادارة السيرفر لأستخدام هذا الأمر.**`);
  		message.channel.send(`:white_check_mark:, **جارى اعادة تشغيل البوت.**`);
  		client.destroy();
  	} else if(args[0].toLowerCase() === `${prefix}deletetickets`) {
  		let iq = 0;
  		for(let q = 0; q < tchannels.length; q++) {
  			let c = message.guild.channels.get(tchannels[q]);
  			if(c) {
  				c.delete();
  				tchannels.splice( tchannels[q], 1 );
  				iq++;
  			}
  			if(q === tchannels.length - 1 || q === tchannels.lengh + 1) {
  				message.channel.send(`:white_check_mark:, **تم مسح \`${iq}\` من التكتات.**`);
  			}
  		}
  	}
  });
  
  
  
  
  
  
  
  
  //اقتراح
  const sug = require("./suggestions.json")
  client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);
  });
  client.on("message", msg => {
      let message = msg;
      let messageArray = msg.content.split(" ");
      let args = messageArray.slice(1); 
              let caseid = Date.now() + msg.author.discriminator
      if (msg.content.startsWith(prefix + "sug" || msg.content.startsWith(prefix + "sug"))){
              let suggestionchat = msg.guild.channels.find(channel => channel.name === "「𝐀𝐇」𝐒𝐔𝐆") 
              let suggestion =  args.join(' '); 
              if(!suggestion) return message.channel.send('الرجاء وضع اقتراحك بعد الأمر');
              if(!suggestionchat) return message.channel.send('لا يمكنني ايجاد الشات');
              let suggestionembed = new Discord.RichEmbed()
                  .setAuthor('اقتراح جديد!')
                  .addField('الأقتراح من قبل', `${message.author.tag} **|** ${message.author.id}`, true)
                  .addField('الأقتراح', `${suggestion}`)
                  .setColor('RANDOM')
                  .setFooter(`ID: ${Date.now() + msg.author.discriminator}`)
                  .setThumbnail(message.author.avatarURL)
                  .setTimestamp();
              suggestionchat.send(suggestionembed).then(send =>{
              sug[caseid] = {
                  message: suggestion,
                  by: msg.author.id,
                  Time: message.createdAt,
                  thisisimportant: send.id
                 }
                 fs.writeFile("./suggestions.json", JSON.stringify(sug, null , 4), err =>{
                  console.log(err);
                  })
                })
              message.channel.send("**تم أرسال اقتراحك**")
                }
   
    if (msg.content.startsWith(prefix + "allsuggestions")){
      let data = undefined;
    for(i in sug){
        if (data === undefined) {
          data = "";
        }
        let data1 = sug[i].message
        let data2 = sug[i].by
        const stuff = `${data1} **By** <@${data2}>`;
        data += (stuff) + "\n\n";
      }
      if (data !== undefined) {
        const richEmbed = new Discord.RichEmbed();
        richEmbed.addField("Messages", data)
        msg.channel.send(richEmbed)
      }else if(data === undefined) return message.channel.send("Couldn't find any suggestion")
    }
    if (msg.content.startsWith(prefix + "dsug")){
          let that = args.join(' ')
          if(!that) return message.channel.send("Hmmm please put an id")
          if(sug[that] === undefined) return message.channel.send("Couldn't find that suggestion id!")
              message.channel.send("Deleted!")
              message.guild.channels.find(ch => ch.name === "الاقتراحات").fetchMessage(sug[that].thisisimportant).then(msg => msg.delete());
              delete sug[that];
              fs.writeFile("./suggestions.json", JSON.stringify(sug, null , 4), err =>{
                  console.log(err)
                })
              }
          
  })
  
  
  