forked from engineering/cloudservices
commands to set resource limits
parent
637c01ae49
commit
84cf60069f
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue