Advertisement
Rashwan-

Untitled

Mar 23rd, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const log = JSON.parse(fs.readFileSync('./log.json' , 'utf8'));
  2.  
  3. client.on('message', message => {
  4.            if (!message.channel.guild) return;
  5.  
  6.     let room = message.content.split(" ").slice(1);
  7.     let findroom = message.guild.channels.find('name', `${room}`)
  8.     if(message.content.startsWith(prefix + "setLog")) {
  9.         if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  10.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  11. if(!room) return message.channel.send('Please Type The Channel Name')
  12. if(!findroom) return message.channel.send('Please Type The Log Channel Name')
  13. let embed = new Discord.RichEmbed()
  14. .setTitle('**Done The Log Code Has Been Setup**')
  15. .addField('Channel:', `${room}`)
  16. .addField('Requested By:', `${message.author}`)
  17. .setThumbnail(message.author.avatarURL)
  18. .setFooter(`${client.user.username}`)
  19. message.channel.sendEmbed(embed)
  20. log[message.guild.id] = {
  21. channel: room,
  22. onoff: 'On'
  23. }
  24. fs.writeFile("./log.json", JSON.stringify(log), (err) => {
  25. if (err) console.error(err)
  26. })
  27.     }})
  28.          
  29. client.on('message', message => {
  30.  
  31.     if(message.content.startsWith(prefix + "toggleLog")) {
  32.         if(!message.channel.guild) return message.reply('**This Command Only For Servers**');
  33.         if(!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('**Sorry But You Dont Have Permission** `MANAGE_GUILD`' );
  34.         if(!log[message.guild.id]) log[message.guild.id] = {
  35.           onoff: 'Off'
  36.         }
  37.           if(log[message.guild.id].onoff === 'Off') return [message.channel.send(`**The log Is __𝐎𝐍__ !**`), log[message.guild.id].onoff = 'On']
  38.           if(log[message.guild.id].onoff === 'On') return [message.channel.send(`**The log Is __𝐎𝐅𝐅__ !**`), log[message.guild.id].onoff = 'Off']
  39.           fs.writeFile("./log.json", JSON.stringify(log), (err) => {
  40.             if (err) console.error(err)
  41.             .catch(err => {
  42.               console.error(err);
  43.           });
  44.             });
  45.           }
  46.          
  47.         })
  48.  
  49.  
  50. client.on('messageDelete', message => {
  51.  
  52.     if(message.author.bot) return;
  53.     if(message.channel.type === 'dm') return;
  54.     if(!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  55.     if(!message.guild.member(client.user).hasPermission('MANAGE_MESSAGES')) return;
  56.                         if(!log[message.guild.id]) log[message.guild.id] = {
  57.           onoff: 'Off'
  58.         }
  59.     if(log[message.guild.id].onoff === 'Off') return;
  60.     var logChannel = message.guild.channels.find(c => c.name === `${log[message.guild.id].channel}`);
  61.     if(!logChannel) return;
  62.  
  63.     let messageDelete = new Discord.RichEmbed()
  64.     .setTitle('**[MESSAGE DELETE]**')
  65.     .setColor('RED')
  66.     .setThumbnail(message.author.avatarURL)
  67.     .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}\`\`\``)
  68.     .setTimestamp()
  69.     .setFooter(message.guild.name, message.guild.iconURL)
  70.  
  71.     logChannel.send(messageDelete);
  72. });
  73. client.on('messageUpdate', (oldMessage, newMessage) => {
  74.  
  75.     if(oldMessage.author.bot) return;
  76.     if(!oldMessage.channel.type === 'dm') return;
  77.     if(!oldMessage.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  78.     if(!oldMessage.guild.member(client.user).hasPermission('MANAGE_MESSAGES')) return;
  79.                         if(!log[oldMessage.guild.id]) log[oldMessage.guild.id] = {
  80.           onoff: 'Off'
  81.         }
  82.     if(log[oldMessage.guild.id].onoff === 'Off') return;
  83.     var logChannel = oldMessage.guild.channels.find(c => c.name === `${log[oldMessage.guild.id].channel}`);
  84.     if(!logChannel) return;
  85.  
  86.     if(oldMessage.content.startsWith('https://')) return;
  87.  
  88.     let messageUpdate = new Discord.RichEmbed()
  89.     .setTitle('**[MESSAGE EDIT]**')
  90.     .setThumbnail(oldMessage.author.avatarURL)
  91.     .setColor('BLUE')
  92.     .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}\`\`\``)
  93.     .setTimestamp()
  94.     .setFooter(oldMessage.guild.name, oldMessage.guild.iconURL)
  95.  
  96.     logChannel.send(messageUpdate);
  97. });
  98.  
  99.  
  100. client.on('roleCreate', role => {
  101.  
  102.     if(!role.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  103.     if(!role.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  104.             if(!log[role.guild.id]) log[role.guild.id] = {
  105.           onoff: 'Off'
  106.         }
  107.     if(log[role.guild.id].onoff === 'Off') return;
  108.     var logChannel = role.guild.channels.find(c => c.name === `${log[role.guild.id].channel}`);
  109.     if(!logChannel) return;
  110.  
  111.     role.guild.fetchAuditLogs().then(logs => {
  112.         var userID = logs.entries.first().executor.id;
  113.         var userAvatar = logs.entries.first().executor.avatarURL;
  114.  
  115.         let roleCreate = new Discord.RichEmbed()
  116.         .setTitle('**[ROLE CREATE]**')
  117.         .setThumbnail(userAvatar)
  118.         .setDescription(`**\n**:white_check_mark: Successfully \`\`CREATE\`\` Role.\n\n**Role Name:** \`\`${role.name}\`\` (ID: ${role.id})\n**By:** <@${userID}> (ID: ${userID})`)
  119.         .setColor('GREEN')
  120.         .setTimestamp()
  121.         .setFooter(role.guild.name, role.guild.iconURL)
  122.  
  123.         logChannel.send(roleCreate);
  124.     })
  125. });
  126. client.on('roleDelete', role => {
  127.  
  128.     if(!role.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  129.     if(!role.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  130.             if(!log[role.guild.id]) log[role.guild.id] = {
  131.           onoff: 'Off'
  132.         }
  133.     if(log[role.guild.id].onoff === 'Off') return;
  134.     var logChannel = role.guild.channels.find(c => c.name === `${log[role.guild.id].channel}`);
  135.     if(!logChannel) return;
  136.  
  137.     role.guild.fetchAuditLogs().then(logs => {
  138.         var userID = logs.entries.first().executor.id;
  139.         var userAvatar = logs.entries.first().executor.avatarURL;
  140.  
  141.         let roleDelete = new Discord.RichEmbed()
  142.         .setTitle('**[ROLE DELETE]**')
  143.         .setThumbnail(userAvatar)
  144.         .setDescription(`**\n**:white_check_mark: Successfully \`\`DELETE\`\` Role.\n\n**Role Name:** \`\`${role.name}\`\` (ID: ${role.id})\n**By:** <@${userID}> (ID: ${userID})`)
  145.         .setColor('RED')
  146.         .setTimestamp()
  147.         .setFooter(role.guild.name, role.guild.iconURL)
  148.  
  149.         logChannel.send(roleDelete);
  150.     })
  151. });
  152. client.on('roleUpdate', (oldRole, newRole) => {
  153.  
  154.     if(!oldRole.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  155.     if(!oldRole.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  156.             if(!log[oldRole.guild.id]) log[oldRole.guild.id] = {
  157.           onoff: 'Off'
  158.             }
  159.     if(log[oldRole.guild.id].onoff === 'Off') return;
  160.     var logChannel = oldRole.guild.channels.find(c => c.name === `${log[oldRole.guild.id].channel}`);
  161.     if(!logChannel) return;
  162.  
  163.     oldRole.guild.fetchAuditLogs().then(logs => {
  164.         var userID = logs.entries.first().executor.id;
  165.         var userAvatar = logs.entries.first().executor.avatarURL;
  166.  
  167.         if(oldRole.name !== newRole.name) {
  168.             if(log[oldRole.guild.id].onoff === 'Off') return;
  169.             let roleUpdateName = new Discord.RichEmbed()
  170.             .setTitle('**[ROLE NAME UPDATE]**')
  171.             .setThumbnail(userAvatar)
  172.             .setColor('BLUE')
  173.             .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})`)
  174.             .setTimestamp()
  175.             .setFooter(oldRole.guild.name, oldRole.guild.iconURL)
  176.  
  177.             logChannel.send(roleUpdateName);
  178.         }
  179.         if(oldRole.hexColor !== newRole.hexColor) {
  180.             if(oldRole.hexColor === '#000000') {
  181.                 var oldColor = '`Default`';
  182.             }else {
  183.                 var oldColor = oldRole.hexColor;
  184.             }
  185.             if(newRole.hexColor === '#000000') {
  186.                 var newColor = '`Default`';
  187.             }else {
  188.                 var newColor = newRole.hexColor;
  189.             }
  190.             if(log[oldRole.guild.id].onoff === 'Off') return;
  191.             let roleUpdateColor = new Discord.RichEmbed()
  192.             .setTitle('**[ROLE COLOR UPDATE]**')
  193.             .setThumbnail(userAvatar)
  194.             .setColor('BLUE')
  195.             .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})`)
  196.             .setTimestamp()
  197.             .setFooter(oldRole.guild.name, oldRole.guild.iconURL)
  198.  
  199.             logChannel.send(roleUpdateColor);
  200.         }
  201.     })
  202. });
  203.  
  204. client.on('channelCreate', channel => {
  205.  
  206.     if(!channel.guild) return;
  207.     if(!channel.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  208.     if(!channel.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  209.             if(!log[channel.guild.id]) log[channel.guild.id] = {
  210.           onoff: 'Off'
  211.         }
  212.     if(log[channel.guild.id].onoff === 'Off') return;
  213.     var logChannel = channel.guild.channels.find(c => c.name === `${log[channel.guild.id].channel}`);
  214.     if(!logChannel) return;
  215.  
  216.     if(channel.type === 'text') {
  217.         var roomType = 'Text';
  218.     }else
  219.     if(channel.type === 'voice') {
  220.         var roomType = 'Voice';
  221.     }else
  222.     if(channel.type === 'category') {
  223.         var roomType = 'Category';
  224.     }
  225.  
  226.     channel.guild.fetchAuditLogs().then(logs => {
  227.         var userID = logs.entries.first().executor.id;
  228.         var userAvatar = logs.entries.first().executor.avatarURL;
  229.  
  230.         let channelCreate = new Discord.RichEmbed()
  231.         .setTitle('**[CHANNEL CREATE]**')
  232.         .setThumbnail(userAvatar)
  233.         .setDescription(`**\n**:white_check_mark: Successfully \`\`CREATE\`\` **${roomType}** channel.\n\n**Channel Name:** \`\`${channel.name}\`\` (ID: ${channel.id})\n**By:** <@${userID}> (ID: ${userID})`)
  234.         .setColor('GREEN')
  235.         .setTimestamp()
  236.         .setFooter(channel.guild.name, channel.guild.iconURL)
  237.  
  238.         logChannel.send(channelCreate);
  239.     })
  240. });
  241. client.on('channelDelete', channel => {
  242.     if(!channel.guild) return;
  243.     if(!channel.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  244.     if(!channel.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  245.             if(!log[channel.guild.id]) log[channel.guild.id] = {
  246.           onoff: 'Off'
  247.         }
  248.     if(log[channel.guild.id].onoff === 'Off') return;
  249.     var logChannel = channel.guild.channels.find(c => c.name === `${log[channel.guild.id].channel}`);
  250.     if(!logChannel) return;
  251.  
  252.     if(channel.type === 'text') {
  253.         var roomType = 'Text';
  254.     }else
  255.     if(channel.type === 'voice') {
  256.         var roomType = 'Voice';
  257.     }else
  258.     if(channel.type === 'category') {
  259.         var roomType = 'Category';
  260.     }
  261.  
  262.     channel.guild.fetchAuditLogs().then(logs => {
  263.         var userID = logs.entries.first().executor.id;
  264.         var userAvatar = logs.entries.first().executor.avatarURL;
  265.  
  266.         let channelDelete = new Discord.RichEmbed()
  267.         .setTitle('**[CHANNEL DELETE]**')
  268.         .setThumbnail(userAvatar)
  269.         .setDescription(`**\n**:white_check_mark: Successfully \`\`DELETE\`\` **${roomType}** channel.\n\n**Channel Name:** \`\`${channel.name}\`\` (ID: ${channel.id})\n**By:** <@${userID}> (ID: ${userID})`)
  270.         .setColor('RED')
  271.         .setTimestamp()
  272.         .setFooter(channel.guild.name, channel.guild.iconURL)
  273.  
  274.         logChannel.send(channelDelete);
  275.     })
  276. });
  277. client.on('channelUpdate', (oldChannel, newChannel) => {
  278.     if(!oldChannel.guild) return;
  279.             if(!log[oldChannel.guild.id]) log[oldChannel.guild.id] = {
  280.           onoff: 'Off'
  281.         }
  282.     if(log[oldChannel.guild.id].onoff === 'Off') return;
  283.     var logChannel = oldChannel.guild.channels.find(c => c.name === `${log[oldChannel.guild.id].channel}`);
  284.     if(!logChannel) return;
  285.  
  286.     if(oldChannel.type === 'text') {
  287.         var channelType = 'Text';
  288.     }else
  289.     if(oldChannel.type === 'voice') {
  290.         var channelType = 'Voice';
  291.     }else
  292.     if(oldChannel.type === 'category') {
  293.         var channelType = 'Category';
  294.     }
  295.  
  296.     oldChannel.guild.fetchAuditLogs().then(logs => {
  297.         var userID = logs.entries.first().executor.id;
  298.         var userAvatar = logs.entries.first().executor.avatarURL;
  299.  
  300.         if(oldChannel.name !== newChannel.name) {
  301.             let newName = new Discord.RichEmbed()
  302.             .setTitle('**[CHANNEL EDIT]**')
  303.             .setThumbnail(userAvatar)
  304.             .setColor('BLUE')
  305.             .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})`)
  306.             .setTimestamp()
  307.             .setFooter(oldChannel.guild.name, oldChannel.guild.iconURL)
  308.  
  309.             logChannel.send(newName);
  310.         }
  311.         if(oldChannel.topic !== newChannel.topic) {
  312.             if(log[oldChannel.guild.id].onoff === 'Off') return;
  313.             let newTopic = new Discord.RichEmbed()
  314.             .setTitle('**[CHANNEL EDIT]**')
  315.             .setThumbnail(userAvatar)
  316.             .setColor('BLUE')
  317.             .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})`)
  318.             .setTimestamp()
  319.             .setFooter(oldChannel.guild.name, oldChannel.guild.iconURL)
  320.  
  321.             logChannel.send(newTopic);
  322.         }
  323.     })
  324. });
  325.  
  326.  
  327. client.on('guildBanAdd', (guild, user) => {
  328.  
  329.     if(!guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  330.     if(!guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  331.             if(!log[user.guild.id]) log[guild.guild.id] = {
  332.           onoff: 'Off'
  333.         }
  334.     if(log[user.guild.id].onoff === 'Off') return;
  335.     var logChannel = guild.channels.find(c => c.name === `${log[guild.guild.id].channel}`);
  336.     if(!logChannel) return;
  337.  
  338.     guild.fetchAuditLogs().then(logs => {
  339.         var userID = logs.entries.first().executor.id;
  340.         var userAvatar = logs.entries.first().executor.avatarURL;
  341.  
  342.         if(userID === client.user.id) return;
  343.  
  344.         let banInfo = new Discord.RichEmbed()
  345.         .setTitle('**[BANNED]**')
  346.         .setThumbnail(userAvatar)
  347.         .setColor('DARK_RED')
  348.         .setDescription(`**\n**:airplane: Successfully \`\`BANNED\`\` **${user.username}** From the server!\n\n**User:** <@${user.id}> (ID: ${user.id})\n**By:** <@${userID}> (ID: ${userID})`)
  349.         .setTimestamp()
  350.         .setFooter(guild.name, guild.iconURL)
  351.  
  352.         logChannel.send(banInfo);
  353.     })
  354. });
  355. client.on('guildBanRemove', (guild, user) => {
  356.     if(!guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  357.     if(!guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  358.             if(!log[guild.guild.id]) log[guild.guild.id] = {
  359.           onoff: 'Off'
  360.         }
  361.     if(log[guild.guild.id].onoff === 'Off') return;
  362.     var logChannel = guild.channels.find(c => c.name === `${log[guild.guild.id].channel}`);
  363.     if(!logChannel) return;
  364.  
  365.     guild.fetchAuditLogs().then(logs => {
  366.         var userID = logs.entries.first().executor.id;
  367.         var userAvatar = logs.entries.first().executor.avatarURL;
  368.  
  369.         if(userID === client.user.id) return;
  370.  
  371.         let unBanInfo = new Discord.RichEmbed()
  372.         .setTitle('**[UNBANNED]**')
  373.         .setThumbnail(userAvatar)
  374.         .setColor('GREEN')
  375.         .setDescription(`**\n**:unlock: Successfully \`\`UNBANNED\`\` **${user.username}** From the server\n\n**User:** <@${user.id}> (ID: ${user.id})\n**By:** <@${userID}> (ID: ${userID})`)
  376.         .setTimestamp()
  377.         .setFooter(guild.name, guild.iconURL)
  378.  
  379.         logChannel.send(unBanInfo);
  380.     })
  381. });
  382.  
  383. client.on('guildMemberUpdate', (oldMember, newMember) => {
  384.     if(!oldMember.guild) return;
  385.                 if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  386.           onoff: 'Off'
  387.         }
  388.     if(log[oldMember.guild.id].onoff === 'Off') return;
  389.     var logChannel = oldMember.guild.channels.find(c => c.name === `${log[oldMember, newMember.guild.id].channel}`);
  390.     if(!logChannel) return;
  391.  
  392.     oldMember.guild.fetchAuditLogs().then(logs => {
  393.         var userID = logs.entries.first().executor.id;
  394.         var userAvatar = logs.entries.first().executor.avatarURL;
  395.         var userTag = logs.entries.first().executor.tag;
  396.  
  397.         if(oldMember.nickname !== newMember.nickname) {
  398.             if(oldMember.nickname === null) {
  399.                 var oldNM = '`اسمه الاصلي`';
  400.             }else {
  401.                 var oldNM = oldMember.nickname;
  402.             }
  403.             if(newMember.nickname === null) {
  404.                 var newNM = '`اسمه الاصلي`';
  405.             }else {
  406.                 var newNM = newMember.nickname;
  407.             }
  408.  
  409.             let updateNickname = new Discord.RichEmbed()
  410.             .setTitle('**[UPDATE MEMBER NICKNAME]**')
  411.             .setThumbnail(userAvatar)
  412.             .setColor('BLUE')
  413.             .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})`)
  414.             .setTimestamp()
  415.             .setFooter(oldMember.guild.name, oldMember.guild.iconURL)
  416.  
  417.             logChannel.send(updateNickname);
  418.         }
  419.         if(oldMember.roles.size < newMember.roles.size) {
  420.             let role = newMember.roles.filter(r => !oldMember.roles.has(r.id)).first();
  421.                             if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  422.           onoff: 'Off'
  423.         }
  424.             if(log[oldMember.guild.id].onoff === 'Off') return;
  425.             let roleAdded = new Discord.RichEmbed()
  426.             .setTitle('**[ADDED ROLE TO MEMBER]**')
  427.             .setThumbnail(oldMember.guild.iconURL)
  428.             .setColor('GREEN')
  429.             .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})`)
  430.             .setTimestamp()
  431.             .setFooter(userTag, userAvatar)
  432.  
  433.             logChannel.send(roleAdded);
  434.         }
  435.         if(oldMember.roles.size > newMember.roles.size) {
  436.             let role = oldMember.roles.filter(r => !newMember.roles.has(r.id)).first();
  437.                             if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  438.           onoff: 'Off'
  439.         }
  440.             if(log[oldMember, newMember.guild.id].onoff === 'Off') return;
  441.             let roleRemoved = new Discord.RichEmbed()
  442.             .setTitle('**[REMOVED ROLE FROM MEMBER]**')
  443.             .setThumbnail(oldMember.guild.iconURL)
  444.             .setColor('RED')
  445.             .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})`)
  446.             .setTimestamp()
  447.             .setFooter(userTag, userAvatar)
  448.  
  449.             logChannel.send(roleRemoved);
  450.         }
  451.     })
  452.     if(oldMember.guild.owner.id !== newMember.guild.owner.id) {
  453.                     if(!log[oldMember.guild.id]) log[oldMember.guild.id] = {
  454.           onoff: 'Off'
  455.         }
  456.         if(log[oldMember, newMember.guild.id].onoff === 'Off') return;
  457.         let newOwner = new Discord.RichEmbed()
  458.         .setTitle('**[UPDATE GUILD OWNER]**')
  459.         .setThumbnail(oldMember.guild.iconURL)
  460.         .setColor('GREEN')
  461.         .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})`)
  462.         .setTimestamp()
  463.         .setFooter(oldMember.guild.name, oldMember.guild.iconURL)
  464.  
  465.         logChannel.send(newOwner);
  466.     }
  467. });
  468.  
  469.  
  470. client.on('voiceStateUpdate', (voiceOld, voiceNew) => {
  471.  
  472.     if(!voiceOld.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
  473.     if(!voiceOld.guild.member(client.user).hasPermission('VIEW_AUDIT_LOG')) return;
  474.                     if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  475.           onoff: 'Off'
  476.         }
  477.     if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  478.     var logChannel = voiceOld.guild.channels.find(c => c.name === `${log[voiceOld, voiceNew.guild.id].channel}`);
  479.     if(!logChannel) return;
  480.  
  481.     voiceOld.guild.fetchAuditLogs().then(logs => {
  482.         var userID = logs.entries.first().executor.id;
  483.         var userTag = logs.entries.first().executor.tag;
  484.         var userAvatar = logs.entries.first().executor.avatarURL;
  485.  
  486.         if(voiceOld.serverMute === false && voiceNew.serverMute === true) {
  487.             let serverMutev = new Discord.RichEmbed()
  488.             .setTitle('**[VOICE MUTE]**')
  489.             .setThumbnail('https://images-ext-1.discordapp.net/external/pWQaw076OHwVIFZyeFoLXvweo0T_fDz6U5C9RBlw_fQ/https/cdn.pg.sa/UosmjqDNgS.png')
  490.             .setColor('RED')
  491.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  492.             .setTimestamp()
  493.             .setFooter(userTag, userAvatar)
  494.  
  495.             logChannel.send(serverMutev);
  496.         }
  497.         if(voiceOld.serverMute === true && voiceNew.serverMute === false) {
  498.                             if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  499.           onoff: 'Off'
  500.         }
  501.             if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  502.             let serverUnmutev = new Discord.RichEmbed()
  503.             .setTitle('**[VOICE UNMUTE]**')
  504.             .setThumbnail('https://images-ext-1.discordapp.net/external/u2JNOTOc1IVJGEb1uCKRdQHXIj5-r8aHa3tSap6SjqM/https/cdn.pg.sa/Iy4t8H4T7n.png')
  505.             .setColor('GREEN')
  506.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  507.             .setTimestamp()
  508.             .setFooter(userTag, userAvatar)
  509.  
  510.             logChannel.send(serverUnmutev);
  511.         }
  512.         if(voiceOld.serverDeaf === false && voiceNew.serverDeaf === true) {
  513.                             if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  514.           onoff: 'Off'
  515.         }
  516.             if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  517.             let serverDeafv = new Discord.RichEmbed()
  518.             .setTitle('**[VOICE DEAF]**')
  519.             .setThumbnail('https://images-ext-1.discordapp.net/external/7ENt2ldbD-3L3wRoDBhKHb9FfImkjFxYR6DbLYRjhjA/https/cdn.pg.sa/auWd5b95AV.png')
  520.             .setColor('RED')
  521.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  522.             .setTimestamp()
  523.             .setFooter(userTag, userAvatar)
  524.  
  525.             logChannel.send(serverDeafv);
  526.         }
  527.         if(voiceOld.serverDeaf === true && voiceNew.serverDeaf === false) {
  528.                             if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  529.           onoff: 'Off'
  530.         }
  531.             if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  532.             let serverUndeafv = new Discord.RichEmbed()
  533.             .setTitle('**[VOICE UNDEAF]**')
  534.             .setThumbnail('https://images-ext-2.discordapp.net/external/s_abcfAlNdxl3uYVXnA2evSKBTpU6Ou3oimkejx3fiQ/https/cdn.pg.sa/i7fC8qnbRF.png')
  535.             .setColor('GREEN')
  536.             .setDescription(`**User:** ${voiceOld} (ID: ${voiceOld.id})\n**By:** <@${userID}> (ID: ${userID})\n**Channel:** \`\`${voiceOld.voiceChannel.name}\`\` (ID: ${voiceOld.voiceChannel.id})`)
  537.             .setTimestamp()
  538.             .setFooter(userTag, userAvatar)
  539.  
  540.             logChannel.send(serverUndeafv);
  541.         }
  542.     })
  543.    
  544.     if(voiceOld.voiceChannelID !== voiceNew.voiceChannelID && voiceNew.voiceChannel && voiceOld.voiceChannel != null) {
  545.                         if(!log[voiceOld.guild.id]) log[voiceOld.guild.id] = {
  546.           onoff: 'Off'
  547.         }
  548.         if(log[voiceOld, voiceOld.guild.id].onoff === 'Off') return;
  549.         let voiceLeave = new Discord.RichEmbed()
  550.         .setTitle('**[CHANGED VOICE ROOM]**')
  551.         .setColor('GREEN')
  552.         .setThumbnail(voiceOld.user.avatarURL)
  553.         .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})`)
  554.         .setTimestamp()
  555.         .setFooter(voiceOld.user.tag, voiceOld.user.avatarURL)
  556.  
  557.         logChannel.send(voiceLeave);
  558.     }
  559. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement