Add rolesInThreadHeader config option

master
Dragory 2019-06-09 16:04:17 +03:00
parent 94d75a184b
commit eb2f109301
3 changed files with 7 additions and 0 deletions

View File

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

View File

@ -70,6 +70,7 @@ const defaultConfig = {
"typingProxy": false,
"typingProxyReverse": false,
"mentionUserInThreadHeader": false,
"rolesInThreadHeader": false,
"enableGreeting": false,
"greetingMessage": null,

View File

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