forked from engineering/cloudservices
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
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 <tier> <limit in MB>`;
|
|
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);
|
|
}
|
|
}
|
|
}
|