Add allowBlock, allowSuspend, and allowSnippets as configuration options (#498)
Co-authored-by: Miikka <2606411+Dragory@users.noreply.github.com>cshd
parent
968d780e28
commit
eea6a1c2b7
|
@ -97,17 +97,29 @@ If enabled, staff members can delete their own replies in modmail threads with `
|
||||||
**Default:** `on`
|
**Default:** `on`
|
||||||
If enabled, staff members can edit their own replies in modmail threads with `!edit`
|
If enabled, staff members can edit their own replies in modmail threads with `!edit`
|
||||||
|
|
||||||
|
#### allowBlock
|
||||||
|
**Default:** `on`
|
||||||
|
If enabled, staff members can block a user from using modmail with `!block`
|
||||||
|
|
||||||
|
#### allowSuspend
|
||||||
|
**Default:** `on`
|
||||||
|
If enabled, staff members can suspend a user from using modmail with `!suspend`
|
||||||
|
|
||||||
|
#### allowSnippets
|
||||||
|
**Default:** `on`
|
||||||
|
If enabled, staff members can use [Snippets](snippets.md)
|
||||||
|
|
||||||
#### allowInlineSnippets
|
#### allowInlineSnippets
|
||||||
**Default:** `on`
|
**Default:** `on`
|
||||||
If enabled, snippets can be included *within* replies by wrapping the snippet's name in {{ and }}.
|
If `allowSnippets` is enabled, this option controls whether the snippets can be included *within* replies by wrapping the snippet's name in {{ and }}.
|
||||||
E.g. `!r Hello! {{rules}}`
|
E.g. `!r Hello! {{rules}}`
|
||||||
|
|
||||||
|
See [inlineSnippetStart](#inlineSnippetStart) and [inlineSnippetEnd](#inlineSnippetEnd) to customize the symbols used.
|
||||||
|
|
||||||
#### allowChangingDisplayRole
|
#### allowChangingDisplayRole
|
||||||
**Default:** `on`
|
**Default:** `on`
|
||||||
If enabled, moderators can change the role that's shown with their replies to any role they currently have using the `!role` command.
|
If enabled, moderators can change the role that's shown with their replies to any role they currently have using the `!role` command.
|
||||||
|
|
||||||
See [inlineSnippetStart](#inlineSnippetStart) and [inlineSnippetEnd](#inlineSnippetEnd) to customize the symbols used.
|
|
||||||
|
|
||||||
#### alwaysReply
|
#### alwaysReply
|
||||||
**Default:** `off`
|
**Default:** `off`
|
||||||
If enabled, all messages in modmail threads will be sent to the user without having to use `!r`.
|
If enabled, all messages in modmail threads will be sent to the user without having to use `!r`.
|
||||||
|
|
|
@ -215,7 +215,7 @@ class Thread {
|
||||||
const moderatorName = config.useNicknames && moderator.nick ? moderator.nick : moderator.user.username;
|
const moderatorName = config.useNicknames && moderator.nick ? moderator.nick : moderator.user.username;
|
||||||
const roleName = await getModeratorThreadDisplayRoleName(moderator, this.id);
|
const roleName = await getModeratorThreadDisplayRoleName(moderator, this.id);
|
||||||
|
|
||||||
if (config.allowInlineSnippets) {
|
if (config.allowSnippets && config.allowInlineSnippets) {
|
||||||
// Replace {{snippet}} with the corresponding snippet
|
// Replace {{snippet}} with the corresponding snippet
|
||||||
// The beginning and end of the variable - {{ and }} - can be changed with the config options
|
// The beginning and end of the variable - {{ and }} - can be changed with the config options
|
||||||
// config.inlineSnippetStart and config.inlineSnippetEnd
|
// config.inlineSnippetStart and config.inlineSnippetEnd
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
* @property {boolean} [rolesInThreadHeader=false]
|
* @property {boolean} [rolesInThreadHeader=false]
|
||||||
* @property {boolean} [allowStaffEdit=true]
|
* @property {boolean} [allowStaffEdit=true]
|
||||||
* @property {boolean} [allowStaffDelete=true]
|
* @property {boolean} [allowStaffDelete=true]
|
||||||
|
* @property {boolean} [allowBlock=true]
|
||||||
|
* @property {boolean} [allowSuspend=true]
|
||||||
|
* @property {boolean} [allowSnippets=true]
|
||||||
* @property {boolean} [enableGreeting=false]
|
* @property {boolean} [enableGreeting=false]
|
||||||
* @property {string} [greetingMessage]
|
* @property {string} [greetingMessage]
|
||||||
* @property {string} [greetingAttachment]
|
* @property {string} [greetingAttachment]
|
||||||
|
|
|
@ -173,7 +173,18 @@
|
||||||
"$ref": "#/definitions/customBoolean",
|
"$ref": "#/definitions/customBoolean",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
"allowBlock": {
|
||||||
|
"$ref": "#/definitions/customBoolean",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
"allowSuspend": {
|
||||||
|
"$ref": "#/definitions/customBoolean",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
"allowSnippets": {
|
||||||
|
"$ref": "#/definitions/customBoolean",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
"enableGreeting": {
|
"enableGreeting": {
|
||||||
"$ref": "#/definitions/customBoolean",
|
"$ref": "#/definitions/customBoolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
|
|
@ -4,6 +4,7 @@ const blocked = require("../data/blocked");
|
||||||
const utils = require("../utils");
|
const utils = require("../utils");
|
||||||
|
|
||||||
module.exports = ({ bot, knex, config, commands }) => {
|
module.exports = ({ bot, knex, config, commands }) => {
|
||||||
|
if (! config.allowBlock) return;
|
||||||
async function removeExpiredBlocks() {
|
async function removeExpiredBlocks() {
|
||||||
const expiredBlocks = await blocked.getExpiredBlocks();
|
const expiredBlocks = await blocked.getExpiredBlocks();
|
||||||
const logChannel = utils.getLogChannel();
|
const logChannel = utils.getLogChannel();
|
||||||
|
|
|
@ -7,6 +7,7 @@ const whitespaceRegex = /\s/;
|
||||||
const quoteChars = ["'", "\""];
|
const quoteChars = ["'", "\""];
|
||||||
|
|
||||||
module.exports = ({ bot, knex, config, commands }) => {
|
module.exports = ({ bot, knex, config, commands }) => {
|
||||||
|
if (! config.allowSnippets) return;
|
||||||
/**
|
/**
|
||||||
* "Renders" a snippet by replacing all argument placeholders e.g. {1} {2} with their corresponding arguments.
|
* "Renders" a snippet by replacing all argument placeholders e.g. {1} {2} with their corresponding arguments.
|
||||||
* The number in the placeholder is the argument's order in the argument list, i.e. {1} is the first argument (= index 0)
|
* The number in the placeholder is the argument's order in the argument list, i.e. {1} is the first argument (= index 0)
|
||||||
|
|
|
@ -6,6 +6,7 @@ const config = require("../cfg");
|
||||||
const {THREAD_STATUS} = require("../data/constants");
|
const {THREAD_STATUS} = require("../data/constants");
|
||||||
|
|
||||||
module.exports = ({ bot, knex, config, commands }) => {
|
module.exports = ({ bot, knex, config, commands }) => {
|
||||||
|
if (! config.allowSuspend) return;
|
||||||
// Check for threads that are scheduled to be suspended and suspend them
|
// Check for threads that are scheduled to be suspended and suspend them
|
||||||
async function applyScheduledSuspensions() {
|
async function applyScheduledSuspensions() {
|
||||||
const threadsToBeSuspended = await threads.getThreadsThatShouldBeSuspended();
|
const threadsToBeSuspended = await threads.getThreadsThatShouldBeSuspended();
|
||||||
|
|
Loading…
Reference in New Issue