MCPcopy Create free account
hub / github.com/esmBot/esmBot / getMem

Method getMem

commands/general/stats.js:109–134  ·  view source on GitHub ↗

* @returns {Promise }

()

Source from the content-addressed store, hash-verified

107 * @returns {Promise<string | null>}
108 */
109 getMem() {
110 if (process.env.CLUSTER_TYPE === "node") {
111 return new Promise((resolve, reject) => {
112 const listener = (/** @type {{ data: { type: string; totalMem: number; }; }} */ message) => {
113 if (message.data?.type === "memResponse") {
114 clearTimeout(timeout);
115 const value = message.data.totalMem / 1000 / 1000;
116 resolve(`${value.toFixed(2)} MB`);
117 process.off("message", listener);
118 }
119 };
120 process.on("message", listener);
121 const timeout = setTimeout(() => {
122 process.off("message", listener);
123 reject("Timed out");
124 }, 3000);
125 process.send?.({
126 data: {
127 type: "getMem",
128 },
129 });
130 });
131 } else {
132 return Promise.resolve(null);
133 }
134 }
135
136 static description = "Gets some statistics about me";
137 static aliases = ["status", "stat"];

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected