Kaynağa Gözat

Fix crash if verify channel is unreachable

ghorsington 5 yıl önce
ebeveyn
işleme
ee98ba636c
1 değiştirilmiş dosya ile 11 ekleme ve 5 silme
  1. 11 5
      bot/src/commands/forums_news_checker.ts

+ 11 - 5
bot/src/commands/forums_news_checker.ts

@@ -86,12 +86,12 @@ async function checkFeeds() {
 
         if (postItem) {
 
-            if(process.env.IGNORE_CHANGED_NEWS === "TRUE") {
+            if (process.env.IGNORE_CHANGED_NEWS === "TRUE") {
                 await forumsNewsRepo.update({
                     id: postItem.id
                 }, {
-                    hash: itemObj.hash
-                });
+                        hash: itemObj.hash
+                    });
                 continue;
             }
 
@@ -146,6 +146,12 @@ async function initPendingReactors() {
 
 async function addVerifyMessage(item: PostedForumNewsItem) {
     let verifyChannel = client.channels.get(verifyChannelId) as TextChannel;
+
+    if(!verifyChannel) {
+        console.log(`Skipping adding item ${item.id} because no verify channel is set up!`);
+        return;
+    }
+
     let verifyMessageRepo = getRepository(PostVerifyMessage);
     let forumsNewsRepo = getRepository(PostedForumNewsItem);
 
@@ -311,13 +317,13 @@ export default {
 
         if (!verifyChannel)
             return;
-        
+
         verifyChannelId = verifyChannel.channelId;
 
         let user = await forumClient.getMe();
         botUserId = user.user_id;
 
         await initPendingReactors();
-        interval(checkFeeds, RSS_UPDATE_INTERVAL_MIN * 60 * 1000);
+        interval(checkFeeds, RSS_UPDATE_INTERVAL_MIN * 1000);
     }
 } as ICommand;