api #3
This commit is contained in:
21
index.js
21
index.js
@@ -131,10 +131,9 @@ client.login(process.env.BOT_TOKEN);
|
|||||||
const http = require('http');
|
const http = require('http');
|
||||||
const port = process.env.PORT || 3000;
|
const port = process.env.PORT || 3000;
|
||||||
|
|
||||||
http
|
let status;
|
||||||
.createServer(async (req, res) => {
|
|
||||||
res.statusCode = 200;
|
|
||||||
|
|
||||||
|
const getStatus = () => {
|
||||||
let totalSeconds = process.uptime();
|
let totalSeconds = process.uptime();
|
||||||
let realTotalSecs = Math.floor(totalSeconds % 60);
|
let realTotalSecs = Math.floor(totalSeconds % 60);
|
||||||
let days = Math.floor((totalSeconds % 31536000) / 86400);
|
let days = Math.floor((totalSeconds % 31536000) / 86400);
|
||||||
@@ -142,8 +141,7 @@ http
|
|||||||
let mins = Math.floor((totalSeconds / 60) % 60);
|
let mins = Math.floor((totalSeconds / 60) % 60);
|
||||||
let used = process.memoryUsage().heapUsed / 1024 / 1024;
|
let used = process.memoryUsage().heapUsed / 1024 / 1024;
|
||||||
|
|
||||||
res.write(
|
status = {
|
||||||
JSON.stringify({
|
|
||||||
username: client.user.username,
|
username: client.user.username,
|
||||||
avatar: client.user.avatarURL(),
|
avatar: client.user.avatarURL(),
|
||||||
status: client.user.presence.status,
|
status: client.user.presence.status,
|
||||||
@@ -161,8 +159,17 @@ http
|
|||||||
memory: `${Math.round(used * 100) / 100}MB`,
|
memory: `${Math.round(used * 100) / 100}MB`,
|
||||||
ping: `${Math.floor(client.ws.ping)}ms`,
|
ping: `${Math.floor(client.ws.ping)}ms`,
|
||||||
node: process.version,
|
node: process.version,
|
||||||
})
|
};
|
||||||
);
|
};
|
||||||
|
|
||||||
|
getStatus();
|
||||||
|
setInterval(getStatus, 30000);
|
||||||
|
|
||||||
|
http
|
||||||
|
.createServer(async (req, res) => {
|
||||||
|
res.statusCode = 200;
|
||||||
|
|
||||||
|
res.write(JSON.stringify(status));
|
||||||
res.end();
|
res.end();
|
||||||
})
|
})
|
||||||
.listen(port, () => console.log(`Now listening on port ${port}`));
|
.listen(port, () => console.log(`Now listening on port ${port}`));
|
||||||
|
|||||||
Reference in New Issue
Block a user