From eb2f109301d478a539d9506afc0fc33867016e78 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 9 Jun 2019 16:04:17 +0300 Subject: [PATCH] Add rolesInThreadHeader config option --- README.md | 1 + src/config.js | 1 + src/data/threads.js | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 85d3fd3..9980c3c 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ These go in `config.json`. See also `config.example.json`. |requiredAccountAge|None|Required account age for contacting modmail (in hours). If the account is not old enough, a new thread will not be created and the bot will reply with `accountAgeDeniedMessage` (if set) instead.| |requiredTimeOnServer|None|Required amount of time (in minutes) the user must be a member of the server before being able to contact modmail. If the user hasn't been a member of the server for the specified time, a new thread will not be created and the bot will reply with `timeOnServerDeniedMessage` (if set) instead.| |responseMessage|"Thank you for your message! Our mod team will reply to you here as soon as possible."|The bot's response to DMs that start a new thread| +|rolesInThreadHeader|false|If enabled, the user's roles will be shown in the thread header| |smallAttachmentLimit|2097152|Size limit of `relaySmallAttachmentsAsAttachments`, in bytes (default is 2MB)| |snippetPrefix|"!!"|Prefix to use snippets| |snippetPrefixAnon|"!!!"|Prefix to use snippets anonymously| diff --git a/src/config.js b/src/config.js index 9fac326..002653a 100644 --- a/src/config.js +++ b/src/config.js @@ -70,6 +70,7 @@ const defaultConfig = { "typingProxy": false, "typingProxyReverse": false, "mentionUserInThreadHeader": false, + "rolesInThreadHeader": false, "enableGreeting": false, "greetingMessage": null, diff --git a/src/data/threads.js b/src/data/threads.js index 6c3afae..5b3f903 100644 --- a/src/data/threads.js +++ b/src/data/threads.js @@ -211,6 +211,11 @@ async function createNewThreadForUser(user, quiet = false, ignoreRequirements = } } + if (config.rolesInThreadHeader && guildData.member.roles.length) { + const roles = guildData.member.roles.map(roleId => guildData.guild.roles.get(roleId)).filter(Boolean); + headerItems.push(`ROLES **${roles.map(r => r.name).join(', ')}**`); + } + const headerStr = headerItems.join(', '); if (mainGuilds.length === 1) {