This commit is contained in:
wakingcan 2026-01-29 21:53:34 -05:00 committed by GitHub
commit fca78c6a35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 58 additions and 6 deletions

View File

@ -284,13 +284,33 @@ export async function handleDiscordMessagingAction(
typeof autoArchiveMinutesRaw === "number" && Number.isFinite(autoArchiveMinutesRaw) typeof autoArchiveMinutesRaw === "number" && Number.isFinite(autoArchiveMinutesRaw)
? autoArchiveMinutesRaw ? autoArchiveMinutesRaw
: undefined; : undefined;
// Forum channel support: initial message content
const messageContent = readStringParam(params, "content");
const appliedTags = readStringArrayParam(params, "appliedTags");
const embeds =
Array.isArray(params.embeds) && params.embeds.length > 0 ? params.embeds : undefined;
const payload: Parameters<typeof createThreadDiscord>[1] = {
name,
messageId,
autoArchiveMinutes,
};
// Add forum-specific fields if content is provided
if (messageContent) {
payload.message = {
content: messageContent,
embeds,
};
}
if (appliedTags?.length) {
payload.appliedTags = appliedTags;
}
const thread = accountId const thread = accountId
? await createThreadDiscord( ? await createThreadDiscord(channelId, payload, { accountId })
channelId, : await createThreadDiscord(channelId, payload);
{ name, messageId, autoArchiveMinutes },
{ accountId },
)
: await createThreadDiscord(channelId, { name, messageId, autoArchiveMinutes });
return jsonResult({ ok: true, thread }); return jsonResult({ ok: true, thread });
} }
case "threadList": { case "threadList": {

View File

@ -183,6 +183,10 @@ export async function handleDiscordMessageAction(
const autoArchiveMinutes = readNumberParam(params, "autoArchiveMin", { const autoArchiveMinutes = readNumberParam(params, "autoArchiveMin", {
integer: true, integer: true,
}); });
// Forum channel support
const content = readStringParam(params, "message");
const appliedTags = readStringArrayParam(params, "appliedTags");
const embeds = Array.isArray(params.embeds) ? params.embeds : undefined;
return await handleDiscordAction( return await handleDiscordAction(
{ {
action: "threadCreate", action: "threadCreate",
@ -191,6 +195,9 @@ export async function handleDiscordMessageAction(
name, name,
messageId, messageId,
autoArchiveMinutes, autoArchiveMinutes,
content,
appliedTags,
embeds,
}, },
cfg, cfg,
); );

View File

@ -97,6 +97,22 @@ export async function createThreadDiscord(
if (payload.autoArchiveMinutes) { if (payload.autoArchiveMinutes) {
body.auto_archive_duration = payload.autoArchiveMinutes; body.auto_archive_duration = payload.autoArchiveMinutes;
} }
// Forum channels require a message object for the initial post
if (payload.message) {
body.message = {
content: payload.message.content,
...(payload.message.embeds?.length ? { embeds: payload.message.embeds } : {}),
};
}
// Forum tags
if (payload.appliedTags?.length) {
body.applied_tags = payload.appliedTags;
}
// For forum channels without messageId, use the channel threads endpoint
// For regular channels with messageId, use the message-based thread endpoint
const route = Routes.threads(channelId, payload.messageId); const route = Routes.threads(channelId, payload.messageId);
return await rest.post(route, { body }); return await rest.post(route, { body });
} }

View File

@ -66,10 +66,19 @@ export type DiscordMessageEdit = {
content?: string; content?: string;
}; };
export type DiscordForumMessage = {
content: string;
embeds?: unknown[];
};
export type DiscordThreadCreate = { export type DiscordThreadCreate = {
messageId?: string; messageId?: string;
name: string; name: string;
autoArchiveMinutes?: number; autoArchiveMinutes?: number;
/** Initial message content for forum posts (required for forum channels) */
message?: DiscordForumMessage;
/** Tag IDs to apply to forum posts */
appliedTags?: string[];
}; };
export type DiscordThreadList = { export type DiscordThreadList = {