From 4337d74aba90ff2903e4e5f24308538d00b8b44d Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 4 Nov 2020 23:53:03 +0200 Subject: [PATCH] Fix ignoreHooks opt in createNewThreadForUser() not working --- src/data/threads.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/data/threads.js b/src/data/threads.js index 7293796..6488cf3 100644 --- a/src/data/threads.js +++ b/src/data/threads.js @@ -156,9 +156,16 @@ async function createNewThreadForUser(user, opts = {}) { } } - // Call any registered beforeNewThreadHooks - const hookResult = await callBeforeNewThreadHooks({ user, opts, message: opts.message }); - if (hookResult.cancelled) return; + let hookResult; + if (! ignoreHooks) { + // Call any registered beforeNewThreadHooks + hookResult = await callBeforeNewThreadHooks({ + user, + opts, + message: opts.message + }); + if (hookResult.cancelled) return; + } // Use the user's name+discrim for the thread channel's name // Channel names are particularly picky about what characters they allow, so we gotta do some clean-up @@ -175,7 +182,7 @@ async function createNewThreadForUser(user, opts = {}) { console.log(`[NOTE] Creating new thread channel ${channelName}`); // Figure out which category we should place the thread channel in - let newThreadCategoryId = hookResult.categoryId || opts.categoryId || null; + let newThreadCategoryId = (hookResult && hookResult.categoryId) || opts.categoryId || null; if (! newThreadCategoryId && config.categoryAutomation.newThreadFromServer) { // Categories for specific source guilds (in case of multiple main guilds)