command to view resource limits

merge-requests/4/head
Matthew 2020-05-02 02:34:40 -04:00
parent 2414c2aa6a
commit 637c01ae49
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 31 additions and 0 deletions

31
src/commands/limits.ts Normal file
View File

@ -0,0 +1,31 @@
import { Message } from 'eris';
import { Command, RichEmbed } from '../class';
import { dataConversion } from '../functions';
import { Client } from '..';
export default class SetLimit extends Command {
constructor(client: Client) {
super(client);
this.name = 'limits';
this.description = 'Views resource limits for each tier.';
this.usage = `${this.client.config.prefix}limits`;
this.subcmds = [];
this.enabled = true;
}
public async run(message: Message) {
try {
const tiers = await this.client.db.Tier.find();
const embed = new RichEmbed();
embed.setTitle('Resource Limit Information');
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
for (const tier of tiers.sort((a, b) => a.id - b.id)) {
embed.addField(`Tier ${tier.id}`, `**RAM:** ${dataConversion(tier.resourceLimits?.ram * 1024 * 1024) ?? '0 B'}\n**Storage:** ${dataConversion(tier.resourceLimits?.storage * 1024 * 1024) ?? '0 B'}`);
}
return message.channel.createMessage({ embed });
} catch (error) {
return this.client.util.handleError(error, message, this);
}
}
}