Add autoAlert/autoAlertDelay options
parent
53dc6edb6a
commit
dd4640bfff
|
@ -133,6 +133,15 @@ Controls how attachments in modmail threads are stored. Possible values:
|
|||
**Default:** *None*
|
||||
When using attachmentStorage is set to "discord", the id of the channel on the inbox server where attachments are saved
|
||||
|
||||
#### autoAlert
|
||||
**Default:** `off`
|
||||
When enabled, the last moderator to reply to a modmail thread will be automatically alerted when the thread gets a new reply.
|
||||
This alert kicks in after a delay, set by the `autoAlertDelay` option below.
|
||||
|
||||
#### autoAlertDelay
|
||||
**Default:** `2m`
|
||||
The delay after which `autoAlert` kicks in. Uses the same format as timed close; for example `1m30s` for 1 minute and 30 seconds.
|
||||
|
||||
#### botMentionResponse
|
||||
**Default:** *None*
|
||||
If set, the bot auto-replies to bot mentions (pings) with this message. Use `{userMention}` in the text to ping the user back.
|
||||
|
|
|
@ -169,6 +169,7 @@ class Thread {
|
|||
|
||||
/**
|
||||
* @returns {Promise<Number>}
|
||||
* @private
|
||||
*/
|
||||
async _getAndIncrementNextMessageNumber() {
|
||||
return knex.transaction(async trx => {
|
||||
|
@ -186,6 +187,21 @@ class Thread {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified moderator to the thread's alert list after config.autoAlertDelay
|
||||
* @param {string} modId
|
||||
* @returns {Promise<void>}
|
||||
* @private
|
||||
*/
|
||||
async _startAutoAlertTimer(modId) {
|
||||
clearTimeout(this._autoAlertTimeout);
|
||||
const autoAlertDelay = utils.convertDelayStringToMS(config.autoAlertDelay);
|
||||
this._autoAlertTimeout = setTimeout(() => {
|
||||
if (this.status !== THREAD_STATUS.OPEN) return;
|
||||
this.addAlert(modId);
|
||||
}, autoAlertDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Eris.Member} moderator
|
||||
* @param {string} text
|
||||
|
@ -296,6 +312,11 @@ class Thread {
|
|||
await this.postSystemMessage("Cancelling scheduled closing of this thread due to new reply");
|
||||
}
|
||||
|
||||
// If enabled, set up a reply alert for the moderator after a slight delay
|
||||
if (config.autoAlert) {
|
||||
this._startAutoAlertTimer(moderator.id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@
|
|||
* @property {boolean} [errorOnUnknownInlineSnippet=true]
|
||||
* @property {boolean} [allowChangingDisplayRole=true]
|
||||
* @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 {string} [logStorage="local"]
|
||||
* @property {object} [logOptions]
|
||||
* @property {string} logOptions.attachmentDirectory
|
||||
|
|
|
@ -346,6 +346,17 @@
|
|||
"default": null
|
||||
},
|
||||
|
||||
"autoAlert": {
|
||||
"$ref": "#/definitions/customBoolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"autoAlertDelay": {
|
||||
"type": "string",
|
||||
"default": "2m",
|
||||
"description": "Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds."
|
||||
},
|
||||
|
||||
"logStorage": {
|
||||
"type": "string",
|
||||
"default": "local"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const attachments = require("../data/attachments");
|
||||
const utils = require("../utils");
|
||||
const config = require("../cfg");
|
||||
const Thread = require("../data/Thread");
|
||||
|
||||
module.exports = ({ bot, knex, config, commands }) => {
|
||||
|
|
Loading…
Reference in New Issue