I'm trying to make a discord bot that takes a screenshot of a specific website(here I'm just using google for example) and send it through discord by command. for some reason it's not working and I'm not sure what I'm doing wrong here. I'm also fairly new to node.js and discord.js. I have created a seperate file for all commands and here is the one with puppeteer:
const pupp = require('puppeteer');
module.exports = {
name: 'pup',
description:'send image',
execute(client, message, args, Discord){
(async () => {
const browser = await pupp.launch();
const page = await browser.newPage();
await page.goto('https://www.google.com');
let screenshot = await page.screenshot({ path: 'screenshot.png' });
await browser.close();
message.channel.send("screenshot",{files: [screenshot]});
})();
}
}
and here is my main.js code:
const Discord = require('discord.js');
const token = 'TOKEN';
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
['commands_handler','events_handler'].forEach(handler =>{
require(`./handlers/${handler}`)(client, Discord);
})
client.login(token);