|
|
@ -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,16 +30,20 @@ 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
|
|
|
|
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") { |
|
|
|
guildData.feeds.push(feedData); |
|
|
|
guildData.cachePastPostedLinks(message.guild) |
|
|
|
.then(() => resolve("Your new feed has been saved!")); |
|
|
|
} |
|
|
|
else |
|
|
|
reject("Your feed has not been saved, please add it again with the correct details"); |
|
|
|
}); |
|
|
|
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") { |
|
|
|
guildData.feeds.push(feedData); |
|
|
|
guildData.cachePastPostedLinks(message.guild) |
|
|
|
.then(() => resolve("Your new feed has been saved!")); |
|
|
|
} |
|
|
|
else |
|
|
|
reject("Your feed has not been saved, please add it again with the correct details"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |