diff --git a/docs/configuration.md b/docs/configuration.md index 39d4299..5c531f8 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -278,6 +278,10 @@ If enabled, a system message will be posted into any open threads if the user le **Default:** `on` If enabled, the bot will mention staff (see `mentionRole` option) on the inbox server when the bot is mentioned on the main server. +#### pinThreadHeader +**Default:** `off` +If enabled, the bot will pin the "thread header" message in each thread that contains the user's details + #### plugins **Default:** *None* **Accepts multiple values.** External plugins to load on startup. See [Plugins](plugins.md) for more information. diff --git a/src/data/Thread.js b/src/data/Thread.js index ef0ecc8..863937d 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -464,7 +464,12 @@ class Thread { const msg = await this._postToThreadChannel(finalContent); threadMessage.inbox_message_id = msg.id; - await this._addThreadMessageToDB(threadMessage.getSQLProps()); + const finalThreadMessage = await this._addThreadMessageToDB(threadMessage.getSQLProps()); + + return { + message: msg, + threadMessage: finalThreadMessage, + }; } /** diff --git a/src/data/cfg.jsdoc.js b/src/data/cfg.jsdoc.js index f743562..e3fd3bf 100644 --- a/src/data/cfg.jsdoc.js +++ b/src/data/cfg.jsdoc.js @@ -64,6 +64,7 @@ * @property {string} [fallbackRoleName=null] * @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 {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 6d2bc30..766671e 100644 --- a/src/data/cfg.schema.json +++ b/src/data/cfg.schema.json @@ -357,6 +357,11 @@ "description": "Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds." }, + "pinThreadHeader": { + "$ref": "#/definitions/customBoolean", + "default": false + }, + "logStorage": { "type": "string", "default": "local" diff --git a/src/data/threads.js b/src/data/threads.js index 946d65d..f0c9cf1 100644 --- a/src/data/threads.js +++ b/src/data/threads.js @@ -287,10 +287,14 @@ async function createNewThreadForUser(user, opts = {}) { infoHeader += "\n────────────────"; - await newThread.postSystemMessage(infoHeader, { + const { message: threadHeaderMessage } = await newThread.postSystemMessage(infoHeader, { allowedMentions: config.mentionUserInThreadHeader ? { users: [user.id] } : undefined, }); + if (config.pinThreadHeader) { + await threadHeaderMessage.pin(); + } + if (config.updateNotifications) { const availableUpdate = await updates.getAvailableUpdate(); if (availableUpdate) {