Browse Source

Add method for recursively iterating over feeds in guild

shorten
benji7425 4 years ago
parent
commit
36aa5639ab
  1. 19
      app/models/guild-data.js

19
app/models/guild-data.js

@ -1,8 +1,21 @@
const Feed = require("./feed.js");
const FeedData = require("./feed-data.js");
const Util = require("discordjs-util");
module.exports = class GuildData {
constructor({id, feeds}) {
constructor({ id, feeds }) {
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();
};
}
};
Loading…
Cancel
Save