1
0
Fork 0

fix memory checking issue

refactor/models
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) {
setInterval(async () => {
try {
const accounts = await client.db.Account.find();
console.log(accounts);
for (const acc of accounts) {
console.log(acc);
if (acc.root) return;
if (acc.root === true) return;
// 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 };
@ -76,5 +79,8 @@ export default function memory(client: Client) {
client.createMessage(channelID, { embed });
}
}
} catch (err) {
client.util.handleError(err);
}
}, 60000);
}