fixes for site cmd

pull/29/head
Matthew 2020-12-29 19:21:43 -05:00
parent 97859b4044
commit 18c7f1d071
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 20 additions and 7 deletions

View File

@ -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,