cloudservices/src/commands/info.ts

40 lines
2.2 KiB
TypeScript

import { Message, MessageEmbed } from 'discord.js';
import { totalmem } from 'os';
import { Client, Command } from '../class';
import { version as discordjsVersion } from '../../node_modules/discord.js/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 MessageEmbed();
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')).split('\n')[0]})`, true);
embed.addField('Discord Library', `Discord.js (${discordjsVersion})`, 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.send({ embeds: [embed] });
} catch (err) {
return this.client.util.handleError(err, message, this);
}
}
}