Fix thread channel being deleted before the close message is sent

cshd
Dragory 2020-10-27 18:27:30 +02:00
parent 1df7ba3e64
commit fa84fa6034
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 4 additions and 2 deletions

View File

@ -66,6 +66,7 @@ module.exports = ({ bot, knex, config, commands }) => {
let hasCloseMessage = !! config.closeMessage;
let silentClose = false;
let suppressSystemMessages = false;
if (msg.channel instanceof Eris.PrivateChannel) {
// User is closing the thread by themselves (if enabled)
@ -79,7 +80,7 @@ module.exports = ({ bot, knex, config, commands }) => {
// between showing the close command in the thread and closing the thread
await messageQueue.add(async () => {
thread.postSystemMessage("Thread closed by user, closing...");
await thread.close(true);
suppressSystemMessages = true;
});
closedBy = "the user";
@ -133,7 +134,6 @@ module.exports = ({ bot, knex, config, commands }) => {
}
// Regular close
await thread.close(false, silentClose);
closedBy = msg.author.username;
}
@ -143,6 +143,8 @@ module.exports = ({ bot, knex, config, commands }) => {
await thread.sendSystemMessageToUser(closeMessage).catch(() => {});
}
await thread.close(suppressSystemMessages, silentClose);
await sendCloseNotification(thread, `Modmail thread with ${thread.user_name} (${thread.user_id}) was closed by ${closedBy}`);
});