1
0
Fork 0

fix bug with cwg_data

master
Matthew 2022-07-16 03:01:39 -04:00
parent 5bf3425ee0
commit 84a539c65a
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 11 additions and 5 deletions

View File

@ -8,7 +8,7 @@ export default class CWG_Data extends Command {
super(client); super(client);
this.name = 'data'; this.name = 'data';
this.description = 'Check CWG data'; this.description = 'Check CWG data';
this.usage = `${this.client.config.prefix}cwg data [Domain | Port]`; this.usage = `${this.client.config.prefix}cwg data <Domain | Port>`;
this.permissions = { roles: ['662163685439045632', '701454780828221450'] }; this.permissions = { roles: ['662163685439045632', '701454780828221450'] };
this.enabled = true; this.enabled = true;
} }
@ -29,7 +29,13 @@ export default class CWG_Data extends Command {
return this.error(message.channel, 'The domain or port you provided could not be found.'); return this.error(message.channel, 'The domain or port you provided could not be found.');
} }
const embeds = await Promise.all(dom.map(async (domain) => { const embeds = await Promise.all(dom.map(async (domain) => {
const pem = fs.readFileSync(domain.x509.cert, { encoding: 'utf8' }); let pem: string;
try {
pem = fs.readFileSync(domain.x509.cert, { encoding: 'utf8' });
} catch {
pem = fs.readFileSync('/etc/ssl/private/cloud-libraryofcode-org.chain.crt', { encoding: 'utf8' });
}
const cert = await this.client.util.parseCertificate(pem); const cert = await this.client.util.parseCertificate(pem);
const embed = new MessageEmbed(); const embed = new MessageEmbed();
embed.setTitle('Domain Information'); embed.setTitle('Domain Information');
@ -37,9 +43,9 @@ export default class CWG_Data extends Command {
embed.addField('Account ID', domain.account.userID, true); embed.addField('Account ID', domain.account.userID, true);
embed.addField('Domain', domain.domain, true); embed.addField('Domain', domain.domain, true);
embed.addField('Port', String(domain.port), true); embed.addField('Port', String(domain.port), true);
embed.addField('Certificate Issuer', cert.issuer.organization[0], true); embed.addField('Certificate Issuer', `${cert.issuer.organization[0]} (${cert.issuer.commonName})` || 'N/A', true);
embed.addField('Certificate Subject', cert.issuer.commonName, true); embed.addField('Certificate Subject', cert.subject.commonName || 'N/A', true);
embed.addField('Certificate Expiration Date', moment(cert.notAfter).format('dddd, MMMM Do YYYY, h:mm:ss A'), true); embed.addField('Certificate Expiration Date', cert.notAfter ? moment(cert.notAfter).format('dddd, MMMM Do YYYY, h:mm:ss A') || 'N/A' : 'N/A', true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setFooter(this.client.user.username, this.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();
return embed; return embed;