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