fix memory checking issue

merge-requests/4/head
Matthew 2020-03-29 05:33:43 -04:00
parent 4ca2e9b188
commit 271cfe1959
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 64 additions and 58 deletions

View File

@ -15,15 +15,18 @@ export const memoryLimits = {
export default function memory(client: Client) { export default function memory(client: Client) {
setInterval(async () => { setInterval(async () => {
try {
const accounts = await client.db.Account.find(); const accounts = await client.db.Account.find();
console.log(accounts); console.log(accounts);
for (const acc of accounts) { for (const acc of accounts) {
console.log(acc); console.log(acc);
if (acc.root) return; if (acc.root === true) return;
// memory in bytes // memory in bytes
const mem = Number(await client.util.exec(`memory ${acc.username}`)) * 1000; const mem = Number(await client.util.exec(`memory ${acc.username}`)) * 1000;
console.log(mem);
// memory in megabytes // memory in megabytes
const memoryConversion = mem / 1024 / 1024; const memoryConversion = mem / 1024 / 1024;
console.log(memoryConversion);
let userLimits: { soft: number, hard: number }; let userLimits: { soft: number, hard: number };
if (acc.tier === 1) { if (acc.tier === 1) {
userLimits = { soft: memoryLimits.TIER_1_SOFT, hard: memoryLimits.TIER_1_HARD }; userLimits = { soft: memoryLimits.TIER_1_SOFT, hard: memoryLimits.TIER_1_HARD };
@ -76,5 +79,8 @@ export default function memory(client: Client) {
client.createMessage(channelID, { embed }); client.createMessage(channelID, { embed });
} }
} }
} catch (err) {
client.util.handleError(err);
}
}, 60000); }, 60000);
} }