From 4b3f04b8a1a909c00dd3abbc4b58f62b2221c8a6 Mon Sep 17 00:00:00 2001 From: Carl Vitullo Date: Tue, 19 Mar 2024 12:54:40 -0400 Subject: [PATCH] Add early return to thread enforcement (#360) --- src/features/autothread.ts | 7 +++++++ src/features/promotion-threads.ts | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/features/autothread.ts b/src/features/autothread.ts index 688b1ea1..0f818bcb 100644 --- a/src/features/autothread.ts +++ b/src/features/autothread.ts @@ -18,6 +18,13 @@ const STAFF_ACCEPT_THRESHOLD = 2; const autoThread: ChannelHandlers = { handleMessage: async ({ msg: maybeMessage }) => { + if ( + maybeMessage.channel.type === ChannelType.PublicThread || + maybeMessage.channel.type === ChannelType.PrivateThread + ) { + return; + } + const msg = maybeMessage.partial ? await maybeMessage.fetch() : maybeMessage; diff --git a/src/features/promotion-threads.ts b/src/features/promotion-threads.ts index 399c60e9..769bca1a 100644 --- a/src/features/promotion-threads.ts +++ b/src/features/promotion-threads.ts @@ -4,10 +4,17 @@ import { ChannelHandlers } from "../types"; import { threadStats } from "../features/stats"; import { format } from "date-fns"; import fetch from "node-fetch"; -import { MessageType } from "discord.js"; +import { ChannelType, MessageType } from "discord.js"; const promotionThread: ChannelHandlers = { handleMessage: async ({ msg: maybeMessage }) => { + if ( + maybeMessage.channel.type === ChannelType.PublicThread || + maybeMessage.channel.type === ChannelType.PrivateThread + ) { + return; + } + const msg = maybeMessage.partial ? await maybeMessage.fetch() : maybeMessage;