SHARE
TWEET

information server - developed

MrWolf_1sT Feb 14th, 2020 (edited) 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const count = require("./count.json")
  2. const finished = require("./finished.json")
  3. client.on('ready', () => {
  4.     bot.setInterval(() => {
  5.         let ga;
  6.         Object.keys(finished).forEach((key) => {
  7.             ga = key
  8.         });
  9.         if (finished[ga] !== undefined) {
  10.             if (Date.now() > finished[ga].timefinish) {
  11.                 finished[ga + ' Finished'] = {
  12.                     Joins: finished[ga].Joins,
  13.                     Leaves: finished[ga].Leaves
  14.                 }
  15.                 finished[ga].Joins = 0
  16.                 finished[ga].Leaves = 0
  17.                 finished[ga].timefinish = Date.now() + 6.048e+8
  18.                 fs.writeFile('./finished.json', JSON.stringify(finished, null, 4), (err) => { if (err) throw err; })
  19.             }
  20.         }
  21.     }, 5000)
  22.  
  23. })
  24. client.on('guildMemberAdd', (codes) => {
  25.     if (count[codes.guild.id] == undefined) {
  26.         count[codes.guild.id] = {
  27.             Joins: 1,
  28.             Leaves: 0,
  29.             timefinish: Date.now() + 6.048e+8
  30.         }
  31.     } else {
  32.         count[codes.guild.id].Joins += 1
  33.     }
  34.     if (finished[codes.guild.id] == undefined) {
  35.         finished[codes.guild.id] = {
  36.             Joins: 1,
  37.             Leaves: 0,
  38.             timefinish: Date.now() + 6.048e+8
  39.         }
  40.     } else {
  41.         finished[codes.guild.id].Joins += 1
  42.     }
  43.     fs.writeFile('./count.json', JSON.stringify(count, null, 4), (err) => {
  44.         if (err) throw err;
  45.     })
  46.     fs.writeFile('./finished.json', JSON.stringify(finished, null, 4), (err) => {
  47.         if (err) throw err;
  48.     })
  49. })
  50. client.on('guildMemberRemove', (codes) => {
  51.     if (count[codes.guild.id] == undefined) {
  52.         count[codes.guild.id] = {
  53.             Joins: 0,
  54.             Leaves: 1,
  55.             timefinish: Date.now() + 6.048e+8
  56.         }
  57.     } else {
  58.         count[codes.guild.id].Leaves += 1
  59.     }
  60.     if (finished[codes.guild.id] == undefined) {
  61.         finished[codes.guild.id] = {
  62.             Joins: 0,
  63.             Leaves: 1,
  64.             timefinish: Date.now() + 6.048e+8
  65.         }
  66.     } else {
  67.         finished[codes.guild.id].Leaves += 1
  68.     }
  69.     fs.writeFile('./count.json', JSON.stringify(count, null, 4), (err) => {
  70.         if (err) throw err;
  71.     })
  72.     fs.writeFile('./finished.json', JSON.stringify(finished, null, 4), (err) => {
  73.         if (err) throw err;
  74.     })
  75. })
  76. client.on('message', function (message) {
  77.     const messageArray = message.content.split(' ')
  78.     const command = messageArray[0].toLowerCase()
  79.     const args = messageArray.slice(1)
  80.     if (command == `${prefix}server`) {
  81.         var embed = new RichEmbed()
  82.         let guild;
  83.         if (count[message.guild.id] == undefined) {
  84.             return;
  85.         }
  86.         if (count[message.guild.id] !== undefined) {
  87.             let tjlr = (count[message.guild.id].Joins / count[message.guild.id].Leaves).toFixed(2)
  88.                         if (tjlr == Infinity) tjlr = '0.00'
  89.                         embed.addField(`? Server ID:`, `? **${message.guild.id}**`, true)
  90.                         embed.addField(`? Created on:`, `? **${moment(message.guild.createdAt).format(`D/M/YYYY h:mm`)} \n ${moment(message.guild.createdAt).locale("AR-eg").fromNow()}**`,true)
  91.                         embed.addField(`? Owned by:`, `? **${message.guild.owner.user.tag} [${message.guild.owner.user.id}]**`,true)
  92.                         embed.addField(`? Members **${message.guild.members.size}**`, `? **${message.guild.members.filter(c => c.presence.status !== "offline").size}** Online`, true)
  93.                         embed.addField(`? Channels **${message.guild.channels.size}**`,`? **${message.guild.channels.filter(f => f.type === "text").size}** Text | **${message.guild.channels.filter(f => f.type === "voice").size}** Voice`,true)
  94.                         embed.addField(`? Others:`, `? Region: **${message.guild.region}** \n? Verification level: **${message.guild.verificationLevel}**`, true)  
  95.                         embed.addField(`? Roles **${message.guild.roles.size}**`, `? More?: **${prefix}roles**`, true)
  96.                         embed.setThumbnail(`${message.guild.iconURL}`)
  97.                         embed.setColor(`black`)
  98.                         embed.setAuthor(`${message.guild.name}`, `${message.guild.iconURL}`)
  99.             embed.addField('? Total joins - Leaves:', `? **${count[message.guild.id].Joins}** | **-${count[message.guild.id].Leaves}**`)
  100.             embed.addField('? Week stats:', `? Joins: **${finished[message.guild.id].Joins}** | ? Leaves: **-${finished[message.guild.id].Leaves}**`)
  101.         }
  102.         if(finished[message.guild.id] == undefined) return;
  103.         if (guild == message.guild.id) {
  104.             let something = (finished[message.guild.id].Joins / finished[message.guild.id].Leaves).toFixed(2)
  105.             if(isNaN(something)) something = 0.00
  106.         }
  107.         finished[message.guild.id + ' Finished'] == undefined;
  108.         message.channel.send(embed)
  109.     }
  110. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top