From 2e1bf68cc077cccdcb654730fabc418c7fc25ce8 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 13:18:22 +0000 Subject: [PATCH 01/16] Correct placement --- src/commands/parseall.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index d33da59..bd2fe86 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -37,9 +37,9 @@ export default class Parseall extends Command { return parseCertificate(this.client, `${a.homepath}/Validation/${certFile}`); }); - const parsed = await Promise.all(certificates); - const final = search.map((a) => { + const final = search.map(async (a) => { try { + const parsed = await Promise.all(certificates); const { notAfter } = parsed[search.findIndex((acc) => acc === a)]; // @ts-ignore const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true); From 350e5c021de91690e54ef06b45bf57c5eebc9b88 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 13:47:54 +0000 Subject: [PATCH 02/16] Use Promise.allSettled --- src/commands/parseall.ts | 45 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index bd2fe86..755b981 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -4,7 +4,7 @@ import { readdirSync } from 'fs'; import moment from 'moment'; import { Client } from '..'; import { Command, RichEmbed } from '../class'; -import { parseCertificate } from '../functions'; +import { parseCertificate, Certificate } from '../functions'; export default class Parseall extends Command { constructor(client: Client) { @@ -36,30 +36,31 @@ export default class Parseall extends Command { } return parseCertificate(this.client, `${a.homepath}/Validation/${certFile}`); }); + // @ts-ignore + const parsed: {status: 'fulfilled', value: Certificate}[] | {status: 'rejected', reason: Error}[] = await Promise.allSettled(certificates); const final = search.map(async (a) => { - try { - const parsed = await Promise.all(certificates); - const { notAfter } = parsed[search.findIndex((acc) => acc === a)]; - // @ts-ignore - const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true); - const precise: [number, string][] = []; - // @ts-ignore - const timeArray: number[] = Object.values(timeObject).filter((v) => typeof v === 'number'); - timeArray.forEach((t) => { // eslint-disable-line - const index = timeArray.indexOf(t); - const measurements = ['yr', 'mo', 'd', 'h', 'm', 's']; - precise.push([t, measurements[index]]); - }); - const time = precise.filter((n) => n[0]).map(((v) => v.join(''))).join(', '); - - if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; - return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; - } catch (error) { - if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; - if (error.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} ** ${a.username}** Invalid certificate`; - throw error; + const result = parsed[search.findIndex((acc) => acc === a)]; + if (result.status === 'rejected') { + if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; + if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} ** ${a.username}** Invalid certificate`; + throw result.reason; } + const { notAfter } = result.value; + // @ts-ignore + const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true); + const precise: [number, string][] = []; + // @ts-ignore + const timeArray: number[] = Object.values(timeObject).filter((v) => typeof v === 'number'); + timeArray.forEach((t) => { // eslint-disable-line + const index = timeArray.indexOf(t); + const measurements = ['yr', 'mo', 'd', 'h', 'm', 's']; + precise.push([t, measurements[index]]); + }); + const time = precise.filter((n) => n[0]).map(((v) => v.join(''))).join(', '); + + if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; + return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; }); if (final.join('\n').length < 2048) embed.setDescription(final.join('\n')); From dd1dacfe304e0b6422b12cfa358fd7e6919164aa Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 14:06:10 +0000 Subject: [PATCH 03/16] Promises --- src/commands/parseall.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 755b981..97b6428 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -37,10 +37,10 @@ export default class Parseall extends Command { return parseCertificate(this.client, `${a.homepath}/Validation/${certFile}`); }); // @ts-ignore - const parsed: {status: 'fulfilled', value: Certificate}[] | {status: 'rejected', reason: Error}[] = await Promise.allSettled(certificates); + const parsed: Promise<{status: 'fulfilled', value: Certificate}>[] | Promise<{status: 'rejected', reason: Error}>[] = await Promise.allSettled(certificates); const final = search.map(async (a) => { - const result = parsed[search.findIndex((acc) => acc === a)]; + const result = await parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} ** ${a.username}** Invalid certificate`; From 1bae7f52a24868fdd00da57bf4f28908276647d6 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 14:28:20 +0000 Subject: [PATCH 04/16] Solution? --- src/commands/parseall.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 97b6428..7c6a452 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -39,7 +39,7 @@ export default class Parseall extends Command { // @ts-ignore const parsed: Promise<{status: 'fulfilled', value: Certificate}>[] | Promise<{status: 'rejected', reason: Error}>[] = await Promise.allSettled(certificates); - const final = search.map(async (a) => { + const final = await search.map(async (a) => { const result = await parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; From 51b888848f9b5a5cf358ea5f0c9a7b34e90c9a58 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:05:05 +0000 Subject: [PATCH 05/16] Proper solution? --- src/commands/parseall.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 7c6a452..f7a34e8 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -26,24 +26,20 @@ export default class Parseall extends Command { embed.setTimestamp(); const search = await this.client.db.Account.find(); - const certificates = search.map((a) => { - let certFile: string; - try { - certFile = readdirSync(`${a.homepath}/Validation`)[0]; // eslint-disable-line - } catch (error) { - if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) certFile = 'not_found.crt'; - else throw error; - } - return parseCertificate(this.client, `${a.homepath}/Validation/${certFile}`); + const files = search.map((acc) => { + let certfile: string; + try { certfile = readdirSync(`${acc.homepath}/Validation`)[0] } catch (error) { if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) certfile = 'not_found.crt' } // eslint-disable-line + return `${acc.homepath}/Validation/${certfile}`; }); - // @ts-ignore - const parsed: Promise<{status: 'fulfilled', value: Certificate}>[] | Promise<{status: 'rejected', reason: Error}>[] = await Promise.allSettled(certificates); - const final = await search.map(async (a) => { + // @ts-ignore + const parsed = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); + + const final = search.map(async (a) => { const result = await parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; - if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} ** ${a.username}** Invalid certificate`; + if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} **${a.username}** Invalid certificate`; throw result.reason; } const { notAfter } = result.value; From 2558c3e78b32f27326f251dfb1b1acc041c612a8 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:17:03 +0000 Subject: [PATCH 06/16] Diagnosis --- src/commands/parseall.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index f7a34e8..4eec7e4 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -29,14 +29,19 @@ export default class Parseall extends Command { const files = search.map((acc) => { let certfile: string; try { certfile = readdirSync(`${acc.homepath}/Validation`)[0] } catch (error) { if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) certfile = 'not_found.crt' } // eslint-disable-line + this.client.signale.note('Cert directory set:'); + this.client.signale.note(`${acc.homepath}/Validation/${certfile}`); return `${acc.homepath}/Validation/${certfile}`; }); // @ts-ignore const parsed = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); + this.client.signale.note('Promise settled:'); + this.client.signale.note(parsed); const final = search.map(async (a) => { const result = await parsed[search.findIndex((acc) => acc === a)]; + this.client.signale.note(result); if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} **${a.username}** Invalid certificate`; From 4f314051b74e6fb50fde09b0074e4a9185c141f5 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:25:22 +0000 Subject: [PATCH 07/16] Diagnosis --- src/commands/parseall.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 4eec7e4..f14c97f 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -35,19 +35,20 @@ export default class Parseall extends Command { }); // @ts-ignore - const parsed = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); + const parsed: ({ status: 'fulfilled', value: Certificate } | { status: 'rejected', reason: Error })[] = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); this.client.signale.note('Promise settled:'); this.client.signale.note(parsed); const final = search.map(async (a) => { const result = await parsed[search.findIndex((acc) => acc === a)]; - this.client.signale.note(result); if (result.status === 'rejected') { + this.client.signale.info(result.reason); if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} **${a.username}** Invalid certificate`; throw result.reason; } const { notAfter } = result.value; + this.client.signale.info(notAfter); // @ts-ignore const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true); const precise: [number, string][] = []; From 6b2bb7293a2c112cfa451c97ad28957956306044 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:27:58 +0000 Subject: [PATCH 08/16] Diagnosis --- src/commands/parseall.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index f14c97f..8e1158f 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -48,7 +48,6 @@ export default class Parseall extends Command { throw result.reason; } const { notAfter } = result.value; - this.client.signale.info(notAfter); // @ts-ignore const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true); const precise: [number, string][] = []; @@ -60,6 +59,7 @@ export default class Parseall extends Command { precise.push([t, measurements[index]]); }); const time = precise.filter((n) => n[0]).map(((v) => v.join(''))).join(', '); + this.client.signale.info(time); if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; From 542bed168be5e631f6d99ac3f031afa78a42c335 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:28:48 +0000 Subject: [PATCH 09/16] Diagnosis --- src/commands/parseall.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 8e1158f..e593e97 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -29,15 +29,11 @@ export default class Parseall extends Command { const files = search.map((acc) => { let certfile: string; try { certfile = readdirSync(`${acc.homepath}/Validation`)[0] } catch (error) { if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) certfile = 'not_found.crt' } // eslint-disable-line - this.client.signale.note('Cert directory set:'); - this.client.signale.note(`${acc.homepath}/Validation/${certfile}`); return `${acc.homepath}/Validation/${certfile}`; }); // @ts-ignore const parsed: ({ status: 'fulfilled', value: Certificate } | { status: 'rejected', reason: Error })[] = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); - this.client.signale.note('Promise settled:'); - this.client.signale.note(parsed); const final = search.map(async (a) => { const result = await parsed[search.findIndex((acc) => acc === a)]; From 3a40a6cc2ba51f7ebd13d77da6ce1f4cc0c4dd4c Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:30:19 +0000 Subject: [PATCH 10/16] Diagnosis --- src/commands/parseall.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index e593e97..60d9151 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -38,7 +38,6 @@ export default class Parseall extends Command { const final = search.map(async (a) => { const result = await parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { - this.client.signale.info(result.reason); if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} **${a.username}** Invalid certificate`; throw result.reason; @@ -55,11 +54,11 @@ export default class Parseall extends Command { precise.push([t, measurements[index]]); }); const time = precise.filter((n) => n[0]).map(((v) => v.join(''))).join(', '); - this.client.signale.info(time); if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; }); + this.client.signale.info(final); if (final.join('\n').length < 2048) embed.setDescription(final.join('\n')); else { From 198aea79f675031669d7a8560f0cc959b7e9584f Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:34:21 +0000 Subject: [PATCH 11/16] Diagnosis --- src/commands/parseall.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 60d9151..2254abc 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -35,8 +35,9 @@ export default class Parseall extends Command { // @ts-ignore const parsed: ({ status: 'fulfilled', value: Certificate } | { status: 'rejected', reason: Error })[] = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); - const final = search.map(async (a) => { - const result = await parsed[search.findIndex((acc) => acc === a)]; + // @ts-ignore + const final: string[] = await Promise.allSettled(search.map(async (a) => { + const result = parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; if (result.reason.message.includes('panic: Certificate PEM Encode == nil')) return `${this.client.stores.emojis.error} **${a.username}** Invalid certificate`; @@ -57,7 +58,7 @@ export default class Parseall extends Command { if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; - }); + })); this.client.signale.info(final); if (final.join('\n').length < 2048) embed.setDescription(final.join('\n')); From dee2e6a82029c951e4a9877550478d400b94f0e5 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:37:37 +0000 Subject: [PATCH 12/16] FINALLY --- src/commands/parseall.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 2254abc..712542c 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -36,7 +36,7 @@ export default class Parseall extends Command { const parsed: ({ status: 'fulfilled', value: Certificate } | { status: 'rejected', reason: Error })[] = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); // @ts-ignore - const final: string[] = await Promise.allSettled(search.map(async (a) => { + const final: {status: 'fulfilled', value: string}[] = await Promise.allSettled(search.map(async (a) => { const result = parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; @@ -59,9 +59,8 @@ export default class Parseall extends Command { if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; })); - this.client.signale.info(final); - if (final.join('\n').length < 2048) embed.setDescription(final.join('\n')); + if (final.map((a) => a.value).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)); From fa5de93c8d338e15d64ad569f4d9f165d05e5161 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:40:00 +0000 Subject: [PATCH 13/16] oop fix --- src/commands/parseall.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 712542c..03598d7 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -60,9 +60,11 @@ export default class Parseall extends Command { return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; })); - if (final.map((a) => a.value).join('\n').length < 2048) embed.setDescription(final.join('\n')); + const result = final.map((a) => a.value); + + if (result.join('\n').length < 2048) embed.setDescription(result.join('\n')); else { - const split = this.client.util.splitString(final.join('\n'), 1024); + const split = this.client.util.splitString(result.join('\n'), 1024); split.forEach((s) => embed.addField('\u200B', s)); } From 9549c99ebb57c9794022c648c8df2452bf3ceeaf Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 15:43:45 +0000 Subject: [PATCH 14/16] no need to use promise.allsettled --- src/commands/parseall.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 03598d7..1aa5fc2 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -35,8 +35,7 @@ export default class Parseall extends Command { // @ts-ignore const parsed: ({ status: 'fulfilled', value: Certificate } | { status: 'rejected', reason: Error })[] = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c))); - // @ts-ignore - const final: {status: 'fulfilled', value: string}[] = await Promise.allSettled(search.map(async (a) => { + const final: string[] = await Promise.all(search.map(async (a) => { const result = parsed[search.findIndex((acc) => acc === a)]; if (result.status === 'rejected') { if (result.reason.message.includes('no such file or directory') || result.reason.message.includes('File doesn\'t exist.')) return `${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`; @@ -59,12 +58,11 @@ export default class Parseall extends Command { if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; })); + this.client.signale.info(final); - const result = final.map((a) => a.value); - - if (result.join('\n').length < 2048) embed.setDescription(result.join('\n')); + if (final.join('\n').length < 2048) embed.setDescription(final.join('\n')); else { - const split = this.client.util.splitString(result.join('\n'), 1024); + const split = this.client.util.splitString(final.join('\n'), 1024); split.forEach((s) => embed.addField('\u200B', s)); } From 56c94a5e33a30525f3f6e09e39dd08d6e5cb82fb Mon Sep 17 00:00:00 2001 From: Bsian Date: Sat, 4 Jan 2020 16:14:08 +0000 Subject: [PATCH 15/16] add loading message --- src/commands/parseall.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/parseall.ts b/src/commands/parseall.ts index 1aa5fc2..65e1531 100644 --- a/src/commands/parseall.ts +++ b/src/commands/parseall.ts @@ -19,6 +19,7 @@ export default class Parseall extends Command { public async run(message: Message, args: string[]) { try { + const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Loading...***`); const embed = new RichEmbed(); embed.setTitle('Certificate Validation'); embed.setAuthor(this.client.user.username, this.client.user.avatarURL); @@ -58,7 +59,6 @@ export default class Parseall extends Command { if (notAfter < new Date()) return `${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`; return `${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`; })); - this.client.signale.info(final); if (final.join('\n').length < 2048) embed.setDescription(final.join('\n')); else { @@ -67,7 +67,7 @@ export default class Parseall extends Command { } // @ts-ignore - return await message.channel.createMessage({ embed }); + return await msg.edit({ content: '', embed }); } catch (error) { return this.client.util.handleError(error, message, this); } From 26e31dece0ed502416279cc84b85477d057c17c9 Mon Sep 17 00:00:00 2001 From: Bsian Date: Sun, 5 Jan 2020 13:27:12 +0000 Subject: [PATCH 16/16] Added system process check --- src/commands/cwg_data.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/cwg_data.ts b/src/commands/cwg_data.ts index f916223..60dad9a 100644 --- a/src/commands/cwg_data.ts +++ b/src/commands/cwg_data.ts @@ -3,7 +3,6 @@ import moment from 'moment'; import x509 from '@ghaiklor/x509'; import { createPaginationEmbed } from 'eris-pagination'; import { Message } from 'eris'; -import { promisify } from 'util'; import { Command, RichEmbed } from '../class'; import { Client } from '..'; @@ -21,7 +20,17 @@ export default class CWG_Data extends Command { try { 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.***`); + if (!dom.length) { + if (!Number.isNaN(Number(args[0]))) { + try { + await this.client.util.exec(`fuser ${args[0]}/tcp`); + return message.channel.createMessage(`***${this.client.stores.emojis.error} The port you provided is being used by a system process.***`); + } catch (error) { + return message.channel.createMessage(`***${this.client.stores.emojis.error} The domain or port you provided could not be found.***`); + } + } + return message.channel.createMessage(`***${this.client.stores.emojis.error} The domain or port you provided could not be found.***`); + } const embeds = dom.map((domain) => { const cert = fs.readFileSync(domain.x509.cert, { encoding: 'utf8' }); const embed = new RichEmbed();