Updated message post fail when disconnected to call onDisconnect func

This commit is contained in:
benji7425 2017-01-08 06:18:05 +00:00
parent 9c89b489d5
commit 111639e032
1 changed files with 3 additions and 8 deletions

View File

@ -95,13 +95,7 @@ var DiscordClient = {
if (err) { if (err) {
Log.error("ERROR: Failed to send message: " + message.substring(0, 15) + "...", err); Log.error("ERROR: Failed to send message: " + message.substring(0, 15) + "...", err);
//if there is an error posting the message, check if it is because the bot isn't connected //if there is an error posting the message, check if it is because the bot isn't connected
if (DiscordClient.bot.connected) if (!DiscordClient.bot.connected) DiscordClient.onDisconnect();
Log.info("Connectivity seems fine - I have no idea why the message didn't post");
else {
Log.error("DiscordClient appears to be disconnected! Attempting to reconnect...", err);
DiscordClient.bot.connect(); //attempt to reconnect
}
} }
}); });
} }
@ -160,7 +154,8 @@ var Links = {
validate: function (err, articles, callback) { validate: function (err, articles, callback) {
if (err) Log.error("FEED ERROR: Error reading RSS feed.", err); if (err) Log.error("FEED ERROR: Error reading RSS feed.", err);
else { else {
var latestLink = Links.standardise(Config.youtubeMode ? YouTube.url.createShareUrl(articles[0].link) : articles[0].link); //get the latest link and convert to share url if youtube mode var latestLink = Links.standardise(articles[0].link);
if (Config.youtubeMode) latestLink = YouTube.createShareUrl(latestLink);
//make sure we don't spam the latest link //make sure we don't spam the latest link
if (latestLink == Links.latestFeedLink) if (latestLink == Links.latestFeedLink)