有没有办法添加命令,以便机器人每天在服务器上的自定义频道中发送此命令? 用于 CS:GO 比赛统计
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();
}
}
我想要做的是设置命令,让机器人每天在不和谐服务器上的自定义频道中发送消息
答案 0 :(得分:1)
我知道了
setInterval(() => {
message.channel.send(`${today}`, {files: [screenshot]});
message.delete();
}, 60000);
最后 60000 是毫秒,只需将其更改为 24h 到毫秒和繁荣:D