discord-bot-rss-feed/app/models/guild-data.js
benji7425 7ee7d4c704 3.2.2
asdf
2018-01-07 23:48:29 +00:00

34 lines
704 B
JavaScript

const Core = require("../../discord-bot-core");
const FeedData = require("./feed-data.js");
module.exports = class GuildData extends Core.BaseGuildData {
constructor() {
super();
this.feeds = [];
this.schema({
feeds: [FeedData]
});
}
cachePastPostedLinks(guild) {
return Promise.all(
this.feeds
.filter(feed => feedIsActive(feed, guild))
.map(feed => feed.updatePastPostedLinks(guild).catch(err => null))
);
}
checkFeeds(guild) {
return Promise.all(
this.feeds
.filter(feed => feedIsActive(feed, guild))
.map(feed => feed.fetchLatest(guild).catch(err => null))
);
}
};
function feedIsActive(feed, guild) {
return guild.channels.get(feed.channelID);
}