Skip to content

Commit

Permalink
Merge pull request #83 from reinhello/stats-cmd
Browse files Browse the repository at this point in the history
Add current server and user counts
  • Loading branch information
reinacchi authored Aug 29, 2022
2 parents 65dfa48 + 1b34435 commit 83036f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions framework/lib/Commands/Modules/StatsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import { Util } from "../../Utils";
import osUtils from "os-utils";
import os from "os";
import packageJson from "../../../package.json";
import { setTimeout } from "node:timers/promises";

export async function statsCommand(client: NReaderClient, interaction: CommandInteraction<TextableChannel>) {
const memory: number = process.memoryUsage().rss;

await interaction.defer();
await setTimeout(2000);

const totalMemory = `${Util.bytesToSize(memory).value}${Util.bytesToSize(memory).unit} / ${Util.bytesToSize(os.totalmem()).value}${Util.bytesToSize(os.totalmem()).unit}`;
const totalMem = Util.bytesToSize(os.totalmem()).value * 1000 ;
const used: number = process.memoryUsage().rss / totalMem / totalMem;
Expand All @@ -29,8 +33,8 @@ export async function statsCommand(client: NReaderClient, interaction: CommandIn
.addField("NodeJS", `${process.versions.node}`, true)
.addField("Eris", `${VERSION}`, true)
.addField("API", packageJson.dependencies["nhentai-api"].replace("^", ""), true)
.addField(client.translate("general.stats.server"), guildData.length.toLocaleString(), true)
.addField(client.translate("general.stats.user"), userData.length.toLocaleString(), true)
.addField(client.translate("general.stats.server"), `${guildData.length.toLocaleString()} (${client.guilds.size.toLocaleString()})`, true)
.addField(client.translate("general.stats.user"), `${userData.length.toLocaleString()} (${client.users.size.toLocaleString()})`, true)
.addField(client.translate("general.stats.platform"), `${process.platform.charAt(0).toUpperCase() + process.platform.slice(1)}`, true);

return interaction.createMessage({
Expand Down

0 comments on commit 83036f7

Please sign in to comment.