我想截图webiste和那个截图发送的消息不一致时,命令运行。我搞砸了,不知道该怎么办
const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require("discord.js");
const fetch = require('node-fetch');
const cheerio = require("cheerio");
const puppeteer = require('puppeteer');
module.exports = class LinkCommand extends BaseCommand {
constructor() {
super('link', 'fun', []);
}
async run(client, message, args) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.hltv.org/team/5995/g2#tab-matchesBox');
console.log(await page.content());
await page.screenshot({path: 'screenshot.png'});
await browser.close();
message.channel.send(`${screenshot} je`)
}
}
如果您没有指定puppeteer的路径,映像将作为二进制数据(源)返回,可以直接发送(请参见DiscordJS'fileOptions):
let screenshot = await page.screenshot();
await browser.close();
message.channel.send("Screenshot", {files: [screenshot]});