Add method for recursively iterating over feeds in guild
This commit is contained in:
parent
084e805f39
commit
36aa5639ab
|
@ -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();
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue