Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unirest.get("https://api.battlemetrics.com/servers/1631443?include=player")
  2.     .end(function (result) {
  3.         //ch1.sendMessage("Добрый вечер, я диспетчер");
  4.         //console.log(result.status, result.headers, result.body);
  5.         var json = JSON.parse(JSON.stringify(result.body));
  6.         if(result.status != 200) {
  7.             ch1.setName("offline");
  8.             /*ch1.fetchMessage('667393448571305994')
  9.             .then(message => message.edit("Сервер оффлайн :("))
  10.             .catch(console.error);*/
  11.  
  12.         } else {
  13.             ch1.setName("💹" +  json.data.attributes.players + " из " + json.data.attributes.maxPlayers);
  14.             var playersList = "Игроки online:";
  15.  
  16.             playersList = playersList + json.included[0];
  17.  
  18.             ch1.fetchMessage('667416042707877903').
  19.             then(message => message.edit("```" + "    " +
  20.                 json.data.attributes.name + "\n" +
  21.                 "    ip: " + json.data.attributes.ip + "\n" +
  22.                 "    Карта: " + json.data.attributes.details.map + "\n" +
  23.                 "    Игроков онлайн: " + json.data.attributes.players + " из "  + json.data.attributes.maxPlayers + "\n" +
  24.                 "    Статус: " + json.data.attributes.status + "\n" + "\n" + playersList + "```"
  25.             ))
  26.             .catch(console.error);
  27.         };
  28.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement