2017-09-14 15:09:43 +03:00
|
|
|
const DiscordUtil = require("../../discord-bot-core").util;
|
2017-09-25 00:46:58 +03:00
|
|
|
const Core = require("../../discord-bot-core");
|
2017-09-20 02:04:04 +03:00
|
|
|
const FeedData = require("./feed-data.js");
|
2017-09-01 17:51:05 +03:00
|
|
|
|
2017-10-02 01:19:10 +03:00
|
|
|
module.exports = class GuildData extends Core.BaseGuildData {
|
2017-12-07 03:35:00 +02:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.feeds = [FeedData];
|
2017-09-20 02:04:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cachePastPostedLinks(guild) {
|
|
|
|
const promises = [];
|
|
|
|
|
2017-11-15 00:27:58 +02:00
|
|
|
this.feeds.forEach(feed => {
|
|
|
|
if (guild.channels.get(feed.channelID))
|
|
|
|
promises.push(
|
|
|
|
feed.updatePastPostedLinks(guild)
|
|
|
|
.catch(err => DiscordUtil.dateError(`Error reading history in channel ${feed.channelID}: ${err.message || err}`)));
|
|
|
|
});
|
2017-09-20 02:04:04 +03:00
|
|
|
|
|
|
|
return Promise.all(promises);
|
|
|
|
}
|
|
|
|
|
2017-10-02 02:52:36 +03:00
|
|
|
checkFeeds(guild) {
|
2017-11-15 00:27:58 +02:00
|
|
|
this.feeds.forEach(feed => {
|
|
|
|
if (guild.channels.get(feed.channelID))
|
|
|
|
feed.fetchLatest(guild);
|
|
|
|
});
|
2017-09-01 17:51:05 +03:00
|
|
|
}
|
|
|
|
};
|