Added an optional close message

You can assign a value to closeMessage to make the bot DM people when their thread gets closed.
master
Jonas Pardon 2018-07-05 18:34:12 +02:00
parent 06a7dd398c
commit 6f327b7456
3 changed files with 5 additions and 0 deletions

View File

@ -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|

View File

@ -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",

View File

@ -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();