diff --git a/index.js b/index.js index 6dc7072..3328f98 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,6 @@ fs.readdir('./commands/', (err, files) => { client.commands.set(commandName, props); }); }); -a client.login("ODU5MzA0NzQyOTcwODUxMzI5.YNqv5w.3ZqRw_qTN6seZt_Ue5K9BYJJzs4"); setInterval(() => { @@ -33,17 +32,29 @@ let hosturl = "https://host.itzy-store.net" let id = "6154c1cc" let apikey = "hgQGH3wpNVP98FTxl2PDOmjQLLmz4WBHsDft1HQPcosqPevS" -let Client = new node.NodeactylClient(hosturl, apikey); -const stats = Client.getServerUsages(id); -const status = (stats.current_state); +//let Client = new node.NodeactylClient(hosturl, apikey); +//const stats = Client.getServerUsages(id); +//const status = (stats.current_state); const ch = client.channels.cache.get('837238494765645834') -const msg = ch.messages.cache.get('860438916275240971') +//const msg = ch.messages.cache.get('860438916275240971') -if(status === 'offline') { -ch.send(`Node is online\nTime : ${Date.now()}`).then(m => { m.delete({timeout: 5000}) }) -} else { -ch.send(`Node is offline\nTime : ${Date.now()}`).then(m => { m.delete({timeout: 5000}) }) -} +//if(status === 'offline') { +axios(`${hosturl} /api/client/servers/${id}/resources`, { + "method": "GET", + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "Authorization": `Bearer ${apikey}`, + } +}) + .then(response => { + ch.send(`Node is online\nTime : ${Date.now()}`).then(m => { m.delete({timeout: 20000}) }) + }) + .catch(err => { + ch.send(`Node is offline\nTime : ${Date.now()}`).then(m => { m.delete({timeout: 20000}) }) + }); +//} else { +//} }, 20000)