diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd9947..6f82b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ Please report any bugs you encounter by [creating a GitHub issue](https://github * The symbols used can be changed with the `inlineSnippetStart` and `inlineSnippetEnd` options * This feature can be disabled by setting `allowInlineSnippets = off` in your config * By default, the bot will refuse to send a reply with an unknown inline snippet. To disable this behavior, set `errorOnUnknownInlineSnippet = off`. +* New option: `fallbackRoleName` + * Sets the role name to display in moderator replies if the moderator doesn't have a hoisted role +* Unless `fallbackRoleName` is set, anonymous replies without a role will no longer display "Moderator:" at the beginning of the message * Plugins can now also be installed from NPM modules * Example: `plugins[] = npm:some-plugin-package` * Fix occasional bug with expiring blocks where the bot would send the expiry message multiple times diff --git a/docs/configuration.md b/docs/configuration.md index 9e9a4a0..bd01c60 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -177,6 +177,10 @@ When enabled, the bot will send a greeting DM to users that join the main server When enabled, the bot will refuse to send any reply with an unknown inline snippet. See [allowInlineSnippets](#allowInlineSnippets) for more details. +#### fallbackRoleName +**Default:** *None* +Role name to display in moderator replies if the moderator doesn't have a hoisted role + #### greetingAttachment **Default:** *None* Path to an image or other attachment to send as a greeting. Requires `enableGreeting` to be enabled. diff --git a/src/data/cfg.jsdoc.js b/src/data/cfg.jsdoc.js index 438d61f..1dbb5eb 100644 --- a/src/data/cfg.jsdoc.js +++ b/src/data/cfg.jsdoc.js @@ -61,6 +61,7 @@ * @property {string} [inlineSnippetEnd="}}"] * @property {boolean} [errorOnUnknownInlineSnippet=true] * @property {boolean} [allowChangingDisplayedRole=true] + * @property {string} [fallbackRoleName=null] * @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 b410e09..6955e83 100644 --- a/src/data/cfg.schema.json +++ b/src/data/cfg.schema.json @@ -341,6 +341,11 @@ "default": true }, + "fallbackRoleName": { + "type": "string", + "default": null + }, + "logStorage": { "type": "string", "default": "local" diff --git a/src/formatters.js b/src/formatters.js index a173ac8..8c086c8 100644 --- a/src/formatters.js +++ b/src/formatters.js @@ -100,19 +100,25 @@ const moment = require("moment"); */ const defaultFormatters = { formatStaffReplyDM(threadMessage) { + const roleName = threadMessage.role_name || config.fallbackRoleName; const modInfo = threadMessage.is_anonymous - ? (threadMessage.role_name ? threadMessage.role_name : "Moderator") - : (threadMessage.role_name ? `(${threadMessage.role_name}) ${threadMessage.user_name}` : threadMessage.user_name); + ? roleName + : (roleName ? `(${roleName}) ${threadMessage.user_name}` : threadMessage.user_name); - return `**${modInfo}:** ${threadMessage.body}`; + return modInfo + ? `**${modInfo}:** ${threadMessage.body}` + : threadMessage.body; }, formatStaffReplyThreadMessage(threadMessage) { + const roleName = threadMessage.role_name || config.fallbackRoleName; const modInfo = threadMessage.is_anonymous - ? `(Anonymous) (${threadMessage.user_name}) ${threadMessage.role_name || "Moderator"}` - : (threadMessage.role_name ? `(${threadMessage.role_name}) ${threadMessage.user_name}` : threadMessage.user_name); + ? (roleName ? `(Anonymous) (${threadMessage.user_name}) ${roleName}` : `(Anonymous) (${threadMessage.user_name})`) + : (roleName ? `(${roleName}) ${threadMessage.user_name}` : threadMessage.user_name); - let result = `**${modInfo}:** ${threadMessage.body}`; + let result = modInfo + ? `**${modInfo}:** ${threadMessage.body}` + : threadMessage.body; if (config.threadTimestamps) { const formattedTimestamp = utils.getTimestamp(threadMessage.created_at);