L Z
L Z

Reputation: 59

Is there a way to msg this daily ? Discord.Js

Is there a way to add command so bot will message this command everday in custom channel on server? Its for CS:GO Matches statistics

const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require("discord.js");
const puppeteer = require('puppeteer');


module.exports = class LinkCommand extends BaseCommand {
  constructor() {
    super('mec', 'fun', []);
  }

  async run(client, message, args) {
    const browser = await puppeteer.launch({defaultViewport: null});

    const page = await browser.newPage();
    await page.setViewport({
      width: 1920,
      height: 1080,
      deviceScaleFactor: 1,
    });
    
    await page.setDefaultNavigationTimeout(0);
    await page._client.send('Network.getAllCookies');
    await page.goto('https://pro.eslgaming.com/csgo/proleague/schedule/#?matchday=2');
    
    console.log(await page.content());
    await page.screenshot({path: 'screenhhhhshot.png'});
    
    let screenshot = await page.screenshot(); 
await browser.close();

let today = new Date().toISOString().slice(0, 10)


message.channel.send(`${today}`, {files: [screenshot]});
message.delete();
    }
    
  }

What i want to do like to set command that will everyday make bot to send message in custom channel on discord server

Upvotes: 0

Views: 157

Answers (1)

L Z
L Z

Reputation: 59

I got it

setInterval(() => {
message.channel.send(`${today}`, {files: [screenshot]});
message.delete();
}, 60000);

at the end 60000 is milliseconds just change that to 24h into milliseconds and boom :D

Upvotes: 1

Related Questions