auto-update ram limit notification threshold on tier change
parent
0182b0af14
commit
9836554be7
|
@ -22,7 +22,12 @@ export default class Tier extends Command {
|
|||
if (Number.isNaN(Number(args[1]))) return edit.edit(`***${this.client.stores.emojis.error} The tier you provided is not a valid number. It should be between 1 and 3.***`);
|
||||
if (Number(args[1]) > 3 || Number(args[1]) < 1) return edit.edit(`***${this.client.stores.emojis.error} You can only choose a Tier between 1 and 3.***`);
|
||||
message.delete();
|
||||
const tier = await this.client.db.Tier.findOne({ id: Number(args[1]) });
|
||||
if (account.ramLimitNotification !== -1) {
|
||||
await account.updateOne({ $set: { tier: Number(args[1]), ramLimitNotification: tier.resourceLimits.ram - 20 } });
|
||||
} else {
|
||||
await account.updateOne({ $set: { tier: Number(args[1]) } });
|
||||
}
|
||||
edit.edit(`***${this.client.stores.emojis.success} Tier for ${account.username} has been changed to ${args[1]}.***`);
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
|
|
|
@ -6,15 +6,26 @@ export default function checkStaffStatus(client: Client) {
|
|||
setInterval(async () => {
|
||||
const accounts = await client.db.Account.find();
|
||||
for (const acc of accounts) {
|
||||
const tier3 = await client.db.Tier.findOne({ id: 3 });
|
||||
|
||||
const user = client.guilds.get('446067825673633794').members.get(acc.userID) || await client.guilds.get('446067825673633794').getRESTMember(acc.userID);
|
||||
if (!acc.permissions.director && user.roles.includes('662163685439045632')) {
|
||||
await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.director': true } });
|
||||
if (acc.ramLimitNotification !== -1) {
|
||||
await client.db.Account.updateOne({ username: acc.username }, { $set: { ramLimitNotification: tier3.resourceLimits.ram - 20 } });
|
||||
}
|
||||
}
|
||||
if (!acc.permissions.technician && user.roles.includes('701454780828221450')) {
|
||||
await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.technician': true } });
|
||||
if (acc.ramLimitNotification !== -1) {
|
||||
await client.db.Account.updateOne({ username: acc.username }, { $set: { ramLimitNotification: tier3.resourceLimits.ram - 20 } });
|
||||
}
|
||||
}
|
||||
if (!acc.permissions.staff && user.roles.includes('446104438969466890')) {
|
||||
await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.staff': true } });
|
||||
if (acc.ramLimitNotification !== -1) {
|
||||
await client.db.Account.updateOne({ username: acc.username }, { $set: { ramLimitNotification: tier3.resourceLimits.ram - 20 } });
|
||||
}
|
||||
}
|
||||
|
||||
if (acc.permissions.director && !user.roles.includes('662163685439045632')) {
|
||||
|
|
Loading…
Reference in New Issue