Fix crash if the close message failed to send when closing a thread

master
Dragory 2018-08-08 00:55:03 +03:00
parent ff977b3eea
commit 7e7bd03798
1 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ module.exports = bot => {
async function applyScheduledCloses() { async function applyScheduledCloses() {
const threadsToBeClosed = await threads.getThreadsThatShouldBeClosed(); const threadsToBeClosed = await threads.getThreadsThatShouldBeClosed();
for (const thread of threadsToBeClosed) { 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(); await thread.close();
const logUrl = await thread.getLogUrl(); const logUrl = await thread.getLogUrl();
@ -68,7 +68,7 @@ module.exports = bot => {
} }
// Regular close // Regular close
if(config.closeMessage) await thread.postToUser(config.closeMessage); if(config.closeMessage) await thread.postToUser(config.closeMessage).catch(() => {});
await thread.close(); await thread.close();
const logUrl = await thread.getLogUrl(); const logUrl = await thread.getLogUrl();
@ -86,7 +86,7 @@ module.exports = bot => {
if (! thread) return; if (! thread) return;
console.log(`[INFO] Auto-closing thread with ${thread.user_name} because the channel was deleted`); 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); await thread.close(true);
const logUrl = await thread.getLogUrl(); const logUrl = await thread.getLogUrl();