diff --git a/docs/configuration.md b/docs/configuration.md index 86d73cc..f4abcc9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -331,7 +331,8 @@ Required amount of time (in minutes) the user must be a member of the server bef #### responseMessage **Default:** `Thank you for your message! Our mod team will reply to you here as soon as possible.` -The bot's response to the user when they message the bot and open a new modmail thread +The bot's response to the user when they message the bot and open a new modmail thread. +If you have a multi-line or otherwise long `responseMessage`, you might want to turn off [showResponseMessageInThreadChannel](#showResponseMessageInThreadChannel) to reduce clutter in the thread channel on the inbox server. #### rolesInThreadHeader **Default:** `off` @@ -348,6 +349,11 @@ serverGreetings.541484311354933258.message[] = Welcome to server ID 541484311354 serverGreetings.541484311354933258.message[] = Second line of the greeting. ``` +#### showResponseMessageInThreadChannel +**Default:** `on` +Whether to show the [responseMessage](#responseMessage) sent to the user in the thread channel on the inbox server as well. +If you have a multi-line or otherwise long `responseMessage`, it might be a good idea to turn this off to reduce clutter. + #### smallAttachmentLimit **Default:** `2097152` Size limit of `relaySmallAttachmentsAsAttachments` in bytes (default is 2MB) diff --git a/src/data/Thread.js b/src/data/Thread.js index 54bbce9..6e1ee16 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -481,6 +481,7 @@ class Thread { * @param {boolean} [allowedMentions.everyone] * @param {boolean|string[]} [allowedMentions.roles] * @param {boolean|string[]} [allowedMentions.users] + * @param {boolean} [allowedMentions.postToThreadChannel] * @returns {Promise} */ async sendSystemMessageToUser(text, opts = {}) { @@ -495,12 +496,14 @@ class Thread { const dmContent = await formatters.formatSystemToUserDM(threadMessage); const dmMsg = await this._sendDMToUser(dmContent); - const inboxContent = await formatters.formatSystemToUserThreadMessage(threadMessage); - const finalInboxContent = typeof inboxContent === "string" ? { content: inboxContent } : inboxContent; - finalInboxContent.allowedMentions = opts.allowedMentions; - const inboxMsg = await this._postToThreadChannel(inboxContent); + if (opts.postToThreadChannel !== false) { + const inboxContent = await formatters.formatSystemToUserThreadMessage(threadMessage); + const finalInboxContent = typeof inboxContent === "string" ? {content: inboxContent} : inboxContent; + finalInboxContent.allowedMentions = opts.allowedMentions; + const inboxMsg = await this._postToThreadChannel(inboxContent); + threadMessage.inbox_message_id = inboxMsg.id; + } - threadMessage.inbox_message_id = inboxMsg.id; threadMessage.dm_channel_id = dmMsg.channel.id; threadMessage.dm_message_id = dmMsg.id; diff --git a/src/data/cfg.jsdoc.js b/src/data/cfg.jsdoc.js index a2f1fc9..b6e46db 100644 --- a/src/data/cfg.jsdoc.js +++ b/src/data/cfg.jsdoc.js @@ -68,6 +68,7 @@ * @property {boolean} [autoAlert=false] * @property {string} [autoAlertDelay="2m"] Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds. * @property {boolean} [pinThreadHeader=false] + * @property {boolean} [showResponseMessageInThreadChannel=true] * @property {string} [logStorage="local"] * @property {object} [logOptions] * @property {string} logOptions.attachmentDirectory diff --git a/src/data/cfg.schema.json b/src/data/cfg.schema.json index 92b5b93..bc5d443 100644 --- a/src/data/cfg.schema.json +++ b/src/data/cfg.schema.json @@ -373,6 +373,11 @@ "default": false }, + "showResponseMessageInThreadChannel": { + "$ref": "#/definitions/customBoolean", + "default": true + }, + "logStorage": { "type": "string", "default": "local" diff --git a/src/data/threads.js b/src/data/threads.js index 6488cf3..a5f50e9 100644 --- a/src/data/threads.js +++ b/src/data/threads.js @@ -221,7 +221,6 @@ async function createNewThreadForUser(user, opts = {}) { }); const newThread = await findById(newThreadId); - let responseMessageError = null; if (! quiet) { // Ping moderators of the new thread diff --git a/src/main.js b/src/main.js index 076855b..a220cb1 100644 --- a/src/main.js +++ b/src/main.js @@ -169,7 +169,8 @@ function initBaseMessageHandlers() { const responseMessage = utils.readMultilineConfigValue(config.responseMessage); try { - await thread.sendSystemMessageToUser(responseMessage); + const postToThreadChannel = config.showResponseMessageInThreadChannel; + await thread.sendSystemMessageToUser(responseMessage, { postToThreadChannel }); } catch (err) { await thread.postSystemMessage(`**NOTE:** Could not send auto-response to the user. The error given was: \`${err.message}\``); }