【发布时间】:2021-10-07 00:09:11
【问题描述】:
我正在制作一个不和谐的机器人,我正在尝试将数据保存在我的机器人始终可以访问的私人服务器中。现在我已经完成了保存和加载功能,唯一的问题是,我什么时候保存?我可以每分钟在频道中发送数据,但这会给频道发送太多垃圾邮件。我想知道是否有更有效的方法来做到这一点。
也就是说,是否有可能检测到 heroku 平台将开始循环,所以我可以让机器人在开始循环过程之前保存数据 - 有没有 heroku 提供的方法来做到这一点? (或者,也可以跟踪 heroku 循环的时间)
bot.js的一部分:
// backup when start
client.on('ready',()=>{
console.log(`${client.user.tag} ready!`);
client.channels.fetch(dataChannelId)
.then(channel => {
dataChannel = channel;
console.log(dataChannel.id);
dataBackup(true);
});
});
// save - when?
dataSave(mainChannel, currentQuestionAns, currentQuestionReward, currentQuestionMessage, miliheads);
【问题讨论】:
标签: node.js heroku discord.js