Display correctly uptime
This commit is contained in:
parent
e5d04529e4
commit
fff71c9066
1 changed files with 18 additions and 8 deletions
|
@ -16,13 +16,23 @@ class StatsCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message) {
|
async exec(message) {
|
||||||
let totalSeconds = (this.client.uptime / 1000);
|
var uptime = process.uptime();
|
||||||
let days = Math.floor(totalSeconds / 86400);
|
const date = new Date(uptime*1000);
|
||||||
let hours = Math.floor(totalSeconds / 3600);
|
const days = date.getUTCDate() - 1,
|
||||||
totalSeconds %= 3600;
|
hours = date.getUTCHours(),
|
||||||
let minutes = Math.floor(totalSeconds / 60);
|
minutes = date.getUTCMinutes(),
|
||||||
let seconds = totalSeconds.toFixed(0) % 60;
|
seconds = date.getUTCSeconds();
|
||||||
let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
|
|
||||||
|
|
||||||
|
let segments = [];
|
||||||
|
|
||||||
|
// Format the uptime string.
|
||||||
|
if (days > 0) segments.push(days + ' day' + ((days == 1) ? '' : 's'));
|
||||||
|
if (hours > 0) segments.push(hours + ' hour' + ((hours == 1) ? '' : 's'));
|
||||||
|
if (minutes > 0) segments.push(minutes + ' minute' + ((minutes == 1) ? '' : 's'));
|
||||||
|
if (seconds > 0) segments.push(seconds + ' second' + ((seconds == 1) ? '' : 's'));
|
||||||
|
const dateString = segments.join(', ');
|
||||||
|
|
||||||
const used = process.memoryUsage().heapUsed / 1024 / 1024;
|
const used = process.memoryUsage().heapUsed / 1024 / 1024;
|
||||||
|
|
||||||
const statsEmbed = new MessageEmbed()
|
const statsEmbed = new MessageEmbed()
|
||||||
|
@ -32,7 +42,7 @@ class StatsCommand extends Command {
|
||||||
.addField('Servers', this.client.guilds.size, true)
|
.addField('Servers', this.client.guilds.size, true)
|
||||||
.addField('Channels', this.client.channels.size, true)
|
.addField('Channels', this.client.channels.size, true)
|
||||||
.addField('Users', this.client.users.size, true)
|
.addField('Users', this.client.users.size, true)
|
||||||
.addField('Uptime', uptime, true)
|
.addField('Uptime', dateString, true)
|
||||||
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
|
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
|
||||||
.addField('Nodejs version', process.version, true)
|
.addField('Nodejs version', process.version, true)
|
||||||
.addField('Discord.js version', version, true)
|
.addField('Discord.js version', version, true)
|
||||||
|
|
Loading…
Reference in a new issue