discord-bot-rss-feed/app/models/guild-data.js

23 lines
526 B
JavaScript
Raw Normal View History

2017-09-09 22:26:04 +03:00
const FeedData = require("./feed-data.js");
const Util = require("discordjs-util");
2017-09-01 17:51:05 +03:00
module.exports = class GuildData {
2017-09-09 22:26:04 +03:00
constructor({ id, feeds }) {
2017-09-01 17:51:05 +03:00
this.id = id;
this.feeds = (feeds || []).map(feed => new FeedData(feed));
2017-09-09 22:26:04 +03:00
}
cachePastPostedLinks(guild) {
const promises = [];
this.feeds.forEach(feed => {
promises.push(feed.updatePastPostedLinks(guild).catch(Util.dateError));
});
return Promise.all(promises);
}
checkFeeds(guilds) {
this.feeds.forEach(feed => feed.check(guilds.get(this.id)));
2017-09-01 17:51:05 +03:00
}
};