Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices-rewrite
commit
17572da752
|
@ -22,7 +22,6 @@ export default class CWG_Data extends Command {
|
|||
if (!args[0]) return this.client.commands.get('help').run(message, ['cwg', this.name]);
|
||||
const dom = await this.client.db.Domain.find({ $or: [{ domain: args[0] }, { port: Number(args[0]) || '' }] });
|
||||
if (!dom.length) return message.channel.createMessage(`***${this.client.stores.emojis.error} The domain or port you provided could not be found.***`);
|
||||
// const embeds: RichEmbed[] = [];
|
||||
const embeds = dom.map((domain) => {
|
||||
const cert = fs.readFileSync(domain.x509.cert, { encoding: 'utf8' });
|
||||
const embed = new RichEmbed();
|
||||
|
|
|
@ -18,6 +18,7 @@ export default class Disk extends Command {
|
|||
|
||||
async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }, { emailAddress: args[0] }] });
|
||||
if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`);
|
||||
if (account.root || args[0].includes('./')) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Permission denied***`);
|
||||
|
@ -30,8 +31,8 @@ export default class Disk extends Command {
|
|||
const embed = new RichEmbed();
|
||||
embed.setTitle('Disk Usage');
|
||||
embed.setColor('ff0000');
|
||||
embed.setDescription(`/home/${account.username}`);
|
||||
embed.addField('Result', dataConversion(Number(result)), true);
|
||||
embed.setDescription(result.split(/ +/g)[1]);
|
||||
embed.addField('Result', dataConversion(Number(result.split(/ +/g)[0])), true);
|
||||
embed.addField('Time taken', totalTime, true);
|
||||
embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL);
|
||||
embed.setTimestamp();
|
||||
|
|
|
@ -10,6 +10,7 @@ export { default as Lock } from './lock';
|
|||
export { default as Modlogs } from './modlogs';
|
||||
export { default as Notify } from './notify';
|
||||
export { default as Parse } from './parse';
|
||||
export { default as Parseall } from './parseall';
|
||||
export { default as Ping } from './ping';
|
||||
export { default as Pull } from './pull';
|
||||
export { default as Sysinfo } from './sysinfo';
|
||||
|
|
|
@ -21,7 +21,8 @@ export default class Modlogs extends Command {
|
|||
const query = await this.client.db.Moderation.find({ $or: [{ username: args.join(' ') }, { userID: args.filter((a) => a)[0].replace(/[<@!>]/g, '') }] });
|
||||
if (!query.length) return msg.edit(`***${this.client.stores.emojis.error} Cannot locate modlogs for ${args.join(' ')}***`);
|
||||
|
||||
const formatted = query.map((log) => {
|
||||
// @ts-ignore
|
||||
const formatted = query.sort((a, b) => a.date - b.date).map((log) => {
|
||||
const { username, moderatorID, reason, type, date } = log;
|
||||
let name: string;
|
||||
switch (type) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
import { parseCert } from '@ghaiklor/x509';
|
||||
import { Message } from 'eris';
|
||||
import { readdirSync } from 'fs';
|
||||
import moment from 'moment';
|
||||
import { Client } from '..';
|
||||
import { Command, RichEmbed } from '../class';
|
||||
|
||||
export default class Parseall extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
|
||||
this.name = 'parseall';
|
||||
this.description = 'Displays certificate validation for all accounts';
|
||||
this.usage = `${this.client.config.prefix}parseall`;
|
||||
this.permissions = { roles: ['446104438969466890'] };
|
||||
this.aliases = ['checkcerts', 'verifyall', 'verifycerts'];
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Certificate Validation');
|
||||
embed.setAuthor(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setFooter(`Requested by ${message.member.username}#${message.member.discriminator}`, message.member.avatarURL);
|
||||
embed.setTimestamp();
|
||||
const search = await this.client.db.Account.find();
|
||||
const accounts = search.map((acc) => acc.username);
|
||||
const final: string[] = [];
|
||||
|
||||
accounts.forEach(async (a) => {
|
||||
try {
|
||||
const certFile = readdirSync(`/home/${a}/Validation`)[0];
|
||||
const { notAfter } = parseCert(`/home/${a}/Validation/${certFile}`);
|
||||
// @ts-ignore
|
||||
const time = moment.preciseDiff(new Date(), notAfter);
|
||||
|
||||
if (notAfter < new Date()) final.push(`${this.client.stores.emojis.error} **${a}** Certificate expired ${time} ago`);
|
||||
else final.push(`${this.client.stores.emojis.success} **${a}** Certificate expires in ${time}`);
|
||||
} catch (error) {
|
||||
if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) final.push(`${this.client.stores.emojis.error} **${a}** Unable to locate certificate`);
|
||||
else throw error;
|
||||
}
|
||||
});
|
||||
|
||||
if (final.join('\n').length < 2048) embed.setDescription(final.join('\n'));
|
||||
else {
|
||||
const split = this.client.util.splitString(final.join('\n'), 1024);
|
||||
split.forEach((s) => embed.addField('\u200B', s));
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return await message.channel.createMessage({ embed });
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue