Change option in #59 to mentionRole, and extend functionality
The option now defaults to "here", and also accepts "everyone" as a value. Can be set to null to disable these mentions entirely.master
parent
4bad0d3f3b
commit
6767cd91f7
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v2.3.0
|
||||||
|
* Added `mentionRole` configuration option ([#59](https://github.com/Dragory/modmailbot/pull/59)). This option can be used to set the role that is pinged when new threads are created or the bot is mentioned. See README for more details.
|
||||||
|
|
||||||
## v2.2.0
|
## v2.2.0
|
||||||
* Added the ability to schedule a thread to close by specifying a time after `!close`, e.g. `!close 1h`. The scheduling is cancelled if a new message is sent to or received from the user.
|
* Added the ability to schedule a thread to close by specifying a time after `!close`, e.g. `!close 1h`. The scheduling is cancelled if a new message is sent to or received from the user.
|
||||||
|
|
||||||
|
|
|
@ -75,3 +75,4 @@ These go in `config.json`. See also `config.example.json`.
|
||||||
|threadTimestamps|false|Whether to show custom timestamps in threads, in addition to Discord's own timestamps. Logs always have accurate timestamps, regardless of this setting.|
|
|threadTimestamps|false|Whether to show custom timestamps in threads, in addition to Discord's own timestamps. Logs always have accurate timestamps, regardless of this setting.|
|
||||||
|typingProxy|false|If enabled, any time a user is typing to modmail in their DMs, the modmail thread will show the bot as "typing"|
|
|typingProxy|false|If enabled, any time a user is typing to modmail in their DMs, the modmail thread will show the bot as "typing"|
|
||||||
|typingProxyReverse|false|If enabled, any time a moderator is typing in a modmail thread, the user will see the bot "typing" in their DMs|
|
|typingProxyReverse|false|If enabled, any time a moderator is typing in a modmail thread, the user will see the bot "typing" in their DMs|
|
||||||
|
|mentionRole|"here"|Role that is mentioned when new threads are created or the bot is mentioned. Accepted values are "here", "everyone", or a role id as a string. Set to null to disable these pings entirely.|
|
||||||
|
|
|
@ -21,7 +21,7 @@ const defaultConfig = {
|
||||||
"responseMessage": "Thank you for your message! Our mod team will reply to you here as soon as possible.",
|
"responseMessage": "Thank you for your message! Our mod team will reply to you here as soon as possible.",
|
||||||
|
|
||||||
"newThreadCategoryId": null,
|
"newThreadCategoryId": null,
|
||||||
"mentionRoleID": null,
|
"mentionRole": null,
|
||||||
|
|
||||||
"inboxServerPermission": null,
|
"inboxServerPermission": null,
|
||||||
"alwaysReply": false,
|
"alwaysReply": false,
|
||||||
|
|
|
@ -79,14 +79,13 @@ async function createNewThreadForUser(user) {
|
||||||
|
|
||||||
const newThread = await findById(newThreadId);
|
const newThread = await findById(newThreadId);
|
||||||
|
|
||||||
//If no role is set, mention @here
|
|
||||||
const mention = (config.mentionRoleID == null) ? "@here" : `<@&${config.mentionRoleID}>`;
|
|
||||||
|
|
||||||
// Ping moderators of the new thread
|
// Ping moderators of the new thread
|
||||||
await newThread.postNonLogMessage({
|
if (config.mentionRole) {
|
||||||
content: `${mention} New modmail thread (${newThread.user_name})`,
|
await newThread.postNonLogMessage({
|
||||||
disableEveryone: false
|
content: `${utils.getInboxMention()}New modmail thread (${newThread.user_name})`,
|
||||||
});
|
disableEveryone: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Send auto-reply to the user
|
// Send auto-reply to the user
|
||||||
if (config.responseMessage) {
|
if (config.responseMessage) {
|
||||||
|
|
|
@ -140,11 +140,8 @@ bot.on('messageCreate', async msg => {
|
||||||
// If the person who mentioned the bot is blocked, ignore them
|
// If the person who mentioned the bot is blocked, ignore them
|
||||||
if (await blocked.isBlocked(msg.author.id)) return;
|
if (await blocked.isBlocked(msg.author.id)) return;
|
||||||
|
|
||||||
//If no role is set, mention @here
|
|
||||||
const mention = (config.mentionRoleID == null) ? "@here" : `<@&${config.mentionRoleID}>`;
|
|
||||||
|
|
||||||
bot.createMessage(utils.getLogChannel(bot).id, {
|
bot.createMessage(utils.getLogChannel(bot).id, {
|
||||||
content: `${mention} Bot mentioned in ${msg.channel.mention} by **${msg.author.username}#${msg.author.discriminator}**: "${msg.cleanContent}"`,
|
content: `${utils.getInboxMention()}Bot mentioned in ${msg.channel.mention} by **${msg.author.username}#${msg.author.discriminator}**: "${msg.cleanContent}"`,
|
||||||
disableEveryone: false,
|
disableEveryone: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
10
src/utils.js
10
src/utils.js
|
@ -58,7 +58,7 @@ function postLog(...args) {
|
||||||
|
|
||||||
function postError(str) {
|
function postError(str) {
|
||||||
getLogChannel().createMessage({
|
getLogChannel().createMessage({
|
||||||
content: `@here **Error:** ${str.trim()}`,
|
content: `${getInboxMention()}**Error:** ${str.trim()}`,
|
||||||
disableEveryone: false
|
disableEveryone: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,13 @@ function convertDelayStringToMS(str) {
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getInboxMention() {
|
||||||
|
if (config.mentionRole == null) return '';
|
||||||
|
else if (config.mentionRole === 'here') return '@here ';
|
||||||
|
else if (config.mentionRole === 'everyone') return '@everyone ';
|
||||||
|
else return `<@&${config.mentionRole}> `;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
BotError,
|
BotError,
|
||||||
|
|
||||||
|
@ -237,6 +244,7 @@ module.exports = {
|
||||||
getSelfUrl,
|
getSelfUrl,
|
||||||
getMainRole,
|
getMainRole,
|
||||||
convertDelayStringToMS,
|
convertDelayStringToMS,
|
||||||
|
getInboxMention,
|
||||||
|
|
||||||
chunk,
|
chunk,
|
||||||
trimAll,
|
trimAll,
|
||||||
|
|
Loading…
Reference in New Issue