From 7e7bd037982b93142a6c1dd0bb1fc0dd29d30ac2 Mon Sep 17 00:00:00 2001 From: Dragory Date: Wed, 8 Aug 2018 00:55:03 +0300 Subject: [PATCH] Fix crash if the close message failed to send when closing a thread --- src/modules/close.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/close.js b/src/modules/close.js index 58f5378..0ba7263 100644 --- a/src/modules/close.js +++ b/src/modules/close.js @@ -14,7 +14,7 @@ module.exports = bot => { async function applyScheduledCloses() { const threadsToBeClosed = await threads.getThreadsThatShouldBeClosed(); for (const thread of threadsToBeClosed) { - if(config.closeMessage) await thread.postToUser(config.closeMessage); + if(config.closeMessage) await thread.postToUser(config.closeMessage).catch(() => {}); await thread.close(); const logUrl = await thread.getLogUrl(); @@ -68,7 +68,7 @@ module.exports = bot => { } // Regular close - if(config.closeMessage) await thread.postToUser(config.closeMessage); + if(config.closeMessage) await thread.postToUser(config.closeMessage).catch(() => {}); await thread.close(); const logUrl = await thread.getLogUrl(); @@ -86,7 +86,7 @@ module.exports = bot => { if (! thread) return; console.log(`[INFO] Auto-closing thread with ${thread.user_name} because the channel was deleted`); - if(config.closeMessage) await thread.postToUser(config.closeMessage); + if(config.closeMessage) await thread.postToUser(config.closeMessage).catch(() => {}); await thread.close(true); const logUrl = await thread.getLogUrl();