From 637c01ae49e4857e0cc07d59d052e45bc2096061 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 2 May 2020 02:34:40 -0400 Subject: [PATCH] command to view resource limits --- src/commands/limits.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/commands/limits.ts diff --git a/src/commands/limits.ts b/src/commands/limits.ts new file mode 100644 index 0000000..78bd292 --- /dev/null +++ b/src/commands/limits.ts @@ -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); + } + } +}