Add method for recursively iterating over feeds in guild

This commit is contained in:
benji7425 2017-07-29 20:32:33 +01:00
parent 084e805f39
commit 36aa5639ab
1 changed files with 16 additions and 3 deletions

View File

@ -1,8 +1,21 @@
const Feed = require("./feed.js"); const FeedData = require("./feed-data.js");
const Util = require("discordjs-util");
module.exports = class GuildData { module.exports = class GuildData {
constructor({id, feeds}) { constructor({ id, feeds }) {
this.id = id; this.id = id;
this.feeds = feeds.filter(feed => new Feed(feed)); this.feeds = feeds.filter(feed => new FeedData(feed));
}
cachePastPostedLinks() {
let i = 0;
const recurse = () => {
this.feeds[i++].cachePastPostedLinks(this)
.catch(Util.dateError)
.then(recurse);
if (i > this.feeds.length)
return Promise.resolve();
};
} }
}; };