thaldrin/modules/General/botinfo.js

86 lines
2.4 KiB
JavaScript

const Command = require("../../src/structures/Command");
// {
// name: 'Voice Connections',
// value: parseInt(ctx.client.voice.connections.size).toLocaleString(),
// inline: true
// },
module.exports = class Botinfo extends Command {
constructor() {
super({
name: "botinfo",
description:
"Bot information and live statistics, such as memory usage and servers.",
// aliases: ['stats', 'statistics', 'about'],
module: "General",
cooldown: 0,
guildOnly: false,
developerOnly: false
});
}
async command(ctx) {
usage.lookup(process.pid, options, (err, result) => {
if (err)
return ctx.send(`There was an error measuring CPU usage.\n\`${err}\``);
return ctx.send({
embed: {
title: `Musik`,
description: `Using discord.js **${
require("discord.js").version
}**, node.js **${process.version.replace(
"v",
""
)}** and Linux **${require("os").release()}**.\nYou are on shard ${ctx
.guild.shard.id + 1}/${ctx.client.options.shards.length} in the "${
ctx.guild.region
}" region.`,
fields: [
{
name: "Servers",
value: parseInt(ctx.client.guilds.size).toLocaleString(),
inline: true
},
{
name: "Users",
value: parseInt(
ctx.client.guilds
.map(guild => guild.memberCount)
.reduce((g1, g2) => g1 + g2)
).toLocaleString(),
inline: true
},
{
name: "Shards",
value: parseInt(
ctx.client.options.shards.length
).toLocaleString(),
inline: true
},
{
name: "Memory Usage",
value:
result.memory < 1024000000
? `${Math.round(result.memory / 1024 / 1024)} MB`
: `${(result.memory / 1024 / 1024 / 1024).toFixed(1)} GB`,
inline: true
},
{
name: "CPU Usage",
value: `${result.cpu.toFixed(1)}%`,
inline: true
},
{
name: "Uptime",
value: format(ctx.client.uptime / 1000),
inline: true
}
],
color: 0xff873f
}
});
});
}
};