Rashwan-

antigreff + sugttions +auto role + members

Mar 24th, 2020
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let anti = JSON.parse(fs.readFileSync("./antigreff.json", "UTF8"));
  2. let config = JSON.parse(fs.readFileSync("./config.json", "UTF8"));
  3. client.on("message", message => {
  4.     if (!message.channel.guild) return;
  5.     let user = anti[message.guild.id + message.author.id]
  6.     let num = message.content.split(" ").slice(2).join(" ");
  7.     if (!anti[message.guild.id + message.author.id]) anti[message.guild.id + message.author.id] = {
  8.         actions: 0
  9.     }
  10.     if (!config[message.guild.id]) config[message.guild.id] = {
  11.         banLimit: 3,
  12.         chaDelLimit: 3,
  13.         roleDelLimit: 3,
  14.         kickLimits: 3,
  15.         roleCrLimits: 3,
  16.         time: 30
  17.     }
  18.     if (message.content.startsWith(prefix + "settings limits")) {
  19.  
  20.  
  21.         if (!message.member.hasPermission('MANAGE_GUILD')) return;
  22.         if (message.content.startsWith(prefix + "settings limitsban")) {
  23.             if (!num) return message.channel.send("**? | أرسل رقم ! **");
  24.             if (isNaN(num)) return message.channel.send("**? | أرقام فقط ! **");
  25.             config[message.guild.id].banLimit = num;
  26.             message.channel.send(`**? | تم التغيير اِلي : ${config[message.guild.id].banLimit} **`)
  27.         }
  28.         if (message.content.startsWith(prefix + "settings limitskick")) {
  29.             if (!num) return message.channel.send("**? | أرسل رقم ! **");
  30.             if (isNaN(num)) return message.channel.send("**? | أرقام فقط ! **");
  31.             config[message.guild.id].kickLimits = num;
  32.             message.channel.send(`**? | تم التغيير اِلي : ${config[message.guild.id].kickLimits}**`)
  33.         }
  34.         if (message.content.startsWith(prefix + "settings limitsroleD")) {
  35.             if (!num) return message.channel.send("**? | أرسل رقم ! **");
  36.             if (isNaN(num)) return message.channel.send("**? | أرقام فقط ! **");
  37.             config[message.guild.id].roleDelLimit = num;
  38.             message.channel.send(`**? | تم التغيير اِلي : ${config[message.guild.id].roleDelLimit}**`)
  39.         }
  40.         if (message.content.startsWith(prefix + "settings limitsroleC")) {
  41.             if (!num) return message.channel.send("**? | أرسل رقم ! **");
  42.             if (isNaN(num)) return message.channel.send("**? | أرقام فقط ! **");
  43.             config[message.guild.id].roleCrLimits = num;
  44.             message.channel.send(`**? | تم التغيير اِلي : ${config[message.guild.id].roleCrLimits}**`)
  45.         }
  46.         if (message.content.startsWith(prefix + "settings limitschannelD")) {
  47.             if (!num) return message.channel.send("**? | أرسل رقم ! **");
  48.             if (isNaN(num)) return message.channel.send("**? | أرقام فقط ! **");
  49.             config[message.guild.id].chaDelLimit = num;
  50.             message.channel.send(`**? | تم التغيير اِلي : ${config[message.guild.id].chaDelLimit}**`)
  51.         }
  52.         if (message.content.startsWith(prefix + "settings limitstime")) {
  53.             if (!num) return message.channel.send("**? | أرسل رقم ! **");
  54.             if (isNaN(num)) return message.channel.send("**? | أرقام فقط ! **");
  55.             config[message.guild.id].time = num;
  56.             message.channel.send(`**? | تم التغيير اِلي : ${config[message.guild.id].time}**`)
  57.         }
  58.         fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  59.             if (e) throw e;
  60.         });
  61.         fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  62.             if (e) throw e;
  63.         });
  64.     }
  65. });
  66. client.on("channelDelete", async channel => {
  67.     const entry1 = await channel.guild.fetchAuditLogs({
  68.         type: 'CHANNEL_DELETE'
  69.     }).then(audit => audit.entries.first())
  70.     console.log(entry1.executor.username)
  71.     const entry = entry1.executor
  72.     if (!config[channel.guild.id]) config[channel.guild.id] = {
  73.         banLimit: 3,
  74.         chaDelLimit: 3,
  75.         roleDelLimit: 3,
  76.         kickLimits: 3,
  77.         roleCrLimits: 3
  78.     }
  79.     if (!anti[channel.guild.id + entry.id]) {
  80.         anti[channel.guild.id + entry.id] = {
  81.             actions: 1
  82.         }
  83.         setTimeout(() => {
  84.             anti[channel.guild.id + entry.id].actions = "0"
  85.         }, config[channel.guild.id].time * 1000)
  86.     } else {
  87.         anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
  88.         console.log("TETS");
  89.         setTimeout(() => {
  90.             anti[channel.guild.id + entry.id].actions = "0"
  91.         }, config[channel.guild.id].time * 1000)
  92.         if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].chaDelLimit) {
  93.             channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**? | ${entry.username} قام بمسح الكثير من الرومات **`))
  94.             anti[channel.guild.id + entry.id].actions = "0"
  95.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  96.                 if (e) throw e;
  97.             });
  98.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  99.                 if (e) throw e;
  100.             });
  101.         }
  102.     }
  103.  
  104.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  105.         if (e) throw e;
  106.     });
  107.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  108.         if (e) throw e;
  109.     });
  110. });
  111.  
  112. client.on("roleDelete", async channel => {
  113.     const entry1 = await channel.guild.fetchAuditLogs({
  114.         type: 'ROLE_DELETE'
  115.     }).then(audit => audit.entries.first())
  116.     console.log(entry1.executor.username)
  117.     const entry = entry1.executor
  118.     if (!config[channel.guild.id]) config[channel.guild.id] = {
  119.         banLimit: 3,
  120.         chaDelLimit: 3,
  121.         roleDelLimit: 3,
  122.         kickLimits: 3,
  123.         roleCrLimits: 3
  124.     }
  125.     if (!anti[channel.guild.id + entry.id]) {
  126.         anti[channel.guild.id + entry.id] = {
  127.             actions: 1
  128.         }
  129.         setTimeout(() => {
  130.             anti[channel.guild.id + entry.id].actions = "0"
  131.         }, config[channel.guild.id].time * 1000)
  132.     } else {
  133.         anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
  134.         console.log("TETS");
  135.         setTimeout(() => {
  136.             anti[channel.guild.id + entry.id].actions = "0"
  137.         }, config[channel.guild.id].time * 1000)
  138.         if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].roleDelLimit) {
  139.             channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**? | ${entry.username} قام بمسح الكثير من الرتب **`))
  140.             anti[channel.guild.id + entry.id].actions = "0"
  141.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  142.                 if (e) throw e;
  143.             });
  144.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  145.                 if (e) throw e;
  146.             });
  147.         }
  148.     }
  149.  
  150.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  151.         if (e) throw e;
  152.     });
  153.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  154.         if (e) throw e;
  155.     });
  156. });
  157.  
  158. client.on("roleCreate", async channel => {
  159.     const entry1 = await channel.guild.fetchAuditLogs({
  160.         type: 'ROLE_CREATE'
  161.     }).then(audit => audit.entries.first())
  162.     console.log(entry1.executor.username)
  163.     const entry = entry1.executor
  164.     if (!config[channel.guild.id]) config[channel.guild.id] = {
  165.         banLimit: 3,
  166.         chaDelLimit: 3,
  167.         roleDelLimit: 3,
  168.         kickLimits: 3,
  169.         roleCrLimits: 3
  170.     }
  171.     if (!anti[channel.guild.id + entry.id]) {
  172.         anti[channel.guild.id + entry.id] = {
  173.             actions: 1
  174.         }
  175.         setTimeout(() => {
  176.             anti[channel.guild.id + entry.id].actions = "0"
  177.         }, config[channel.guild.id].time * 1000)
  178.     } else {
  179.         anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
  180.         console.log("TETS");
  181.         setTimeout(() => {
  182.             anti[channel.guild.id + entry.id].actions = "0"
  183.         }, config[channel.guild.id].time * 1000)
  184.         if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].roleCrLimits) {
  185.             channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**? | ${entry.username} قام بأنشاء الكثير من الرتب **`))
  186.             anti[channel.guild.id + entry.id].actions = "0"
  187.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  188.                 if (e) throw e;
  189.             });
  190.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  191.                 if (e) throw e;
  192.             });
  193.         }
  194.     }
  195.  
  196.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  197.         if (e) throw e;
  198.     });
  199.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  200.         if (e) throw e;
  201.     });
  202. });
  203.  
  204. client.on("guildBanAdd", async (guild, user) => {
  205.     const entry1 = await channel.guild.fetchAuditLogs({
  206.         type: 'MEMBER_BAN_ADD'
  207.     }).then(audit => audit.entries.first())
  208.     console.log(entry1.executor.username)
  209.     const entry = entry1.executor
  210.     if (!config[guild.id]) config[guild.id] = {
  211.         banLimit: 3,
  212.         chaDelLimit: 3,
  213.         roleDelLimit: 3,
  214.         kickLimits: 3,
  215.         roleCrLimits: 3
  216.     }
  217.     if (!anti[guild.id + entry.id]) {
  218.         anti[guild.id + entry.id] = {
  219.             actions: 1
  220.         }
  221.         setTimeout(() => {
  222.             anti[guild.id + entry.id].actions = "0"
  223.         }, config[guild.id].time * 1000)
  224.     } else {
  225.         anti[guild.id + entry.id].actions = Math.floor(anti[guild.id + entry.id].actions + 1)
  226.         console.log("TETS");
  227.         setTimeout(() => {
  228.             anti[guild.id + entry.id].actions = "0"
  229.         }, config[guild.id].time * 1000)
  230.         if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
  231.             channel.members.get(entry.id).ban().catch(e => channel.owner.send(`**? | ${entry.username} حاول حظر جميع الأعضاء **`))
  232.             anti[guild.id + entry.id].actions = "0"
  233.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  234.                 if (e) throw e;
  235.             });
  236.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  237.                 if (e) throw e;
  238.             });
  239.         }
  240.     }
  241.  
  242.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  243.         if (e) throw e;
  244.     });
  245.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  246.         if (e) throw e;
  247.     });
  248. });
  249.  
  250. client.on("guildKickAdd", async (guild, user) => {
  251.     const entry1 = await channel.fetchAuditLogs({
  252.         type: 'MEMBER_KICK'
  253.     }).then(audit => audit.entries.first())
  254.     console.log(entry1.executor.username)
  255.     const entry = entry1.executor
  256.     if (!config[guild.id]) config[guild.id] = {
  257.         banLimit: 3,
  258.         chaDelLimit: 3,
  259.         roleDelLimit: 3,
  260.         kickLimits: 3,
  261.         roleCrLimits: 3
  262.     }
  263.     if (!anti[guild.id + entry.id]) {
  264.         anti[guild.id + entry.id] = {
  265.             actions: 1
  266.         }
  267.         setTimeout(() => {
  268.             anti[guild.id + entry.id].actions = "0"
  269.         }, config[guild.id].time * 1000)
  270.     } else {
  271.         anti[guild.id + entry.id].actions = Math.floor(anti[guild.id + entry.id].actions + 1)
  272.         console.log("TETS");
  273.         setTimeout(() => {
  274.             anti[guild.id + entry.id].actions = "0"
  275.         }, config[guild.id].time * 1000)
  276.         if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
  277.             channel.members.get(entry.id).ban().catch(e => channel.owner.send(`**? | ${entry.username} حاول حظر جميع الأعضاء **`))
  278.             anti[guild.id + entry.id].actions = "0"
  279.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  280.                 if (e) throw e;
  281.             });
  282.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  283.                 if (e) throw e;
  284.             });
  285.         }
  286.     }
  287.  
  288.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  289.         if (e) throw e;
  290.     });
  291.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  292.         if (e) throw e;
  293.     });
  294. });
  295.  
  296. client.on("guildMemberRemove", async member => {
  297.     const entry1 = await member.guild.fetchAuditLogs().then(audit => audit.entries.first())
  298.     if (entry1.action === "MEMBER_KICK") {
  299.         const entry2 = await member.guild.fetchAuditLogs({
  300.             type: "MEMBER_KICK"
  301.         }).then(audit => audit.entries.first())
  302.         const entry = entry2.executor;
  303.         if (!config[member.guild.id]) config[guild.id] = {
  304.             banLimit: 3,
  305.             chaDelLimit: 3,
  306.             roleDelLimit: 3,
  307.             kickLimits: 3,
  308.             roleCrLimits: 3
  309.         }
  310.         if (!anti[member.guild.id + entry.id]) {
  311.             anti[member.guild.id + entry.id] = {
  312.                 actions: 1
  313.             }
  314.             setTimeout(() => {
  315.                 anti[member.guild.id + entry.id].actions = "0"
  316.             }, config[member.guild.id].time * 1000)
  317.         } else {
  318.             anti[member.guild.id + entry.id].actions = Math.floor(anti[member.guild.id + entry.id].actions + 1)
  319.             console.log("TETS");
  320.             setTimeout(() => {
  321.                 anti[member.guild.id + entry.id].actions = "0"
  322.             }, config[member.guild.id].time * 1000)
  323.             if (anti[member.guild.id + entry.id].actions >= config[member.guild.id].kickLimits) {
  324.                 member.members.get(entry.id).ban().catch(e => member.owner.send(`**? | ${entry.username} حاول حظر جميع الأعضاء **`))
  325.                 anti[member.guild.id + entry.id].actions = "0"
  326.                 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  327.                     if (e) throw e;
  328.                 });
  329.                 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  330.                     if (e) throw e;
  331.                 });
  332.             }
  333.         }
  334.  
  335.         fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  336.             if (e) throw e;
  337.         });
  338.         fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  339.             if (e) throw e;
  340.         });
  341.     }
  342.  
  343. })
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350. const members = JSON.parse(fs.readFileSync("./members.json")) || {};
  351. client.on('ready', () => {
  352.   console.log(`Logged in as ${client.user.tag}!`);
  353.   client.guilds.forEach(g=> !members[g.id] ? members[g.id] = {} : null)
  354. });
  355.  
  356. client.on("guildMemberRemove", member=>{
  357.   let roles = [];
  358.   member.roles.forEach(r=> roles.push(r.id));
  359.   members[member.guild.id][member.id] = roles;
  360.   saveChanges();
  361. });
  362. client.on("guildMemberAdd", member=> {
  363.   if(members[member.guild.id][member.id] !== undefined){
  364.     member.addRoles(members[member.guild.id][member.id], "Returning roles after leaving");
  365.     members[member.guild.id][member.id] = [];
  366.   };
  367.   saveChanges();
  368. });
  369. function saveChanges(){
  370.   fs.writeFileSync("./members.json", JSON.stringify(members, null, 4));
  371. };
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378. const sug = JSON.parse(fs.readFileSync('./sug.json', 'utf8'));
  379. // ?  , ?
  380. client.on('message', message => {
  381.     if (!message.channel.guild) return;
  382.     let room = message.content.split(" ").slice(1);
  383.     let findroom = message.guild.channels.find(x => x.name === `${room}`)
  384.     if (message.content.startsWith(prefix + "setSug")) {
  385.         if (!message.channel.guild) return;
  386.         if (!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send(`** | Don\'t have perms.**`);
  387.        if (!room) return message.channel.send(`** | Please type the channel name.**`)
  388.        if (!findroom) return message.channel.send(`** | Can\'t found this channel.**`)
  389.        let embed = new Discord.RichEmbed()
  390.            .addField(`? Channel:`, `? \`${room}\`.`)
  391.            .addField(`? Requested By:`, `? \`${message.author}\``)
  392.            .setThumbnail(message.author.avatarURL)
  393.            .setFooter(`${client.user.username}`)
  394.        message.channel.sendEmbed(embed)
  395.        sug[message.guild.id] = {
  396.            channel: room,
  397.        }
  398.        fs.writeFile("./sug.json", JSON.stringify(sug), (err) => {
  399.            if (err) console.error(err)
  400.        })
  401.        client.on('message', message => {
  402.            // ?  , ?
  403.            if (message.content.startsWith(`sug`)) {
  404.                if (!message.channel.guild) return;
  405.                let suggest = message.content.split(" ").slice(1);
  406.                if (!suggest) return message.reply(`** | Please type the suggest.**`)
  407.                let findchannel = (message.guild.channels.find(x => x.name === `${sug[message.guild.id].channel}`))
  408.                if (!findchannel) return message.channel.send(`**  | Error: \`Can\'t find the suggestions room.**`)
  409.                message.channel.send(`**| Thanks for your suggest.**`)
  410.                let sugembed = new Discord.RichEmbed()
  411.                    .setTitle('? New suggest:')
  412.                    .addField('? Suggest By:', `? \`${message.author}\``)
  413.                    .addField('? Suggest:', `? \`${suggest}\``)
  414.                    .setFooter(client.user.username)
  415.                findchannel.sendEmbed(sugembed)
  416.                    .then(function (message) {
  417.                        message.react('?')
  418.                        message.react('?')
  419.                    })
  420.                    .catch(err => {
  421.                        message.reply(`**  | Error: \`Can\'t find the suggestions room.**`)
  422.                        console.error(err);
  423.                    });
  424.            }
  425.        })
  426.    }
  427. })
  428.  
  429.  
  430. const rWlc = JSON.parse(fs.readFileSync("./AutoRole.json", "utf8"));
  431. client.on('message', message => {
  432. var prefix = "-";//البرفكس
  433. if(message.channel.type === "dm") return;
  434. if(message.author.bot) return;
  435.   if(!rWlc[message.guild.id]) rWlc[message.guild.id] = {
  436.    role: "member"
  437.  }
  438. const channel = rWlc[message.guild.id].role
  439.  if (message.content.startsWith(prefix + "autorole")) {
  440.    if(!message.member.hasPermission(`MANAGE_GUILD`)) return;
  441.    let newrole = message.content.split(' ').slice(1).join(" ")
  442.    if(!newrole) return message.reply(`**${prefix}autorole <role name>**`)
  443.    rWlc[message.guild.id].role = newrole
  444.    message.channel.send(`**${message.guild.name}'s role has been changed to ${newrole}**`);
  445.   }
  446. fs.writeFile("./AutoRole.json", JSON.stringify(rWlc), function(e){
  447.     if (e) throw e;
  448. })
  449. });
  450. client.on("guildMemberAdd", member => {
  451.       if(!rWlc[member.guild.id]) rWlc[member.guild.id] = {
  452.     role: "member"
  453.   }
  454.     const sRole = rWlc[member.guild.id].role
  455.     let Rrole = member.guild.roles.find('name', sRole);
  456.   member.addRole(Rrole);
  457.  
  458.       });
  459.  
  460. client.on("message", msg => {
  461.     if(msg.content.startsWith(prefix + "infoautorole")){
  462.     var sRole = rWlc[msg.guild.id].role
  463. let emb = new Discord.RichEmbed()
  464. .setTitle("**AutoRole معلومات**")
  465. .setAuthor(msg.guild.name,msg.guild.iconURL)
  466. .setThumbnail(msg.guild.iconURL)
  467. .setColor("GREEN")
  468. .addField("**ايدي السيرفر**", msg.guild.id)
  469. .addField("**اسم السيرفر**", msg.guild.name)
  470. .addField("**الرتبه المحددة**", sRole)
  471. .setFooter(client.user.tag,client.user.avatarURL)
  472. msg.channel.send(emb)
  473.     }
  474. });
  475.  
  476.  
  477. let antijoin = JSON.parse(fs.readFileSync('./antijoin.json' , 'utf8'));
  478. /*يحتاج تعرف بكج const fs = require('fs')
  479. طبعا لو مو معرف البكج ^
  480. + تثبت البكج npm i fs
  481. */
  482. client.on('message', message => {
  483.     if(message.content.startsWith(prefix + "antijoin on")) {
  484.         if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  485.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  486. antijoin[message.guild.id] = {
  487. onoff: 'On',
  488. }
  489. message.channel.send(`**? The AntiJoin Is __????__ !**`)
  490.           fs.writeFile("./antijoin.json", JSON.stringify(antijoin), (err) => {
  491.             if (err) return console.error(err)
  492.             .catch(err => {
  493.               console.error(err);
  494.           });
  495.             });
  496.           }
  497.  
  498.         })
  499.  
  500.  
  501.  
  502. client.on('message', message => {
  503.     if(message.content.startsWith(prefix + "antijoin off")) {
  504.         if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  505.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  506. antijoin[message.guild.id] = {
  507. onoff: 'Off',
  508. }
  509. message.channel.send(`**? The AntiJoin Is __??????__ !**`)
  510.           fs.writeFile("./antijoin.json", JSON.stringify(antijoin), (err) => {
  511.             if (err) return console.error(err)
  512.             .catch(err => {
  513.               console.error(err);
  514.           });
  515.             });
  516.           }
  517.  
  518.         })
  519.          client.on('message', message => {
  520.           if (!message.channel.guild) return;
  521.  
  522.  
  523.    if(message.content.startsWith(prefix + "setJoin")) {
  524.           let time = message.content.split(" ").slice(1).join(" ");
  525.        if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  526.        if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  527. if (!time) return message.channel.send('Please Type The Account Created Time [Days]');
  528. let embed = new Discord.RichEmbed()
  529. .setTitle('**Done The AntiJoin Code Has Been Setup**')
  530. .addField('Account Create Time:', `${time}.`)
  531. .addField('Requested By:', `${message.author}`)
  532. .setThumbnail(message.author.avatarURL)
  533. .setFooter(`${client.user.username}`)
  534. message.channel.sendEmbed(embed)
  535. antijoin[message.guild.id] = {
  536. created: time,
  537. onoff: 'On',
  538. }
  539. fs.writeFile("./antijoin.json", JSON.stringify(antijoin), (err) => {
  540. if (err) console.error(err)
  541. })
  542.    }})
  543.  
  544. client.on("guildMemberAdd", async member => {
  545.   if(!antijoin[member.guild.id]) antijoin[member.guild.id] = {
  546.     onoff: 'Off'
  547.   }
  548.   if(antijoin[member.guild.id].onoff === 'Off') return;
  549.   if(!member.user.bot) return;
  550.     let accounttime = `${antijoin[member.guild.id].created}`
  551.     let moment2 = require('moment-duration-format'),
  552.         moment = require("moment"),
  553.         date = moment.duration(new Date() - member.user.createdAt).format("d");
  554.  
  555.     if(date < accounttime) {
  556.       member.ban(`Member account age is lower than ${antijoin[member.guild.id].created} days.`)
  557.     }
  558.   });
Add Comment
Please, Sign In to add comment