discord-bot-rss-feed/app/models/guild-data.js
benji7425 b3deb2a640 Refactor multiple areas for simplicity and readability
This is a squash commit of many commits
2017-10-01 23:20:06 +01:00

27 lines
686 B
JavaScript

const DiscordUtil = require("../../discord-bot-core").util;
const Core = require("../../discord-bot-core");
const FeedData = require("./feed-data.js");
module.exports = class GuildData extends Core.BaseGuildData {
constructor({ id, feeds = [] }) {
super(id);
this.feeds = feeds.map(feed => new FeedData(feed));
}
cachePastPostedLinks(guild) {
const promises = [];
this.feeds.forEach(feed =>
promises.push(
feed.updatePastPostedLinks(guild)
.catch(err => DiscordUtil.dateError(`Error reading history in ${err.path}`))
)
);
return Promise.all(promises);
}
checkFeeds(guilds) {
this.feeds.forEach(feed => feed.fetchLatest(guilds.get(this.id)));
}
};