Add pinThreadHeader option

cshd
Dragory 2020-11-01 23:26:38 +02:00
parent a5279feb18
commit 7a9bcc5b95
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
5 changed files with 21 additions and 2 deletions

View File

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

View File

@ -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,
};
}
/**

View File

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

View File

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

View File

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