import { Message } from 'eris'; import { Command, RichEmbed } from '../class'; import { Client } from '..'; export default class Limits_SetRAMNotification extends Command { constructor(client: Client) { super(client); this.name = 'set-ram-notification'; this.description = 'Sets your personal perference for receiving RAM resource limit notifications. Set the limit to "-1" to disable notifications.'; this.usage = `${this.client.config.prefix}limits set-ram-notification `; this.enabled = true; } public async run(message: Message, args: string[]) { try { const account = await this.client.db.Account.findOne({ userID: message.author.id }); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} You do not have a Cloud Account.***`); const tier = await this.client.db.Tier.findOne({ id: account.tier }); if (Number(args[0]) >= tier.resourceLimits.ram) return message.channel.createMessage(`***${this.client.stores.emojis.error} You cannot set your notification limit to be set to or above your hard limit.***`); if ((Number(args[0]) < 1) && (Number(args[0]) !== -1)) return message.channel.createMessage(`***${this.client.stores.emojis.error} You cannot set your notification limit to a negative number.***`); if (Number(args[0]) === -1) { await account.updateOne({ $set: { ramLimitNotification: -1 } }); return message.channel.createMessage(`***${this.client.stores.emojis.success} You have disabled notifications.***`); } await account.updateOne({ $set: { ramLimitNotification: Number(args[0]) } }); return message.channel.createMessage(`***${this.client.stores.emojis.success} You will now receive notifications when you go above ${Number(args[0])} MB.***`); } catch (error) { return this.client.util.handleError(error, message, this); } } }