Add feed validity checking before adding

This commit is contained in:
benji7425 2017-11-11 01:59:00 +00:00
parent 0d5e3dcd81
commit 3877aa5c59
1 changed files with 16 additions and 11 deletions

View File

@ -1,5 +1,6 @@
const Core = require("../../discord-bot-core");
const GetUrls = require("get-urls");
const FeedRead = require("feed-read");
const FeedData = require("../models/feed-data.js");
const GuildData = require("../models/guild-data.js");
// @ts-ignore
@ -29,7 +30,10 @@ function invoke({ message, params, guildData, client }) {
});
return new Promise((resolve, reject) => {
//ask the user if they're happy with the details they set up, save if yes, don't if no
FeedRead(feedUrl, (err, articles) => {
if (err)
return reject(`Unable to add the feed due to the following error:\n${err.message}`);
Core.util.ask(client, message.channel, message.member, "Are you happy with this (yes/no)?\n" + feedData.toString())
.then(responseMessage => {
if (responseMessage.content.toLowerCase() === "yes") {
@ -41,4 +45,5 @@ function invoke({ message, params, guildData, client }) {
reject("Your feed has not been saved, please add it again with the correct details");
});
});
});
}