From 6f327b74569a1e97195e0af5198909719981a8ed Mon Sep 17 00:00:00 2001 From: Jonas Pardon Date: Thu, 5 Jul 2018 18:34:12 +0200 Subject: [PATCH] Added an optional close message You can assign a value to closeMessage to make the bot DM people when their thread gets closed. --- README.md | 1 + src/config.js | 1 + src/modules/close.js | 3 +++ 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index ac8fa76..114516c 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ These go in `config.json`. See also `config.example.json`. |prefix|"!"|Prefix for bot commands| |status|"Message me for help"|The bot's "Playing" text| |responseMessage|"Thank you for your message! Our mod team will reply to you here as soon as possible."|The bot's response to DMs that start a new thread| +|closeMessage|None|The bot's message to the user when the thread is closed| |alwaysReply|false|If set to true, all messages in modmail threads will be relayed back to the user, even ones without `!r`| |alwaysReplyAnon|false|If `alwaysReply` is set to true, this option controls whether the auto-reply is anonymous| |useNicknames|false|If set to true, mod replies will use their nickname (on the inbox server) instead of their username| diff --git a/src/config.js b/src/config.js index 8ea73e8..952a589 100644 --- a/src/config.js +++ b/src/config.js @@ -45,6 +45,7 @@ const defaultConfig = { "status": "Message me for help!", "responseMessage": "Thank you for your message! Our mod team will reply to you here as soon as possible.", + "closeMessage": null, "newThreadCategoryId": null, "mentionRole": "here", diff --git a/src/modules/close.js b/src/modules/close.js index e46b504..58f5378 100644 --- a/src/modules/close.js +++ b/src/modules/close.js @@ -14,6 +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); await thread.close(); const logUrl = await thread.getLogUrl(); @@ -67,6 +68,7 @@ module.exports = bot => { } // Regular close + if(config.closeMessage) await thread.postToUser(config.closeMessage); await thread.close(); const logUrl = await thread.getLogUrl(); @@ -84,6 +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); await thread.close(true); const logUrl = await thread.getLogUrl();