diff --git a/src/commands/setlimit.ts b/src/commands/setlimit.ts new file mode 100644 index 0000000..741e63c --- /dev/null +++ b/src/commands/setlimit.ts @@ -0,0 +1,23 @@ +import { Message } from 'eris'; +import { Command } from '../class'; +import { Client } from '..'; + +export default class SetLimit extends Command { + constructor(client: Client) { + super(client); + this.name = 'setlimit'; + this.description = 'Sets resource limits for the various tiers'; + this.usage = `Run ${this.client.config.prefix}${this.name} [subcommand] for usage information`; + this.permissions = { roles: ['662163685439045632'] }; + this.subcmds = []; + this.enabled = true; + } + + public async run(message: Message) { + try { + return this.client.commands.get('help').run(message, [this.name]); + } catch (error) { + return this.client.util.handleError(error, message, this); + } + } +} diff --git a/src/commands/setlimit_ram.ts b/src/commands/setlimit_ram.ts new file mode 100644 index 0000000..10f47c2 --- /dev/null +++ b/src/commands/setlimit_ram.ts @@ -0,0 +1,27 @@ +import { Message } from 'eris'; +import { Command } from '../class'; +import { Client } from '..'; + +export default class SetLimit_RAM extends Command { + constructor(client: Client) { + super(client); + this.name = 'ram'; + this.description = 'Sets tier limits for RAM.'; + this.usage = `${this.client.config.prefix}setlimit ram `; + this.permissions = { roles: ['662163685439045632'] }; + this.enabled = true; + } + + public async run(message: Message, args: string[]) { + try { + if (!args[0]) return this.client.commands.get('help').run(message, ['setlimit', this.name]); + const tier = await this.client.db.Tier.findOne({ id: Number(args[0]) }); + if (!tier) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot locate that tier.***`); + if (Number.isNaN(Number(args[1]))) return message.channel.createMessage(`***${this.client.stores.emojis.error} This is not a valid number.***`); + await tier.updateOne({ 'resourceLimits.ram': Number(args[1]) }); + return message.channel.createMessage(`***${this.client.stores.emojis.success} Tier ${tier.id} RAM resource limit set to ${args[1]} MB.***`); + } catch (error) { + return this.client.util.handleError(error, message, this); + } + } +}