Advertisement
Rashwan-

anti bots + media room +link and toggle link + setlog

Mar 24th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  let antibots = JSON.parse(fs.readFileSync('./antibots.json' , 'utf8'));//require antihack.json file
  2.   client.on('message', message => {
  3.     if(message.content.startsWith(prefix + "antibots on")){
  4.           if(!message.channel.guild) return;
  5.           if(!message.member.hasPermission('ADMINISTRATOR')) return;
  6.   antibots[message.guild.id] = {
  7.   onoff: 'On',
  8.   }
  9.   message.channel.send(`**<a:true:593078038166503451> | \`ON\`.**`)
  10.             fs.writeFile("./antibots.json", JSON.stringify(antibots), (err) => {
  11.               if (err) console.error(err)
  12.               .catch(err => {
  13.                 console.error(err);
  14.             });
  15.               });
  16.             }
  17.  
  18.           })
  19.  
  20.  
  21.  
  22.   client.on('message', message => {
  23.     if(message.content.startsWith(prefix + "antibots off")) {
  24.           if(!message.channel.guild) return;
  25.           if(!message.member.hasPermission('ADMINISTRATOR')) return;
  26.   antibots[message.guild.id] = {
  27.   onoff: 'Off',
  28.   }
  29.   message.channel.send(`**<a:true:593078038166503451> | \`OFF\`.**`)
  30.             fs.writeFile("./antibots.json", JSON.stringify(antibots), (err) => {
  31.               if (err) console.error(err)
  32.               .catch(err => {
  33.                 console.error(err);
  34.             });
  35.               });
  36.             }
  37.  
  38.           })
  39.  
  40.   client.on("guildMemberAdd", member => {
  41.     if(!antibots[member.guild.id]) antibots[member.guild.id] = {
  42.   onoff: 'Off'
  43.   }
  44.     if(antibots[member.guild.id].onoff === 'Off') return;
  45.   if(member.user.bot) return member.kick()
  46.   })
  47.  
  48.   fs.writeFile("./antibots.json", JSON.stringify(antibots), (err) => {
  49.   if (err) console.error(err)
  50.   .catch(err => {
  51.   console.error(err);
  52.   });
  53.  
  54.   })
  55.  
  56. const pics = JSON.parse(fs.readFileSync('./pics.json' , 'utf8'));
  57.  client.on('message', message => {
  58.          if (!message.channel.guild) return;
  59.  
  60.   let room = message.content.split(" ").slice(1);
  61.   let findroom = message.guild.channels.find('name', `${room}`)
  62.   if(message.content.startsWith(prefix + "setMedia")) {
  63.       if(!message.channel.guild) return;
  64.       if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  65.       if(!room) return message.channel.send('Please Type The Channel Name')
  66.       if(!findroom) return message.channel.send('Cant Find This Channel')
  67.       let embed = new Discord.RichEmbed()
  68.       .setTitle('**Done The MediaOnly Code Has Been Setup**')
  69.       .addField('Channel:', `${room}`)
  70.       .addField('Requested By', `${message.author}`)
  71.       .setThumbnail(message.author.avatarURL)
  72.       .setFooter(`${client.user.username}`)
  73.       message.channel.sendEmbed(embed)
  74.       pics[message.guild.id] = {
  75.       channel: room,
  76.       onoff: 'On'
  77.       },
  78.       fs.writeFile("./pics.json", JSON.stringify(pics), (err) => {
  79.       if (err) console.error(err)
  80.      
  81.       })
  82.     }})
  83.  
  84.  
  85.  
  86. client.on('message', message => {
  87.  
  88.   if(message.content.startsWith(prefix + "toggleMedia")) {
  89.           if (!message.channel.guild) return;
  90.  
  91.       if(!message.channel.guild) return;
  92.       if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  93.       if(!pics[message.guild.id]) pics[message.guild.id] = {
  94.         onoff: 'Off'
  95.       }
  96.         if(pics[message.guild.id].onoff === 'Off') return [message.channel.send(`**The MediaCode Is __????__ !**`), pics[message.guild.id].onoff = 'On']
  97.         if(pics[message.guild.id].onoff === 'On') return [message.channel.send(`**The MediaCode Is __??????__ !**`), pics[message.guild.id].onoff = 'Off']
  98.         fs.writeFile("./pics.json", JSON.stringify(pics), (err) => {
  99.           if (err) console.error(err)
  100.          
  101.           })
  102.         }
  103.        
  104.       })
  105.      
  106.              client.on('message', message => {
  107.                        if (!message.channel.guild) return;
  108.   if(message.author.bot) return;
  109.  
  110.         if(!pics[message.guild.id]) pics[message.guild.id] = {
  111.         onoff: 'Off'
  112.       }
  113.         if(pics[message.guild.id].onoff === 'Off') return;
  114.  
  115.   if(message.channel.name !== `${pics[message.guild.id].channel}`) return;
  116.  
  117.    let types = [
  118.     'jpg',
  119.     'jpeg',
  120.     'png',
  121.     'http://prntscr.com/'
  122.   ]
  123.    if (message.attachments.size <= 0) {
  124.     message.delete();
  125.     message.channel.send(`${message.author}, This Channel For Media ??? Only !`)
  126.     .then(msg => {
  127.       setTimeout(() => {
  128.         msg.delete();
  129.       }, 5000)
  130.   })
  131.   return;
  132. }
  133.    if(message.attachments.size >= 1) {
  134.     let filename = message.attachments.first().filename
  135.     console.log(filename);
  136.     if(!types.some( type => filename.endsWith(type) )) {
  137.       message.delete();
  138.       message.channel.send(`${message.author}, This Channel For Media ??? Only !`)
  139.       .then(msg => {
  140.         setTimeout(() => {
  141.           msg.delete();
  142.         }, 5000)
  143.       })
  144.       .catch(err => {
  145.         console.error(err);
  146.     });
  147.     }
  148.   }
  149.  })
  150. client.on('message', message => {
  151.   if(message.content.startsWith(prefix + "infoMedia")) {
  152. let embed = new Discord.RichEmbed()
  153. .addField('Channel Status', `${pics[message.guild.id].onoff}`)
  154. .addField('Media Channel', `${pics[message.guild.id].channel}`)
  155. .addField('Requested By', `${message.author}`)
  156. .setThumbnail(message.author.avatarURL)
  157. .setFooter(`${client.user.username}`)
  158. message.channel.sendEmbed(embed)
  159.   }})
  160.  
  161.  
  162. let link= JSON.parse(fs.readFileSync('./link.json' , 'utf8'));
  163. client.on('message', message => {
  164.     if(message.content.startsWith(prefix + "settings toggleLink")) {
  165.         if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  166.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  167.         if(!link[message.guild.id]) link[message.guild.id] = {
  168.           onoff: 'Off'
  169.         }
  170.           if(link[message.guild.id].onoff === 'Off') return [message.channel.send(`**? The Invite Link Cmd Is __????__ !**`), link[message.guild.id].onoff = 'On']
  171.           if(link[message.guild.id].onoff === 'On') return [message.channel.send(`**? The Invite Link Cmd Is __??????__ !**`), link[message.guild.id].onoff = 'Off']
  172.           fs.writeFile("./link.json", JSON.stringify(link), (err) => {
  173.             if (err) console.error(err)
  174.             .catch(err => {
  175.               console.error(err);
  176.           });
  177.             });
  178.           }
  179.          
  180.         })
  181.  
  182. const coolDown = new Set();
  183. client.on('message', message => {
  184.  
  185.       if (message.content.startsWith("رابط")) {
  186.                   if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  187.                       if(!link[message.guild.id]) link[message.guild.id] = {
  188.         onoff: 'Off'
  189.             }
  190.         if(link[message.guild.id].onoff === 'Off') return;
  191.         if(coolDown.has(message.author.id)) return message.channel.send(`**:stopwatch: | ${message.author.username}, your invite :yen: link refreshes in \`\`1 Day\`\`.**`);
  192.  
  193.     message.channel.createInvite({
  194.  
  195.           thing: true,
  196.  
  197.           maxUses: 5,  
  198.  
  199.           maxAge: 86400
  200.  
  201.       }).then(invite =>
  202.  
  203.         message.author.sendMessage(invite.url)
  204.  
  205.       )
  206.  
  207.     message.channel.send("**تم ارسال الرابط برسالة خاصة**")   .then(() => {    
  208.       coolDown.add(message.author.id);
  209.   });
  210.  
  211.  
  212.   message.author.send(`**مدة الرابط : يـوم
  213.   عدد استخدامات الرابط : 5**`)
  214.  
  215.       }
  216.  
  217.       setTimeout(() => {
  218.         coolDown.remove(message.author.id);
  219.      },86400000);
  220.      
  221.   });
  222.  
  223.  
  224. let log= JSON.parse(fs.readFileSync('./log.json' , 'utf8'));
  225.  
  226. client.on('message', message => {
  227.            if (!message.channel.guild) return;
  228.  
  229.     let room = message.content.split(" ").slice(1);
  230.     let findroom = message.guild.channels.find('name', `${room}`)
  231.     if(message.content.startsWith(prefix + "setLog")) {
  232.         if(!message.channel.guild) return;
  233.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  234. if(!room) return message.channel.send('Please Type The Channel Name')
  235. if(!findroom) return message.channel.send('Please Type The Log Channel Name')
  236. let embed = new Discord.RichEmbed()
  237. .setTitle('**Done The Log Code Has Been Setup**')
  238. .addField('Channel:', `${room}`)
  239. .addField('Requested By:', `${message.author}`)
  240. .setThumbnail(message.author.avatarURL)
  241. .setFooter(`${client.user.username}`)
  242. message.channel.sendEmbed(embed)
  243. log[message.guild.id] = {
  244. channel: room,
  245. onoff: 'On'
  246. }
  247. fs.writeFile("./log.json", JSON.stringify(log), (err) => {
  248. if (err) console.error(err)
  249. })
  250.     }})
  251.          
  252. client.on('message', message => {
  253.  
  254.     if(message.content.startsWith(prefix + "toggleLog")) {
  255.         if(!message.channel.guild) return;
  256.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  257.         if(!log[message.guild.id]) log[message.guild.id] = {
  258.           onoff: 'Off'
  259.         }
  260.           if(log[message.guild.id].onoff === 'Off') return [message.channel.send(`**The log Is __????__ !**`), log[message.guild.id].onoff = 'On']
  261.           if(log[message.guild.id].onoff === 'On') return [message.channel.send(`**The log Is __??????__ !**`), log[message.guild.id].onoff = 'Off']
  262.           fs.writeFile("./log.json", JSON.stringify(log), (err) => {
  263.             if (err) console.error(err)
  264.             .catch(err => {
  265.               console.error(err);
  266.           });
  267.             });
  268.           }
  269.          
  270.         })
  271.  
  272.  
  273. client.on('messageDelete', message => {
  274.  
  275.     if(message.author.bot) return;
  276.     if(message.channel.type === 'dm') return;
  277.     if(!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  278.     if(!message.guild.member(client.user).hasPermission('MANAGE_MESSAGES')) return;
  279.                         if(!log[message.guild.id]) log[message.guild.id] = {
  280.           onoff: 'Off'
  281.         }
  282.     if(log[message.guild.id].onoff === 'Off') return;
  283.     var logChannel = message.guild.channels.find(c => c.name === `${log[message.guild.id].channel}`);
  284.     if(!logChannel) return;
  285.  
  286.     let messageDelete = new Discord.RichEmbed()
  287.     .setTitle('**[MESSAGE DELETE]**')
  288.     .setColor('RED')
  289.     .setThumbnail(message.author.avatarURL)
  290.     .setDescription(`**\n**:wastebasket: Successfully \`\`DELETE\`\` **MESSAGE** In ${message.channel}\n\n**Channel:** \`\`${message.channel.name}\`\` (ID: ${message.channel.id})\n**Message ID:** ${message.id}\n**Sent By:** <@${message.author.id}> (ID: ${message.author.id})\n**Message:**\n\`\`\`${message}\`\`\``)
  291.     .setTimestamp()
  292.     .setFooter(message.guild.name, message.guild.iconURL)
  293.  
  294.     logChannel.send(messageDelete);
  295. });
  296. client.on('messageUpdate', (oldMessage, newMessage) => {
  297.  
  298.     if(oldMessage.author.bot) return;
  299.     if(!oldMessage.channel.type === 'dm') return;
  300.     if(!oldMessage.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  301.     if(!oldMessage.guild.member(client.user).hasPermission('MANAGE_MESSAGES')) return;
  302.                         if(!log[oldMessage.guild.id]) log[oldMessage.guild.id] = {
  303.           onoff: 'Off'
  304.         }
  305.     if(log[oldMessage.guild.id].onoff === 'Off') return;
  306.     var logChannel = oldMessage.guild.channels.find(c => c.name === `${log[oldMessage.guild.id].channel}`);
  307.     if(!logChannel) return;
  308.  
  309.     if(oldMessage.content.startsWith('https://')) return;
  310.  
  311.     let messageUpdate = new Discord.RichEmbed()
  312.     .setTitle('**[MESSAGE EDIT]**')
  313.     .setThumbnail(oldMessage.author.avatarURL)
  314.     .setColor('BLUE')
  315.     .setDescription(`**\n**:wrench: Successfully \`\`EDIT\`\` **MESSAGE** In ${oldMessage.channel}\n\n**Channel:** \`\`${oldMessage.channel.name}\`\` (ID: ${oldMessage.channel.id})\n**Message ID:** ${oldMessage.id}\n**Sent By:** <@${oldMessage.author.id}> (ID: ${oldMessage.author.id})\n\n**Old Message:**\`\`\`${oldMessage}\`\`\`\n**New Message:**\`\`\`${newMessage}\`\`\``)
  316.     .setTimestamp()
  317.     .setFooter(oldMessage.guild.name, oldMessage.guild.iconURL)
  318.  
  319.     logChannel.send(messageUpdate);
  320. });
  321.  
  322.  
  323. client.on('roleCreate', role => {
  324.  
  325.     if(!role.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  326.     if(!role.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  327.             if(!log[role.guild.id]) log[role.guild.id] = {
  328.           onoff: 'Off'
  329.         }
  330.     if(log[role.guild.id].onoff === 'Off') return;
  331.     var logChannel = role.guild.channels.find(c => c.name === `${log[role.guild.id].channel}`);
  332.     if(!logChannel) return;
  333.  
  334.     role.guild.fetchAuditLogs().then(logs => {
  335.         var userID = logs.entries.first().executor.id;
  336.         var userAvatar = logs.entries.first().executor.avatarURL;
  337.  
  338.         let roleCreate = new Discord.RichEmbed()
  339.         .setTitle('**[ROLE CREATE]**')
  340.         .setThumbnail(userAvatar)
  341.         .setDescription(`**\n**:white_check_mark: Successfully \`\`CREATE\`\` Role.\n\n**Role Name:** \`\`${role.name}\`\` (ID: ${role.id})\n**By:** <@${userID}> (ID: ${userID})`)
  342.         .setColor('GREEN')
  343.         .setTimestamp()
  344.         .setFooter(role.guild.name, role.guild.iconURL)
  345.  
  346.         logChannel.send(roleCreate);
  347.     })
  348. });
  349. client.on('roleDelete', role => {
  350.  
  351.     if(!role.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  352.     if(!role.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  353.             if(!log[role.guild.id]) log[role.guild.id] = {
  354.           onoff: 'Off'
  355.         }
  356.     if(log[role.guild.id].onoff === 'Off') return;
  357.     var logChannel = role.guild.channels.find(c => c.name === `${log[role.guild.id].channel}`);
  358.     if(!logChannel) return;
  359.  
  360.     role.guild.fetchAuditLogs().then(logs => {
  361.         var userID = logs.entries.first().executor.id;
  362.         var userAvatar = logs.entries.first().executor.avatarURL;
  363.  
  364.         let roleDelete = new Discord.RichEmbed()
  365.         .setTitle('**[ROLE DELETE]**')
  366.         .setThumbnail(userAvatar)
  367.         .setDescription(`**\n**:white_check_mark: Successfully \`\`DELETE\`\` Role.\n\n**Role Name:** \`\`${role.name}\`\` (ID: ${role.id})\n**By:** <@${userID}> (ID: ${userID})`)
  368.         .setColor('RED')
  369.         .setTimestamp()
  370.         .setFooter(role.guild.name, role.guild.iconURL)
  371.  
  372.         logChannel.send(roleDelete);
  373.     })
  374. });
  375. client.on('roleUpdate', (oldRole, newRole) => {
  376.  
  377.     if(!oldRole.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  378.     if(!oldRole.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  379.             if(!log[oldRole.guild.id]) log[oldRole.guild.id] = {
  380.           onoff: 'Off'
  381.             }
  382.     if(log[oldRole.guild.id].onoff === 'Off') return;
  383.     var logChannel = oldRole.guild.channels.find(c => c.name === `${log[oldRole.guild.id].channel}`);
  384.     if(!logChannel) return;
  385.  
  386.     oldRole.guild.fetchAuditLogs().then(logs => {
  387.         var userID = logs.entries.first().executor.id;
  388.         var userAvatar = logs.entries.first().executor.avatarURL;
  389.  
  390.         if(oldRole.name !== newRole.name) {
  391.             if(log[oldRole.guild.id].onoff === 'Off') return;
  392.             let roleUpdateName = new Discord.RichEmbed()
  393.             .setTitle('**[ROLE NAME UPDATE]**')
  394.             .setThumbnail(userAvatar)
  395.             .setColor('BLUE')
  396.             .setDescription(`**\n**:white_check_mark: Successfully \`\`EDITED\`\` Role Name.\n\n**Old Name:** \`\`${oldRole.name}\`\`\n**New Name:** \`\`${newRole.name}\`\`\n**Role ID:** ${oldRole.id}\n**By:** <@${userID}> (ID: ${userID})`)
  397.             .setTimestamp()
  398.             .setFooter(oldRole.guild.name, oldRole.guild.iconURL)
  399.  
  400.             logChannel.send(roleUpdateName);
  401.         }
  402.         if(oldRole.hexColor !== newRole.hexColor) {
  403.             if(oldRole.hexColor === '#000000') {
  404.                 var oldColor = '`Default`';
  405.             }else {
  406.                 var oldColor = oldRole.hexColor;
  407.             }
  408.             if(newRole.hexColor === '#000000') {
  409.                 var newColor = '`Default`';
  410.             }else {
  411.                 var newColor = newRole.hexColor;
  412.             }
  413.             if(log[oldRole.guild.id].onoff === 'Off') return;
  414.             let roleUpdateColor = new Discord.RichEmbed()
  415.             .setTitle('**[ROLE COLOR UPDATE]**')
  416.             .setThumbnail(userAvatar)
  417.             .setColor('BLUE')
  418.             .setDescription(`**\n**:white_check_mark: Successfully \`\`EDITED\`\` **${oldRole.name}** Role Color.\n\n**Old Color:** ${oldColor}\n**New Color:** ${newColor}\n**Role ID:** ${oldRole.id}\n**By:** <@${userID}> (ID: ${userID})`)
  419.             .setTimestamp()
  420.             .setFooter(oldRole.guild.name, oldRole.guild.iconURL)
  421.  
  422.             logChannel.send(roleUpdateColor);
  423.         }
  424.     })
  425. });
  426.  
  427. client.on('channelCreate', channel => {
  428.  
  429.     if(!channel.guild) return;
  430.     if(!channel.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  431.     if(!channel.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  432.             if(!log[channel.guild.id]) log[channel.guild.id] = {
  433.           onoff: 'Off'
  434.         }
  435.     if(log[channel.guild.id].onoff === 'Off') return;
  436.     var logChannel = channel.guild.channels.find(c => c.name === `${log[channel.guild.id].channel}`);
  437.     if(!logChannel) return;
  438.  
  439.     if(channel.type === 'text') {
  440.         var roomType = 'Text';
  441.     }else
  442.     if(channel.type === 'voice') {
  443.         var roomType = 'Voice';
  444.     }else
  445.     if(channel.type === 'category') {
  446.         var roomType = 'Category';
  447.     }
  448.  
  449.     channel.guild.fetchAuditLogs().then(logs => {
  450.         var userID = logs.entries.first().executor.id;
  451.         var userAvatar = logs.entries.first().executor.avatarURL;
  452.  
  453.         let channelCreate = new Discord.RichEmbed()
  454.         .setTitle('**[CHANNEL CREATE]**')
  455.         .setThumbnail(userAvatar)
  456.         .setDescription(`**\n**:white_check_mark: Successfully \`\`CREATE\`\` **${roomType}** channel.\n\n**Channel Name:** \`\`${channel.name}\`\` (ID: ${channel.id})\n**By:** <@${userID}> (ID: ${userID})`)
  457.         .setColor('GREEN')
  458.         .setTimestamp()
  459.         .setFooter(channel.guild.name, channel.guild.iconURL)
  460.  
  461.         logChannel.send(channelCreate);
  462.     })
  463. });
  464. client.on('channelDelete', channel => {
  465.     if(!channel.guild) return;
  466.     if(!channel.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  467.     if(!channel.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  468.             if(!log[channel.guild.id]) log[channel.guild.id] = {
  469.           onoff: 'Off'
  470.         }
  471.     if(log[channel.guild.id].onoff === 'Off') return;
  472.     var logChannel = channel.guild.channels.find(c => c.name === `${log[channel.guild.id].channel}`);
  473.     if(!logChannel) return;
  474.  
  475.     if(channel.type === 'text') {
  476.         var roomType = 'Text';
  477.     }else
  478.     if(channel.type === 'voice') {
  479.         var roomType = 'Voice';
  480.     }else
  481.     if(channel.type === 'category') {
  482.         var roomType = 'Category';
  483.     }
  484.  
  485.     channel.guild.fetchAuditLogs().then(logs => {
  486.         var userID = logs.entries.first().executor.id;
  487.         var userAvatar = logs.entries.first().executor.avatarURL;
  488.  
  489.         let channelDelete = new Discord.RichEmbed()
  490.         .setTitle('**[CHANNEL DELETE]**')
  491.         .setThumbnail(userAvatar)
  492.         .setDescription(`**\n**:white_check_mark: Successfully \`\`DELETE\`\` **${roomType}** channel.\n\n**Channel Name:** \`\`${channel.name}\`\` (ID: ${channel.id})\n**By:** <@${userID}> (ID: ${userID})`)
  493.         .setColor('RED')
  494.         .setTimestamp()
  495.         .setFooter(channel.guild.name, channel.guild.iconURL)
  496.  
  497.         logChannel.send(channelDelete);
  498.     })
  499. });
  500. client.on('channelUpdate', (oldChannel, newChannel) => {
  501.     if(!oldChannel.guild) return;
  502.             if(!log[oldChannel.guild.id]) log[oldChannel.guild.id] = {
  503.           onoff: 'Off'
  504.         }
  505.     if(log[oldChannel.guild.id].onoff === 'Off') return;
  506.     var logChannel = oldChannel.guild.channels.find(c => c.name === `${log[oldChannel.guild.id].channel}`);
  507.     if(!logChannel) return;
  508.  
  509.     if(oldChannel.type === 'text') {
  510.         var channelType = 'Text';
  511.     }else
  512.     if(oldChannel.type === 'voice') {
  513.         var channelType = 'Voice';
  514.     }else
  515.     if(oldChannel.type === 'category') {
  516.         var channelType = 'Category';
  517.     }
  518.  
  519.     oldChannel.guild.fetchAuditLogs().then(logs => {
  520.         var userID = logs.entries.first().executor.id;
  521.         var userAvatar = logs.entries.first().executor.avatarURL;
  522.  
  523.         if(oldChannel.name !== newChannel.name) {
  524.             let newName = new Discord.RichEmbed()
  525.             .setTitle('**[CHANNEL EDIT]**')
  526.             .setThumbnail(userAvatar)
  527.             .setColor('BLUE')
  528.             .setDescription(`**\n**:wrench: Successfully Edited **${channelType}** Channel Name\n\n**Old Name:** \`\`${oldChannel.name}\`\`\n**New Name:** \`\`${newChannel.name}\`\`\n**Channel ID:** ${oldChannel.id}\n**By:** <@${userID}> (ID: ${userID})`)
  529.             .setTimestamp()
  530.             .setFooter(oldChannel.guild.name, oldChannel.guild.iconURL)
  531.  
  532.             logChannel.send(newName);
  533.         }
  534.         if(oldChannel.topic !== newChannel.topic) {
  535.             if(log[oldChannel.guild.id].onoff === 'Off') return;
  536.             let newTopic = new Discord.RichEmbed()
  537.             .setTitle('**[CHANNEL EDIT]**')
  538.             .setThumbnail(userAvatar)
  539.             .setColor('BLUE')
  540.             .setDescription(`**\n**:wrench: Successfully Edited **${channelType}** Channel Topic\n\n**Old Topic:**\n\`\`\`${oldChannel.topic || 'NULL'}\`\`\`\n**New Topic:**\n\`\`\`${newChannel.topic || 'NULL'}\`\`\`\n**Channel:** ${oldChannel} (ID: ${oldChannel.id})\n**By:** <@${userID}> (ID: ${userID})`)
  541.             .setTimestamp()
  542.             .setFooter(oldChannel.guild.name, oldChannel.guild.iconURL)
  543.  
  544.             logChannel.send(newTopic);
  545.         }
  546.     })
  547. });
  548.  
  549.  
  550. client.on('guildBanAdd', (guild, user) => {
  551.  
  552.     if(!guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  553.     if(!guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  554.             if(!log[user.guild.id]) log[guild.guild.id] = {
  555.           onoff: 'Off'
  556.         }
  557.     if(log[user.guild.id].onoff === 'Off') return;
  558.     var logChannel = guild.channels.find(c => c.name === `${log[guild.guild.id].channel}`);
  559.     if(!logChannel) return;
  560.  
  561.     guild.fetchAuditLogs().then(logs => {
  562.         var userID = logs.entries.first().executor.id;
  563.         var userAvatar = logs.entries.first().executor.avatarURL;
  564.  
  565.         if(userID === client.user.id) return;
  566.  
  567.         let banInfo = new Discord.RichEmbed()
  568.         .setTitle('**[BANNED]**')
  569.         .setThumbnail(userAvatar)
  570.         .setColor('DARK_RED')
  571.         .setDescription(`**\n**:airplane: Successfully \`\`BANNED\`\` **${user.username}** From the server!\n\n**User:** <@${user.id}> (ID: ${user.id})\n**By:** <@${userID}> (ID: ${userID})`)
  572.         .setTimestamp()
  573.         .setFooter(guild.name, guild.iconURL)
  574.  
  575.         logChannel.send(banInfo);
  576.     })
  577. });
  578. client.on('guildBanRemove', (guild, user) => {
  579.     if(!guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  580.     if(!guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  581.             if(!log[guild.guild.id]) log[guild.guild.id] = {
  582.           onoff: 'Off'
  583.         }
  584.     if(log[guild.guild.id].onoff === 'Off') return;
  585.     var logChannel = guild.channels.find(c => c.name === `${log[guild.guild.id].channel}`);
  586.     if(!logChannel) return;
  587.  
  588.     guild.fetchAuditLogs().then(logs => {
  589.         var userID = logs.entries.first().executor.id;
  590.         var userAvatar = logs.entries.first().executor.avatarURL;
  591.  
  592.         if(userID === client.user.id) return;
  593.  
  594.         let unBanInfo = new Discord.RichEmbed()
  595.         .setTitle('**[UNBANNED]**')
  596.         .setThumbnail(userAvatar)
  597.         .setColor('GREEN')
  598.         .setDescription(`**\n**:unlock: Successfully \`\`UNBANNED\`\` **${user.username}** From the server\n\n**User:** <@${user.id}> (ID: ${user.id})\n**By:** <@${userID}> (ID: ${userID})`)
  599.         .setTimestamp()
  600.         .setFooter(guild.name, guild.iconURL)
  601.  
  602.         logChannel.send(unBanInfo);
  603.     })
  604. });
  605.  
  606. client.on('guildMemberUpdate', (oldMember, newMember) => {
  607.     if(!oldMember.guild) return;
  608.                 if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  609.           onoff: 'Off'
  610.         }
  611.     if(log[oldMember.guild.id].onoff === 'Off') return;
  612.     var logChannel = oldMember.guild.channels.find(c => c.name === `${log[oldMember, newMember.guild.id].channel}`);
  613.     if(!logChannel) return;
  614.  
  615.     oldMember.guild.fetchAuditLogs().then(logs => {
  616.         var userID = logs.entries.first().executor.id;
  617.         var userAvatar = logs.entries.first().executor.avatarURL;
  618.         var userTag = logs.entries.first().executor.tag;
  619.  
  620.         if(oldMember.nickname !== newMember.nickname) {
  621.             if(oldMember.nickname === null) {
  622.                 var oldNM = '`His Orginal Name`';
  623.             }else {
  624.                 var oldNM = oldMember.nickname;
  625.             }
  626.             if(newMember.nickname === null) {
  627.                 var newNM = '`His Orginal Name`';
  628.             }else {
  629.                 var newNM = newMember.nickname;
  630.             }
  631.  
  632.             let updateNickname = new Discord.RichEmbed()
  633.             .setTitle('**[UPDATE MEMBER NICKNAME]**')
  634.             .setThumbnail(userAvatar)
  635.             .setColor('BLUE')
  636.             .setDescription(`**\n**:spy: Successfully \`\`CHANGE\`\` Member Nickname.\n\n**User:** ${oldMember} (ID: ${oldMember.id})\n**Old Nickname:** ${oldNM}\n**New Nickname:** ${newNM}\n**By:** <@${userID}> (ID: ${userID})`)
  637.             .setTimestamp()
  638.             .setFooter(oldMember.guild.name, oldMember.guild.iconURL)
  639.  
  640.             logChannel.send(updateNickname);
  641.         }
  642.         if(oldMember.roles.size < newMember.roles.size) {
  643.             let role = newMember.roles.filter(r => !oldMember.roles.has(r.id)).first();
  644.                             if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  645.           onoff: 'Off'
  646.         }
  647.             if(log[oldMember.guild.id].onoff === 'Off') return;
  648.             let roleAdded = new Discord.RichEmbed()
  649.             .setTitle('**[ADDED ROLE TO MEMBER]**')
  650.             .setThumbnail(oldMember.guild.iconURL)
  651.             .setColor('GREEN')
  652.             .setDescription(`**\n**:white_check_mark: Successfully \`\`ADDED\`\` Role to **${oldMember.user.username}**\n\n**User:** <@${oldMember.id}> (ID: ${oldMember.user.id})\n**Role:** \`\`${role.name}\`\` (ID: ${role.id})\n**By:** <@${userID}> (ID: ${userID})`)
  653.             .setTimestamp()
  654.             .setFooter(userTag, userAvatar)
  655.  
  656.             logChannel.send(roleAdded);
  657.         }
  658.         if(oldMember.roles.size > newMember.roles.size) {
  659.             let role = oldMember.roles.filter(r => !newMember.roles.has(r.id)).first();
  660.                             if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  661.           onoff: 'Off'
  662.         }
  663.             if(log[oldMember, newMember.guild.id].onoff === 'Off') return;
  664.             let roleRemoved = new Discord.RichEmbed()
  665.             .setTitle('**[REMOVED ROLE FROM MEMBER]**')
  666.             .setThumbnail(oldMember.guild.iconURL)
  667.             .setColor('RED')
  668.             .setDescription(`**\n**:negative_squared_cross_mark: Successfully \`\`REMOVED\`\` Role from **${oldMember.user.username}**\n\n**User:** <@${oldMember.user.id}> (ID: ${oldMember.id})\n**Role:** \`\`${role.name}\`\` (ID: ${role.id})\n**By:** <@${userID}> (ID: ${userID})`)
  669.             .setTimestamp()
  670.             .setFooter(userTag, userAvatar)
  671.  
  672.             logChannel.send(roleRemoved);
  673.         }
  674.     })
  675.     if(oldMember.guild.owner.id !== newMember.guild.owner.id) {
  676.                     if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  677.           onoff: 'Off'
  678.         }
  679.         if(log[oldMember, newMember.guild.id].onoff === 'Off') return;
  680.         let newOwner = new Discord.RichEmbed()
  681.         .setTitle('**[UPDATE GUILD OWNER]**')
  682.         .setThumbnail(oldMember.guild.iconURL)
  683.         .setColor('GREEN')
  684.         .setDescription(`**\n**:white_check_mark: Successfully \`\`TRANSFER\`\` The Owner Ship.\n\n**Old Owner:** <@${oldMember.user.id}> (ID: ${oldMember.user.id})\n**New Owner:** <@${newMember.user.id}> (ID: ${newMember.user.id})`)
  685.         .setTimestamp()
  686.         .setFooter(oldMember.guild.name, oldMember.guild.iconURL)
  687.  
  688.         logChannel.send(newOwner);
  689.     }
  690. });
  691.  
  692.  
  693. client.on('voiceStateUpdate', (voiceOld, voiceNew) => {
  694.  
  695.     if(!voiceOld.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  696.     if(!voiceOld.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  697.                     if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  698.           onoff: 'Off'
  699.         }
  700.     if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  701.     var logChannel = voiceOld.guild.channels.find(c => c.name === `${log[voiceOld, voiceNew.guild.id].channel}`);
  702.     if(!logChannel) return;
  703.  
  704.     voiceOld.guild.fetchAuditLogs().then(logs => {
  705.         var userID = logs.entries.first().executor.id;
  706.         var userTag = logs.entries.first().executor.tag;
  707.         var userAvatar = logs.entries.first().executor.avatarURL;
  708.  
  709.         if(voiceOld.serverMute === false && voiceNew.serverMute === true) {
  710.             let serverMutev = new Discord.RichEmbed()
  711.             .setTitle('**[VOICE MUTE]**')
  712.             .setThumbnail('https://images-ext-1.discordapp.net/external/pWQaw076OHwVIFZyeFoLXvweo0T_fDz6U5C9RBlw_fQ/https/cdn.pg.sa/UosmjqDNgS.png')
  713.             .setColor('RED')
  714.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  715.             .setTimestamp()
  716.             .setFooter(userTag, userAvatar)
  717.  
  718.             logChannel.send(serverMutev);
  719.         }
  720.         if(voiceOld.serverMute === true && voiceNew.serverMute === false) {
  721.                             if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  722.           onoff: 'Off'
  723.         }
  724.             if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  725.             let serverUnmutev = new Discord.RichEmbed()
  726.             .setTitle('**[VOICE UNMUTE]**')
  727.             .setThumbnail('https://images-ext-1.discordapp.net/external/u2JNOTOc1IVJGEb1uCKRdQHXIj5-r8aHa3tSap6SjqM/https/cdn.pg.sa/Iy4t8H4T7n.png')
  728.             .setColor('GREEN')
  729.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  730.             .setTimestamp()
  731.             .setFooter(userTag, userAvatar)
  732.  
  733.             logChannel.send(serverUnmutev);
  734.         }
  735.         if(voiceOld.serverDeaf === false && voiceNew.serverDeaf === true) {
  736.                             if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  737.           onoff: 'Off'
  738.         }
  739.             if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  740.             let serverDeafv = new Discord.RichEmbed()
  741.             .setTitle('**[VOICE DEAF]**')
  742.             .setThumbnail('https://images-ext-1.discordapp.net/external/7ENt2ldbD-3L3wRoDBhKHb9FfImkjFxYR6DbLYRjhjA/https/cdn.pg.sa/auWd5b95AV.png')
  743.             .setColor('RED')
  744.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  745.             .setTimestamp()
  746.             .setFooter(userTag, userAvatar)
  747.  
  748.             logChannel.send(serverDeafv);
  749.         }
  750.         if(voiceOld.serverDeaf === true && voiceNew.serverDeaf === false) {
  751.                             if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  752.           onoff: 'Off'
  753.         }
  754.             if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  755.             let serverUndeafv = new Discord.RichEmbed()
  756.             .setTitle('**[VOICE UNDEAF]**')
  757.             .setThumbnail('https://images-ext-2.discordapp.net/external/s_abcfAlNdxl3uYVXnA2evSKBTpU6Ou3oimkejx3fiQ/https/cdn.pg.sa/i7fC8qnbRF.png')
  758.             .setColor('GREEN')
  759.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  760.             .setTimestamp()
  761.             .setFooter(userTag, userAvatar)
  762.  
  763.             logChannel.send(serverUndeafv);
  764.         }
  765.     })
  766.    
  767.     if(voiceOld.voiceChannelID !== voiceNew.voiceChannelID && voiceNew.voiceChannel && voiceOld.voiceChannel != null) {
  768.                         if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  769.           onoff: 'Off'
  770.         }
  771.         if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  772.         let voiceLeave = new Discord.RichEmbed()
  773.         .setTitle('**[CHANGED VOICE ROOM]**')
  774.         .setColor('GREEN')
  775.         .setThumbnail(voiceOld.user.avatarURL)
  776.         .setDescription(`**\n**:repeat: Successfully \`\`CHANGED\`\` The Voice Channel.\n\n**From:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannelID})\n**To:** \`\`${voiceNew.voiceChannel.name}\`\` (ID: ${voiceNew.voiceChannelID})\n**User:** ${voiceOld} (ID: ${voiceOld.id})`)
  777.         .setTimestamp()
  778.         .setFooter(voiceOld.user.tag, voiceOld.user.avatarURL)
  779.  
  780.         logChannel.send(voiceLeave);
  781.     }
  782. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement