27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { Message } from 'eris';
|
|
import { Client, Command } from '../class';
|
|
|
|
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 this.error(message.channel, 'The tier you provided doesn\'t appear to exist.');
|
|
if (Number.isNaN(Number(args[1]))) return this.error(message.channel, 'Invalid number in limit argument.');
|
|
await tier.updateOne({ 'resourceLimits.ram': Number(args[1]) });
|
|
return this.success(message.channel, `Tier ${tier.id} RAM resource limit set to ${args[1]} MB.`);
|
|
} catch (error) {
|
|
return this.client.util.handleError(error, message, this);
|
|
}
|
|
}
|
|
}
|