Update feed error handling

This commit is contained in:
benji7425 2017-12-08 00:29:16 +00:00
parent da1edc57f0
commit 20fa9d09af
2 changed files with 15 additions and 16 deletions

View file

@ -3,7 +3,8 @@ const Camo = require("camo");
const Config = require("../config.json");
const Dns = require("dns"); //for host resolution checking
const Url = require("url"); //for url parsing
const FeedRead = require("feed-read"); //for extracing new links from RSS feeds
const { promisify } = require("util");
const FeedReadPromise = promisify(require("feed-read")); //for extracing new links from RSS feeds
const GetUrls = require("get-urls"); //for extracting urls from messages
module.exports = class FeedData extends Camo.EmbeddedDocument {
@ -63,12 +64,9 @@ module.exports = class FeedData extends Camo.EmbeddedDocument {
}
_doFetchRSS(guild) {
FeedRead(this.url, (err, articles) => {
if (err)
return;
FeedReadPromise(this.url + "asdf")
.then(articles => {
if (articles.length > 0 && articles[0].link) {
const latest = normaliseUrl(articles[0].link);
if (!this.cachedLinks.includes(latest)) {
@ -79,7 +77,8 @@ module.exports = class FeedData extends Camo.EmbeddedDocument {
.catch(err => DiscordUtil.dateDebugError(`Error posting in ${channel.id}: ${err.message || err}`));
}
}
});
})
.catch(err => DiscordUtil.dateDebugError(`Error reading feed ${this.url}`, err));
}
};