Fix ignoreHooks opt in createNewThreadForUser() not working

cshd
Dragory 2020-11-04 23:53:03 +02:00
parent 4e8c35cae7
commit 4337d74aba
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 11 additions and 4 deletions

View File

@ -156,9 +156,16 @@ async function createNewThreadForUser(user, opts = {}) {
} }
} }
// Call any registered beforeNewThreadHooks let hookResult;
const hookResult = await callBeforeNewThreadHooks({ user, opts, message: opts.message }); if (! ignoreHooks) {
if (hookResult.cancelled) return; // 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 // 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 // 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}`); console.log(`[NOTE] Creating new thread channel ${channelName}`);
// Figure out which category we should place the thread channel in // 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) { if (! newThreadCategoryId && config.categoryAutomation.newThreadFromServer) {
// Categories for specific source guilds (in case of multiple main guilds) // Categories for specific source guilds (in case of multiple main guilds)