From 18c7f1d0718ef21880802a06a32e9a898b309e7a Mon Sep 17 00:00:00 2001 From: Matthew R Date: Tue, 29 Dec 2020 19:21:43 -0500 Subject: [PATCH] fixes for site cmd --- src/commands/site.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/commands/site.ts b/src/commands/site.ts index 8f66c82..774ee9f 100644 --- a/src/commands/site.ts +++ b/src/commands/site.ts @@ -145,11 +145,21 @@ export default class SiteInfo extends Command { loading.delete().catch(() => {}); return this.error(message.channel, 'Unable to receive information.'); } - - const browser = await puppeteer.launch(); - const page = await browser.newPage(); - await page.goto(`https://${args[0]}`); - const screenshotData = await page.screenshot(); + let screenshotData: string; + try { + const browser = await puppeteer.launch({ + ignoreHTTPSErrors: true, + args: [ + '--ignore-certificate-errors', + '--ignore-certificate-errors-spki-list', + ], + }); + const page = await browser.newPage(); + await page.goto(`https://${args[0]}`); + screenshotData = await page.screenshot(); + } catch (e) { + this.client.util.signale.error(e); + } embeds.forEach((embed) => { embed.setAuthor(author.name, author.icon, author.url); embed.setColor('#4870fe'); @@ -157,8 +167,11 @@ export default class SiteInfo extends Command { embed.setTimestamp(); }); - if (embeds.length === 1) return message.channel.createMessage({ embed: embeds[0] }, { name: 'img.png', file: screenshotData }); - await message.channel.createMessage('', { name: 'img.png', file: screenshotData }); + if (screenshotData) { + if (embeds.length === 1) return message.channel.createMessage({ embed: embeds[0] }, { name: 'img.png', file: screenshotData }); + } else { + await message.channel.createMessage('', { name: 'img.png', file: screenshotData }); + } loading.delete().catch(() => {}); return await createPaginationEmbed(message, embeds, { cycling: true,