Fix crash when the auto-response cannot be sent. Add pingOnBotMention option for controlling whether the staff get pinged for bot mentions.
parent
cd96c70f1c
commit
1d2f3dd4d8
|
@ -48,6 +48,7 @@ const defaultConfig = {
|
||||||
|
|
||||||
"newThreadCategoryId": null,
|
"newThreadCategoryId": null,
|
||||||
"mentionRole": "here",
|
"mentionRole": "here",
|
||||||
|
"pingOnBotMention": true,
|
||||||
|
|
||||||
"inboxServerPermission": null,
|
"inboxServerPermission": null,
|
||||||
"alwaysReply": false,
|
"alwaysReply": false,
|
||||||
|
|
|
@ -85,6 +85,7 @@ async function createNewThreadForUser(user, quiet = false) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const newThread = await findById(newThreadId);
|
const newThread = await findById(newThreadId);
|
||||||
|
let responseMessageError = null;
|
||||||
|
|
||||||
if (! quiet) {
|
if (! quiet) {
|
||||||
// Ping moderators of the new thread
|
// Ping moderators of the new thread
|
||||||
|
@ -97,7 +98,11 @@ async function createNewThreadForUser(user, quiet = false) {
|
||||||
|
|
||||||
// Send auto-reply to the user
|
// Send auto-reply to the user
|
||||||
if (config.responseMessage) {
|
if (config.responseMessage) {
|
||||||
newThread.postToUser(config.responseMessage);
|
try {
|
||||||
|
await newThread.postToUser(config.responseMessage);
|
||||||
|
} catch (err) {
|
||||||
|
responseMessageError = err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +150,11 @@ async function createNewThreadForUser(user, quiet = false) {
|
||||||
|
|
||||||
await newThread.postSystemMessage(infoHeader);
|
await newThread.postSystemMessage(infoHeader);
|
||||||
|
|
||||||
|
// If there were errors sending a response to the user, note that
|
||||||
|
if (responseMessageError) {
|
||||||
|
await newThread.postSystemMessage(`**NOTE:** Could not send auto-response to the user. The error given was: \`${responseMessageError.message}\``);
|
||||||
|
}
|
||||||
|
|
||||||
// Return the thread
|
// Return the thread
|
||||||
return newThread;
|
return newThread;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,11 +155,12 @@ bot.on('messageCreate', async msg => {
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
const mainGuilds = utils.getMainGuilds();
|
const mainGuilds = utils.getMainGuilds();
|
||||||
|
const staffMention = (config.pingOnBotMention ? utils.getInboxMention() : '');
|
||||||
|
|
||||||
if (mainGuilds.length === 1) {
|
if (mainGuilds.length === 1) {
|
||||||
content = `${utils.getInboxMention()}Bot mentioned in ${msg.channel.mention} by **${msg.author.username}#${msg.author.discriminator}**: "${msg.cleanContent}"`;
|
content = `${staffMention}Bot mentioned in ${msg.channel.mention} by **${msg.author.username}#${msg.author.discriminator}**: "${msg.cleanContent}"`;
|
||||||
} else {
|
} else {
|
||||||
content = `${utils.getInboxMention()}Bot mentioned in ${msg.channel.mention} (${msg.channel.guild.name}) by **${msg.author.username}#${msg.author.discriminator}**: "${msg.cleanContent}"`;
|
content = `${staffMention}Bot mentioned in ${msg.channel.mention} (${msg.channel.guild.name}) by **${msg.author.username}#${msg.author.discriminator}**: "${msg.cleanContent}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.createMessage(utils.getLogChannel(bot).id, {
|
bot.createMessage(utils.getLogChannel(bot).id, {
|
||||||
|
|
Loading…
Reference in New Issue