SHARE
TWEET

ass

a guest May 20th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js')
  2. const request = require('request')
  3. const prefix = "/"
  4.  
  5.  
  6. function getAllServers(ip) {
  7.     return new Promise(function(sendSuccess, sendError) {
  8.       request(`http://${ip}/info.json`, function (error, response, body) {
  9.       //request('http://servers-live. .net/api/servers/', function (error, response, body) {
  10.         if (error) {
  11.           sendError(error);
  12.           return;
  13.         }
  14.  
  15.         sendSuccess(JSON.parse(body));
  16.       });
  17.     });
  18. }
  19.  
  20.  
  21. function getServerInfo(ip) {
  22.     return new Promise(function(sendSuccess, sendError) {
  23.       var server = {}
  24.       request("http://"+ip+"/info.json", function (error, response, body) {
  25.         if (error) {
  26.           sendError(error);
  27.           return;
  28.         }
  29.  
  30.         server.infos = JSON.parse(body);
  31.  
  32.         request("http://"+ip+"/players.json", function (error, response, body) {
  33.           if (error) {
  34.             sendError(error);
  35.             return;
  36.           }
  37.  
  38.           server.players = JSON.parse(body);
  39.  
  40.           getAllServers(ip).then(function(servers) {
  41.             let serv = servers
  42.             //for (let serv of servers) {
  43.               if (serv.EndPoint == ip) {
  44.                 server.infos.vars.sv_hostname = serv.Data.hostname
  45.               //}
  46.             }
  47.  
  48.             sendSuccess(server)
  49.           })
  50.  
  51.         });
  52.  
  53.       });
  54.     });
  55.   }
  56.  
  57. const LS1 = '145.239.204.77:30120'
  58. const LS2 = '145.239.204.77:30122'
  59. const LS3 = '145.239.204.77:30124'
  60. const LS4 = '145.239.204.77:30126'
  61.  
  62. const TR1 = '145.239.204.77:30121'
  63. const TR2 = '145.239.204.77:30123'
  64. const TR3 = '145.239.204.77:30125'
  65. const TR4 = '145.239.204.77:30127'
  66.  
  67. let los1
  68. let los2
  69. let los3
  70. let los4
  71.  
  72. let tra1
  73. let tra2
  74. let tra3
  75. let tra4
  76.  
  77.  
  78. var los1="Server Error"
  79. var los2="Server Error"
  80. var los3="Server Error"
  81. var los4="Server Error"
  82.  
  83. var tra1="Server Error"
  84. var tra2="Server Error"
  85. var tra3="Server Error"
  86. var tra4="Server Error"
  87.  
  88.  
  89. // bot
  90. module.exports.run = async (bot, message, args) => {
  91.   try{
  92.   ls1_stat=getServerInfo(LS1).then((server1) => {
  93.     los1 = server1.players.length
  94.   })
  95. }
  96. catch(e){
  97.   los1="Server Error"
  98.   console.log(e)
  99. }
  100.  
  101. try{
  102.   getServerInfo(LS2).then((server2) => {
  103.     los2 = server2.players.length
  104.   })
  105. }
  106. catch(e){
  107.   los2="Server Error"
  108.   console.log(e)
  109. }
  110.  
  111. try{
  112.   getServerInfo(LS3).then((server3) => {
  113.     los3 = server3.players.length
  114.   })
  115. }
  116. catch(e){
  117.   los3="Server Error"
  118.   console.log(e)
  119. }
  120.  
  121. try{
  122.   getServerInfo(LS4).then((server4) => {
  123.     los4 = server4.players.length
  124.   })
  125. }
  126. catch(e){
  127.   los4="Server Error"
  128.   console.log(e)
  129. }
  130.  
  131. try{
  132.   getServerInfo(TR1).then((server1) => {
  133.     tra1 = server1.players.length
  134.   })
  135. }
  136. catch(e){
  137.   tra1="Server Error"
  138.   console.log(e)
  139. }
  140.  
  141. try{
  142.   getServerInfo(TR2).then((server1) => {
  143.     tra2 = server1.players.length
  144.   })
  145. }
  146. catch(e){
  147.   tra2="Server Error"
  148.   console.log(e)
  149. }
  150.  
  151. try{
  152.   getServerInfo(TR3).then((server1) => {
  153.     tra3 = server1.players.length
  154.   })
  155. }
  156. catch(e){
  157.   tra3="Server Error"
  158.   console.log(e)
  159. }
  160.  
  161. try{
  162.   getServerInfo(TR4).then((server1) => {
  163.     tra4 = server1.players.length
  164.   })
  165. }
  166. catch(e){
  167.   tra4="Server Error"
  168.   console.log(e)
  169. }
  170. console.dir(`----- ${los1}  |  ${los2}  |  ${los3}  |  ${los4}  |  ${tra1}  |  ${tra2}  |  ${tra3}  |  ${tra4}`)
  171.        
  172.        
  173.  
  174.  
  175.         var interval = setTimeout (function () {
  176.             const serverEmbed = new Discord.RichEmbed()
  177.             .setTitle(`Velocity Drift Servers`)
  178.             .setDescription(`View our server statistics below.`)
  179.  
  180.             .addField(`__Los Santos 1__`, `IP: **${LS1}**\nPlayers: ${los1} / 32\n`, true)
  181.  
  182.             .addField(`__Tracks 1__`, `IP: **${TR1}**\nPlayers: ${tra1} / 32\n`, true)
  183.             .addBlankField()
  184.  
  185.             .addField(`__Los Santos 2__`, `IP: **${LS2}**\nPlayers: ${los2} / 32\n`, true)
  186.  
  187.             .addField(`__Tracks 2__`, `IP: **${TR2}**\nPlayers: ${tra2} / 32\n`, true)
  188.             .addBlankField()
  189.  
  190.             .addField(`__Los Santos 3__`, `IP: **${LS3}**\nPlayers: ${los3} / 32\n`, true)
  191.  
  192.             .addField(`__Tracks 3__`, `IP: **${TR3}**\nPlayers: ${tra3} / 32\n`, true)
  193.             .addBlankField()
  194.  
  195.             .addField(`__Los Santos 4__`, `IP: **${LS4}**\nPlayers: ${los4} / 32\n`, true)
  196.  
  197.             .addField(`__Tracks 4__`, `IP: **${TR4}**\nPlayers: ${tra4} / 32\n`, true)
  198.  
  199.             .setFooter(`hazelify & zit`, `https://i.imgur.com/sI2ENmQ.png`)
  200.  
  201.             if (message.channel.id === `444989838635302915`) {
  202.  
  203.                 message.channel.send(serverEmbed).then(msg => {
  204.                     message.delete(50)
  205.                     msg.delete(30000)
  206.                    
  207.                 })
  208.  
  209.  
  210.             } else {
  211.  
  212.                 message.channel.send(`Please refer to ${bot.channels.get(`444989838635302915`)}.`).then(msg => {
  213.                     msg.delete(3000)
  214.                     message.delete(50)
  215.                 })
  216.             }
  217.            
  218.             console.dir(`${los1}  |  ${los2}  |  ${los3}  |  ${los4}  |  ${tra1}  |  ${tra2}  |  ${tra3}  |  ${tra4}`)
  219.         }, 1 * 500)
  220.     }))
  221.  
  222. }
  223.  
  224. module.exports.help = {
  225.     name: "ip"
  226. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top