From b0239282f47ab891a326a2149963228f38204ca7 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 4 Jul 2020 23:44:49 -0400 Subject: [PATCH] add info cmd --- src/commands/index.ts | 1 + src/commands/info.ts | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/commands/info.ts diff --git a/src/commands/index.ts b/src/commands/index.ts index 029babf..0f7f9a9 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -8,6 +8,7 @@ export { default as emailcode } from './emailcode'; export { default as eval } from './eval'; export { default as exec } from './exec'; export { default as help } from './help'; +export { default as info } from './info'; export { default as limits } from './limits'; export { default as load } from './load'; export { default as lock } from './lock'; diff --git a/src/commands/info.ts b/src/commands/info.ts new file mode 100644 index 0000000..6682aca --- /dev/null +++ b/src/commands/info.ts @@ -0,0 +1,39 @@ +import { Message } from 'eris'; +import { totalmem } from 'os'; +import { Client, Command, RichEmbed } from '../class'; +import { version as erisVersion } from '../../node_modules/eris/package.json'; +import { version as expressVersion } from '../../node_modules/express/package.json'; +import { version as mongooseVersion } from '../../node_modules/mongoose/package.json'; +import { version as ioredisVersion } from '../../node_modules/ioredis/package.json'; +import { version as tscVersion } from '../../node_modules/typescript/package.json'; + +export default class Info extends Command { + constructor(client: Client) { + super(client); + this.name = 'info'; + this.description = 'Provides information about CSD.'; + this.usage = `${this.client.config.prefix}info`; + this.enabled = true; + } + + public async run(message: Message) { + try { + const embed = new RichEmbed(); + embed.setTitle('Information'); + embed.setThumbnail(this.client.user.avatarURL); + embed.addField('Language(s)', '<:ts:604565354554982401> TypeScript, <:Go:703449475405971466> Go', true); + embed.addField('Runtime', `Node (${process.version})`, true); + embed.addField('Compilers/Transpilers', `TypeScript [tsc] (${tscVersion}) | Go [gc] (${await this.client.util.exec('go version')})`, true); + embed.addField('Process Manager', `SystemD (${await this.client.util.exec('systemd --version')})`, true); + embed.addField('Discord Library', `Eris (${erisVersion})`, true); + embed.addField('HTTP Server Library', `Express (${expressVersion})`, true); + embed.addField('Database Library', `MongoDB w/ Mongoose ODM (${mongooseVersion})`, true); + embed.addField('Cache Library', `Redis w/ IORedis (${ioredisVersion})`, true); + embed.addField('Memory Usage', `${Math.round(process.memoryUsage().rss / 1024 / 1024)} MB / ${Math.round(totalmem() / 1024 / 1024 / 1024)} GB`, true); + embed.addField('Repository', 'https://loc.sh/csdgit | Licensed under GNU Affero General Public License V3', true); + return message.channel.createMessage({ embed }); + } catch (err) { + return this.client.util.handleError(err, message, this); + } + } +}