Fixed disconnect error crash + added channel check on message detect
This commit is contained in:
parent
a8283ba87a
commit
599ed40db0
|
@ -53,14 +53,15 @@ Dns.resolve("discordapp.com", function (err) {
|
|||
});
|
||||
|
||||
bot.on("disconnect", function (err, code) {
|
||||
logEvent("Bot was disconnected. Code: " + code + ". Details: " + (err.message || err));
|
||||
logEvent("Bot was disconnected! " + code != null ? code : "No disconnect code provided");
|
||||
if (err) reportError("Bot disconnect error: " + (err.message || err));
|
||||
logEvent("Trying to reconnect bot");
|
||||
bot.connect();
|
||||
});
|
||||
|
||||
bot.on("message", function (user, userID, channelID, message) {
|
||||
//check if the message is a link, cache it if it is
|
||||
if (linkRegExp.test(message) && (message !== latestFeedLink)) {
|
||||
//check if the message contains a link, in the right channel, and not the latest link from the rss feed
|
||||
if (channelID === Config.channelID && linkRegExp.test(message) && (message !== latestFeedLink)) {
|
||||
logEvent("Detected posted link: " + message);
|
||||
//detect the url inside the string, and cache it
|
||||
Uri.withinString(message, function (url) {
|
||||
|
|
Loading…
Reference in a new issue