Advertisement
AcTCrAFT2004

Protect bot

Feb 3rd, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', message => {
  2.  
  3.     if (message.author.bot) return;
  4.     if (!message.guild) return;
  5.     if (message.content.startsWith(prefix + 'config')) {
  6.      
  7.     var mrx = new Discord.RichEmbed()
  8.    
  9.     .setTitle(`**__${message.guild.name}__ , Server Settings**`)
  10.  
  11.    
  12.  
  13.  
  14.     .addField('Ban Limit Info', `
  15. **| Count : __\`${config[message.guild.id].banLimit} \`__**
  16. `)
  17.         .addField('Kick Limit Info', `
  18. **| Count : __\`${config[message.guild.id].kickLimits} \`__**
  19. `)
  20.     .addField('Role Delete Limit Info', `
  21. **| Count : __\`${config[message.guild.id].roleDelLimit} \`__**
  22. `)
  23.    
  24.     .addField('Role Create Limit Info', `
  25. **| Count : __\`${config[message.guild.id].roleCrLimits} \`__**
  26. `)
  27.     .addField('Channel Delete Limit Info', `
  28. **| Count : __\`${config[message.guild.id].chaDelLimit} \`__**
  29. `)
  30.    
  31.    
  32.     //.setFooter(message.author.avatarURL, message.author.tag)
  33. message.channel.sendEmbed(mrx);
  34.     }
  35. });
  36. let anti = JSON.parse(fs.readFileSync("./antigreff.json", "UTF8"));
  37. let config = JSON.parse(fs.readFileSync("./config.json", "UTF8"));
  38. client.on("message", message => {
  39.     if (!message.channel.guild) return;
  40.     let user = anti[message.guild.id + message.author.id]
  41.     let num = message.content.split(" ").slice(2).join(" ");
  42.     if (!anti[message.guild.id + message.author.id]) anti[message.guild.id + message.author.id] = {
  43.         actions: 0
  44.     }
  45.     if (!config[message.guild.id]) config[message.guild.id] = {
  46.         banLimit: 3,
  47.         chaDelLimit: 3,
  48.         roleDelLimit: 3,
  49.         kickLimits: 3,
  50.         roleCrLimits: 3,
  51.         time: 30
  52.     }
  53.     if (message.content.startsWith(prefix + "settings limits")) {
  54.  
  55.  
  56.         if (!message.member.hasPermission('MANAGE_GUILD')) return;
  57.         if (message.content.startsWith(prefix + "settings limitsban")) {
  58.             if (!num) return message.channel.send("**⇏ | Type Number**");
  59.             if (isNaN(num)) return message.channel.send("**⇏ | Number Only**");
  60.             config[message.guild.id].banLimit = num;
  61.             message.channel.send(`**| Done It's Now : ${config[message.guild.id].banLimit} **`)
  62.        }
  63.        if (message.content.startsWith(prefix + "settings limitskick")) {
  64.            if (!num) return message.channel.send("**⇏ | Type Number**");
  65.            if (isNaN(num)) return message.channel.send("**⇏ | Numbers Only **");
  66.            config[message.guild.id].kickLimits = num;
  67.            message.channel.send(`**⇏ | Done It's Now : ${config[message.guild.id].kickLimits}**`)
  68.         }
  69.         if (message.content.startsWith(prefix + "settings limitsroleD")) {
  70.             if (!num) return message.channel.send("**⇏ | Type Number**");
  71.             if (isNaN(num)) return message.channel.send("**Numbers Only**");
  72.             config[message.guild.id].roleDelLimit = num;
  73.             message.channel.send(`**| Done It's Now : ${config[message.guild.id].roleDelLimit}**`)
  74.        }
  75.        if (message.content.startsWith(prefix + "settings limitsroleC")) {
  76.            if (!num) return message.channel.send("**⇏ | Type Number**");
  77.            if (isNaN(num)) return message.channel.send("**⇏ | Numbers Only**");
  78.            config[message.guild.id].roleCrLimits = num;
  79.            message.channel.send(`**⇏ | Done It's Now : ${config[message.guild.id].roleCrLimits}**`)
  80.         }
  81.         if (message.content.startsWith(prefix + "settings limitschannelD")) {
  82.             if (!num) return message.channel.send("**⇏ | Type Number **");
  83.             if (isNaN(num)) return message.channel.send("**⇏ | Numbers Only **");
  84.             config[message.guild.id].chaDelLimit = num;
  85.             message.channel.send(`**| Done It's Now : ${config[message.guild.id].chaDelLimit}**`)
  86.        }
  87.        if (message.content.startsWith(prefix + "settings limitstime")) {
  88.            if (!num) return message.channel.send("**⇏ | Type Number **");
  89.            if (isNaN(num)) return message.channel.send("**⇏ | Numbers Only**");
  90.            config[message.guild.id].time = num;
  91.            message.channel.send(`**⇏ | Done It's Now : ${config[message.guild.id].time}**`)
  92.         }
  93.         fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  94.             if (e) throw e;
  95.         });
  96.         fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  97.             if (e) throw e;
  98.         });
  99.     }
  100. });
  101. client.on("channelDelete", async channel => {
  102.     const entry1 = await channel.guild.fetchAuditLogs({
  103.         type: 'CHANNEL_DELETE'
  104.     }).then(audit => audit.entries.first())
  105.     console.log(entry1.executor.username)
  106.     const entry = entry1.executor
  107.     if (!config[channel.guild.id]) config[channel.guild.id] = {
  108.         banLimit: 3,
  109.         chaDelLimit: 3,
  110.         roleDelLimit: 3,
  111.         kickLimits: 3,
  112.         roleCrLimits: 3
  113.     }
  114.     if (!anti[channel.guild.id + entry.id]) {
  115.         anti[channel.guild.id + entry.id] = {
  116.             actions: 1
  117.         }
  118.         setTimeout(() => {
  119.             anti[channel.guild.id + entry.id].actions = "0"
  120.         }, config[channel.guild.id].time * 1000)
  121.     } else {
  122.         anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
  123.         console.log("TETS");
  124.         setTimeout(() => {
  125.             anti[channel.guild.id + entry.id].actions = "0"
  126.         }, config[channel.guild.id].time * 1000)
  127.         if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].chaDelLimit) {
  128.             channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**| ${entry.username} He Tried To Delete Many Channels**`))
  129.             anti[channel.guild.id + entry.id].actions = "0"
  130.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  131.                 if (e) throw e;
  132.             });
  133.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  134.                 if (e) throw e;
  135.             });
  136.         }
  137.     }
  138.  
  139.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  140.         if (e) throw e;
  141.     });
  142.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  143.         if (e) throw e;
  144.     });
  145. });
  146.  
  147. client.on("roleDelete", async channel => {
  148.     const entry1 = await channel.guild.fetchAuditLogs({
  149.         type: 'ROLE_DELETE'
  150.     }).then(audit => audit.entries.first())
  151.     console.log(entry1.executor.username)
  152.     const entry = entry1.executor
  153.     if (!config[channel.guild.id]) config[channel.guild.id] = {
  154.         banLimit: 3,
  155.         chaDelLimit: 3,
  156.         roleDelLimit: 3,
  157.         kickLimits: 3,
  158.         roleCrLimits: 3
  159.     }
  160.     if (!anti[channel.guild.id + entry.id]) {
  161.         anti[channel.guild.id + entry.id] = {
  162.             actions: 1
  163.         }
  164.         setTimeout(() => {
  165.             anti[channel.guild.id + entry.id].actions = "0"
  166.         }, config[channel.guild.id].time * 1000)
  167.     } else {
  168.         anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
  169.         console.log("TETS");
  170.         setTimeout(() => {
  171.             anti[channel.guild.id + entry.id].actions = "0"
  172.         }, config[channel.guild.id].time * 1000)
  173.         if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].roleDelLimit) {
  174.             channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**| ${entry.username} He Tried To Delete Roles**`))
  175.             anti[channel.guild.id + entry.id].actions = "0"
  176.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  177.                 if (e) throw e;
  178.             });
  179.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  180.                 if (e) throw e;
  181.             });
  182.         }
  183.     }
  184.  
  185.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  186.         if (e) throw e;
  187.     });
  188.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  189.         if (e) throw e;
  190.     });
  191. });
  192.  
  193. client.on("roleCreate", async channel => {
  194.     const entry1 = await channel.guild.fetchAuditLogs({
  195.         type: 'ROLE_CREATE'
  196.     }).then(audit => audit.entries.first())
  197.     console.log(entry1.executor.username)
  198.     const entry = entry1.executor
  199.     if (!config[channel.guild.id]) config[channel.guild.id] = {
  200.         banLimit: 3,
  201.         chaDelLimit: 3,
  202.         roleDelLimit: 3,
  203.         kickLimits: 3,
  204.         roleCrLimits: 3
  205.     }
  206.     if (!anti[channel.guild.id + entry.id]) {
  207.         anti[channel.guild.id + entry.id] = {
  208.             actions: 1
  209.         }
  210.         setTimeout(() => {
  211.             anti[channel.guild.id + entry.id].actions = "0"
  212.         }, config[channel.guild.id].time * 1000)
  213.     } else {
  214.         anti[channel.guild.id + entry.id].actions = Math.floor(anti[channel.guild.id + entry.id].actions + 1)
  215.         console.log("TETS");
  216.         setTimeout(() => {
  217.             anti[channel.guild.id + entry.id].actions = "0"
  218.         }, config[channel.guild.id].time * 1000)
  219.         if (anti[channel.guild.id + entry.id].actions >= config[channel.guild.id].roleCrLimits) {
  220.             channel.guild.members.get(entry.id).ban().catch(e => channel.guild.owner.send(`**| ${entry.username} He Tried To Make Many Roles**`))
  221.             anti[channel.guild.id + entry.id].actions = "0"
  222.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  223.                 if (e) throw e;
  224.             });
  225.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  226.                 if (e) throw e;
  227.             });
  228.         }
  229.     }
  230.  
  231.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  232.         if (e) throw e;
  233.     });
  234.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  235.         if (e) throw e;
  236.     });
  237. });
  238.  
  239. client.on("guildBanAdd", async (guild, user) => {
  240.     const entry1 = await guild.guild.fetchAuditLogs({
  241.         type: 'MEMBER_BAN_ADD'
  242.     }).then(audit => audit.entries.first())
  243.     console.log(entry1.executor.username)
  244.     const entry = entry1.executor
  245.     if (!config[guild.id]) config[guild.id] = {
  246.         banLimit: 3,
  247.         chaDelLimit: 3,
  248.         roleDelLimit: 3,
  249.         kickLimits: 3,
  250.         roleCrLimits: 3
  251.     }
  252.     if (!anti[guild.id + entry.id]) {
  253.         anti[guild.id + entry.id] = {
  254.             actions: 1
  255.         }
  256.         setTimeout(() => {
  257.             anti[guild.id + entry.id].actions = "0"
  258.         }, config[guild.id].time * 1000)
  259.     } else {
  260.         anti[guild.id + entry.id].actions = Math.floor(anti[guild.id + entry.id].actions + 1)
  261.         console.log("TETS");
  262.         setTimeout(() => {
  263.             anti[guild.id + entry.id].actions = "0"
  264.         }, config[guild.id].time * 1000)
  265.         if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
  266.             user.members.get(entry.id).ban().catch(e => user.owner.send(`**| ${entry.username} He Tried To Ban Many People**`))
  267.             anti[guild.id + entry.id].actions = "0"
  268.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  269.                 if (e) throw e;
  270.             });
  271.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  272.                 if (e) throw e;
  273.             });
  274.         }
  275.     }
  276.  
  277.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  278.         if (e) throw e;
  279.     });
  280.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  281.         if (e) throw e;
  282.     });
  283. });
  284.  
  285. client.on("guildKickAdd", async (guild, user) => {
  286.     const entry1 = await guild.fetchAuditLogs({
  287.         type: 'MEMBER_KICK'
  288.     }).then(audit => audit.entries.first())
  289.     console.log(entry1.executor.username)
  290.     const entry = entry1.executor
  291.     if (!config[guild.id]) config[guild.id] = {
  292.         banLimit: 3,
  293.         chaDelLimit: 3,
  294.         roleDelLimit: 3,
  295.         kickLimits: 3,
  296.         roleCrLimits: 3
  297.     }
  298.     if (!anti[guild.id + entry.id]) {
  299.         anti[guild.id + entry.id] = {
  300.             actions: 1
  301.         }
  302.         setTimeout(() => {
  303.             anti[guild.id + entry.id].actions = "0"
  304.         }, config[guild.id].time * 1000)
  305.     } else {
  306.         anti[guild.id + entry.id].actions = Math.floor(anti[guild.id + entry.id].actions + 1)
  307.         console.log("TETS");
  308.         setTimeout(() => {
  309.             anti[guild.id + entry.id].actions = "0"
  310.         }, config[guild.id].time * 1000)
  311.         if (anti[guild.id + entry.id].actions >= config[guild.id].banLimit) {
  312.             user.members.get(entry.id).ban().catch(e => user.owner.send(`**| ${entry.username} He Tried To Kick Many People**`))
  313.             anti[guild.id + entry.id].actions = "0"
  314.             fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  315.                 if (e) throw e;
  316.             });
  317.             fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  318.                 if (e) throw e;
  319.             });
  320.         }
  321.     }
  322.  
  323.     fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  324.         if (e) throw e;
  325.     });
  326.     fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  327.         if (e) throw e;
  328.     });
  329. });
  330.  
  331. client.on("guildMemberRemove", async member => {
  332.     const entry1 = await member.guild.fetchAuditLogs().then(audit => audit.entries.first())
  333.     if (entry1.action === "MEMBER_KICK") {
  334.         const entry2 = await member.guild.fetchAuditLogs({
  335.             type: "MEMBER_KICK"
  336.         }).then(audit => audit.entries.first())
  337.         const entry = entry2.executor;
  338.         if (!config[member.guild.id]) config[member.guild.id] = {
  339.             banLimit: 3,
  340.             chaDelLimit: 3,
  341.             roleDelLimit: 3,
  342.             kickLimits: 3,
  343.             roleCrLimits: 3
  344.         }
  345.         if (!anti[member.guild.id + entry.id]) {
  346.             anti[member.guild.id + entry.id] = {
  347.                 actions: 1
  348.             }
  349.             setTimeout(() => {
  350.                 anti[member.guild.id + entry.id].actions = "0"
  351.             }, config[member.guild.id].time * 1000)
  352.         } else {
  353.             anti[member.guild.id + entry.id].actions = Math.floor(anti[member.guild.id + entry.id].actions + 1)
  354.             console.log("TETS");
  355.             setTimeout(() => {
  356.                 anti[member.guild.id + entry.id].actions = "0"
  357.             }, config[member.guild.id].time * 1000)
  358.             if (anti[member.guild.id + entry.id].actions >= config[member.guild.id].kickLimits) {
  359.                 member.members.get(entry.id).ban().catch(e => member.owner.send(`**| ${entry.username} He Tried To Ban Many People**`))
  360.                 anti[member.guild.id + entry.id].actions = "0"
  361.                 fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  362.                     if (e) throw e;
  363.                 });
  364.                 fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  365.                     if (e) throw e;
  366.                 });
  367.             }
  368.         }
  369.  
  370.         fs.writeFile("./config.json", JSON.stringify(config, null, 2), function (e) {
  371.             if (e) throw e;
  372.         });
  373.         fs.writeFile("./antigreff.json", JSON.stringify(anti, null, 2), function (e) {
  374.             if (e) throw e;
  375.         });
  376.     }
  377.  
  378. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement