mirror of
https://github.com/litruv/DAdmin.git
synced 2026-07-25 03:06:11 +10:00
Initial commit
This commit is contained in:
50
commands/stats.js
Normal file
50
commands/stats.js
Normal file
@@ -0,0 +1,50 @@
|
||||
exports.name = 'Stats for DAdmin'
|
||||
exports.alias = ['stats']
|
||||
exports.helptext = 'Metrics on DAdmin, uptime, users, servers'
|
||||
exports.helphide = false
|
||||
exports.permissions = ['READ_MESSAGES']
|
||||
exports.category = 'general'
|
||||
exports.command = (client, msg) => {
|
||||
var users = 0;
|
||||
for (var i = 0; i < client.guilds.array().length; i++){
|
||||
users += client.guilds.array()[i].members.array().length;
|
||||
}
|
||||
|
||||
msg.reply("Running DAdmin for " + millisecondsToStr(client.uptime) + " on " + client.guilds.array().length + " servers for " + users + " users, since 09 Aug 2018");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function millisecondsToStr (milliseconds) {
|
||||
// TIP: to find current time in milliseconds, use:
|
||||
// var current_time_milliseconds = new Date().getTime();
|
||||
|
||||
function numberEnding (number) {
|
||||
return (number > 1) ? 's' : '';
|
||||
}
|
||||
|
||||
var temp = Math.floor(milliseconds / 1000);
|
||||
var years = Math.floor(temp / 31536000);
|
||||
if (years) {
|
||||
return years + ' year' + numberEnding(years);
|
||||
}
|
||||
//TODO: Months! Maybe weeks?
|
||||
var days = Math.floor((temp %= 31536000) / 86400);
|
||||
if (days) {
|
||||
return days + ' day' + numberEnding(days);
|
||||
}
|
||||
var hours = Math.floor((temp %= 86400) / 3600);
|
||||
if (hours) {
|
||||
return hours + ' hour' + numberEnding(hours);
|
||||
}
|
||||
var minutes = Math.floor((temp %= 3600) / 60);
|
||||
if (minutes) {
|
||||
return minutes + ' minute' + numberEnding(minutes);
|
||||
}
|
||||
var seconds = temp % 60;
|
||||
if (seconds) {
|
||||
return seconds + ' second' + numberEnding(seconds);
|
||||
}
|
||||
return 'less than a second'; //'just now' //or other string you like;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user