Fix Discord auto-thread attempting to thread in Forum/Media channels\n\nCreating threads on messages within Forum/Media channels is often redundant\nor invalid (as messages are already posts). This prevents API errors and spam.\n\nFix: Check channel type before attempting auto-thread creation.

This commit is contained in:
Rain
2026-02-16 21:00:30 +08:00
committed by Peter Steinberger
parent b90d7625e5
commit a0ab301dc3
3 changed files with 68 additions and 0 deletions

View File

@@ -298,6 +298,7 @@ export async function resolveDiscordAutoThreadReplyPlan(params: {
isGuildMessage: boolean;
channelConfig?: DiscordChannelConfigResolved | null;
threadChannel?: DiscordThreadChannel | null;
channelType?: ChannelType;
baseText: string;
combinedBody: string;
replyToMode: ReplyToMode;
@@ -320,6 +321,7 @@ export async function resolveDiscordAutoThreadReplyPlan(params: {
isGuildMessage: params.isGuildMessage,
channelConfig: params.channelConfig,
threadChannel: params.threadChannel,
channelType: params.channelType,
baseText: params.baseText,
combinedBody: params.combinedBody,
});
@@ -348,6 +350,7 @@ export async function maybeCreateDiscordAutoThread(params: {
isGuildMessage: boolean;
channelConfig?: DiscordChannelConfigResolved | null;
threadChannel?: DiscordThreadChannel | null;
channelType?: ChannelType;
baseText: string;
combinedBody: string;
}): Promise<string | undefined> {
@@ -360,6 +363,16 @@ export async function maybeCreateDiscordAutoThread(params: {
if (params.threadChannel) {
return undefined;
}
// Avoid creating threads in channels that don't support it or are already forums
if (
params.channelType === ChannelType.GuildForum ||
params.channelType === ChannelType.GuildMedia ||
params.channelType === ChannelType.GuildVoice ||
params.channelType === ChannelType.GuildStageVoice
) {
return undefined;
}
const messageChannelId = (
params.messageChannelId ||
resolveDiscordMessageChannelId({