fix memory checking issue

merge-requests/4/head
Matthew 2020-03-29 05:43:40 -04:00
parent 0b08700140
commit 2cec8a45ae
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 2 additions and 7 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable no-continue */
/* eslint-disable no-await-in-loop */
import { Client } from '..';
import { RichEmbed } from '../class';
@ -17,17 +18,12 @@ export default function memory(client: Client) {
setInterval(async () => {
try {
const accounts = await client.db.Account.find();
console.log(accounts);
for (const acc of accounts) {
console.log(acc.username);
console.log(acc.root);
if (acc.root === true) return;
if (acc.root === true) continue;
// memory in bytes
const mem = Number(await client.util.exec(`memory ${acc.username}`)) * 1000;
console.log(mem);
// memory in megabytes
const memoryConversion = mem / 1024 / 1024;
console.log(memoryConversion);
let userLimits: { soft: number, hard: number };
if (acc.tier === 1) {
userLimits = { soft: memoryLimits.TIER_1_SOFT, hard: memoryLimits.TIER_1_HARD };
@ -40,7 +36,6 @@ export default function memory(client: Client) {
/* if the user has exceeded their soft memory limit, which is the one described in the
resource limit guidelines, we'll inform staff.
*/
console.log(memoryConversion, userLimits.soft, userLimits.hard);
if (memoryConversion >= userLimits.soft) {
client.signale.info(`RAM Soft Limit Reached | ${acc.username} | ${memoryConversion}/${userLimits.soft} MB`);
const embed = new RichEmbed();