javascript - Discord.js/Cron - 在特定时间发送多条消息
问题描述
我希望我的机器人在一天中的特定时间以特定延迟发送特定数量的消息,并每天不断重复。我知道这涉及到 Cron 的使用,但我在实现它时遇到了一些困难。
const Discord = require('discord.js');
const bot = new Discord.Client();
const reactionEmoji = message.guild.emojis.cache.find(emoji => emoji.name === '7c2gaheiowu31compressed');
const clientPY = '7xxx45076137459732'
bot.on('message', (message) => {
const mentionedMembersCollection = message.mentions.members;
if (message.content.includes('play') || message.content.includes('time')) {
message.react(reactionEmoji);
const reply = ['No', 'You know? you will get sick', 'You really should stop']
const show = reply[Math.floor(Math.random() * reply.length)];
message.send(show)
}
if (mentionedMembersCollection.has('4xxx56331777245185') ||
mentionedMembersCollection.has('70xxx2119722278943')) {
if (message.author.id === clientPY) {
message.channel.send('hello')
}
}
});
bot.login('ODI1MTxxxxxxxx1NzI4.YF5FAg.3bim466DN7HT_Ixxxxxxxxxxx');
解决方案
推荐阅读
- rfo - 如何修改或替换 PBEwithMD5AndDes
- c++ - 使向量的类型任意
- git - VS 2019 克隆 Git 因致命错误而失败。未找到存储库
- reactjs - 在页面转换上存储滚动位置
- javascript - 如何在 JavaScript 中使用 push() 或类似方法作为函数参数
- r - 将一串变量粘贴到函数中不起作用
- android - 如何在 air sdkharman 上加载本地 html
- javascript - javascript将数据流式传输到网页的最佳实践是什么?
- python - smtplib 电子邮件不发送,脚本继续运行,没有错误消息
- postgresql - 自定义聚合函数 parallel = safe 在 postgres 13.3 中生成语法