multiple changes to memory notification handling
parent
7897ff2165
commit
3985b0c3aa
|
@ -33,7 +33,9 @@ export default function memory(client: Client) {
|
|||
const tier: TierInterface = await client.db.Tier.findOne({ id: acc.tier }).lean().exec();
|
||||
userLimits.soft = tier.resourceLimits.ram - 50;
|
||||
userLimits.hard = tier.resourceLimits.ram + 10;
|
||||
|
||||
if (memoryConversion <= userLimits.soft) {
|
||||
set.delete(acc.username);
|
||||
}
|
||||
/* if the user has exceeded their soft memory limit, which is the one described in the
|
||||
resource limit guidelines, we'll inform staff.
|
||||
*/
|
||||
|
@ -77,17 +79,18 @@ export default function memory(client: Client) {
|
|||
embed.setFooter(client.user.username, client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
await client.createMessage(channelID, { embed });
|
||||
if (memoryConversion >= acc.ramLimitNotification) {
|
||||
if (acc.ramLimitNotification === -1) return;
|
||||
const notifyEmbed = new RichEmbed()
|
||||
.setTitle('Cloud Account | Notification')
|
||||
.setDescription(`You are about to reach your RAM resource limits, you are currently using '${String(memoryConversion)} MB' and your limit is '${String(userLimits.hard)} MB'. Please correct your usage to avoid further action.`)
|
||||
.setDescription(`You are about to reach your RAM resource limits, you are currently using '${String(memoryConversion)} MB' and your limit is '${String(userLimits.hard)} MB'. Please correct your usage to avoid further action.\nYou can set your notification preferences by running \`=limits set-ram-notification <preferred ram threshold in MB>\`, you can disable these notifications by running \`=limits set-ram-notification -1\`.`)
|
||||
.addField('User', `${acc.username} | <@${acc.userID}>`, true)
|
||||
.addField('Technician', 'SYSTEM', true)
|
||||
.setFooter(client.user.username, client.user.avatarURL)
|
||||
.setTimestamp();
|
||||
client.getDMChannel(acc.userID).then((channel) => {
|
||||
channel.createMessage({ embed: notifyEmbed });
|
||||
});
|
||||
notifyEmbed.addField('User', `${acc.username} | <@${acc.userID}>`, true);
|
||||
client.createMessage('580950455581147146', { embed });
|
||||
client.util.transport.sendMail({
|
||||
to: acc.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
|
@ -100,6 +103,8 @@ export default function memory(client: Client) {
|
|||
<b><i>Library of Code sp-us | Support Team</i></b>
|
||||
`,
|
||||
});
|
||||
}
|
||||
client.createMessage('580950455581147146', { embed });
|
||||
set.add(acc.username);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue