From f7490c119091a5cb206fcbb5388ba0f2b20ac375 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Thu, 22 Feb 2024 22:25:33 -0500 Subject: [PATCH] Memory command --- src/api/commands/groups/index.ts | 3 ++- src/api/commands/groups/util/mem.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/api/commands/groups/util/mem.ts diff --git a/src/api/commands/groups/index.ts b/src/api/commands/groups/index.ts index 17ac941..33f1214 100644 --- a/src/api/commands/groups/index.ts +++ b/src/api/commands/groups/index.ts @@ -12,6 +12,7 @@ import { inventory } from "./inventory/inventory"; import { eat } from "./inventory/eat"; import { sack } from "./inventory/sack"; import { reel } from "./fishing/reel"; +import { memory } from "./util/mem"; interface ICommandGroup { id: string; @@ -48,7 +49,7 @@ commandGroups.push(inventoryGroup); const utilGroup: ICommandGroup = { id: "util", displayName: "Utility", - commands: [data, setcolor] + commands: [data, setcolor, memory] }; commandGroups.push(utilGroup); diff --git a/src/api/commands/groups/util/mem.ts b/src/api/commands/groups/util/mem.ts new file mode 100644 index 0000000..784bf5b --- /dev/null +++ b/src/api/commands/groups/util/mem.ts @@ -0,0 +1,18 @@ +import Command from "@server/commands/Command"; + +export const memory = new Command( + "memory", + ["memory", "mem"], + "View memory usage", + "memory", + "command.util.memory", + async () => { + const mem = process.memoryUsage(); + return `Memory: ${(mem.heapUsed / 1024 / 1024).toFixed(2)}m / ${( + mem.heapTotal / + 1024 / + 1024 + ).toFixed(2)}m / ${(mem.rss / 1024 / 1024).toFixed(2)}m`; + }, + false +);