Auto-close threads if their inbox server channel is deleted
parent
c3b702d7a7
commit
32260fd22c
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v2.3.2
|
||||||
|
* Auto-close threads if their modmail channel is deleted
|
||||||
|
|
||||||
## v2.3.1
|
## v2.3.1
|
||||||
* Fixed incorrect default value for `mentionRole` (was `null`, should've been `"here"`)
|
* Fixed incorrect default value for `mentionRole` (was `null`, should've been `"here"`)
|
||||||
|
|
||||||
|
|
17
src/main.js
17
src/main.js
|
@ -200,6 +200,23 @@ async function closeLoop() {
|
||||||
|
|
||||||
closeLoop();
|
closeLoop();
|
||||||
|
|
||||||
|
// Auto-close threads if their channel is deleted
|
||||||
|
bot.on('channelDelete', async (channel) => {
|
||||||
|
if (! (channel instanceof Eris.TextChannel)) return;
|
||||||
|
if (channel.guild.id !== utils.getInboxGuild().id) return;
|
||||||
|
const thread = await threads.findOpenThreadByChannelId(channel.id);
|
||||||
|
if (! thread) return;
|
||||||
|
|
||||||
|
console.log(`[INFO] Auto-closing thread with ${thread.user_name} because the channel was deleted`);
|
||||||
|
await thread.close(true);
|
||||||
|
|
||||||
|
const logUrl = await thread.getLogUrl();
|
||||||
|
utils.postLog(utils.trimAll(`
|
||||||
|
Modmail thread with ${thread.user_name} (${thread.user_id}) was closed automatically because the channel was deleted
|
||||||
|
Logs: ${logUrl}
|
||||||
|
`));
|
||||||
|
});
|
||||||
|
|
||||||
// Mods can reply to modmail threads using !r or !reply
|
// Mods can reply to modmail threads using !r or !reply
|
||||||
// These messages get relayed back to the DM thread between the bot and the user
|
// These messages get relayed back to the DM thread between the bot and the user
|
||||||
addInboxServerCommand('reply', async (msg, args, thread) => {
|
addInboxServerCommand('reply', async (msg, args, thread) => {
|
||||||
|
|
Loading…
Reference in New Issue