Merge 75a7c81476 into da71eaebd2
This commit is contained in:
commit
b5d3c51603
@ -279,6 +279,7 @@ export async function handleDiscordMessagingAction(
|
||||
const channelId = resolveChannelId();
|
||||
const name = readStringParam(params, "name", { required: true });
|
||||
const messageId = readStringParam(params, "messageId");
|
||||
const message = readStringParam(params, "message");
|
||||
const autoArchiveMinutesRaw = params.autoArchiveMinutes;
|
||||
const autoArchiveMinutes =
|
||||
typeof autoArchiveMinutesRaw === "number" && Number.isFinite(autoArchiveMinutesRaw)
|
||||
@ -287,10 +288,10 @@ export async function handleDiscordMessagingAction(
|
||||
const thread = accountId
|
||||
? await createThreadDiscord(
|
||||
channelId,
|
||||
{ name, messageId, autoArchiveMinutes },
|
||||
{ name, messageId, message, autoArchiveMinutes },
|
||||
{ accountId },
|
||||
)
|
||||
: await createThreadDiscord(channelId, { name, messageId, autoArchiveMinutes });
|
||||
: await createThreadDiscord(channelId, { name, messageId, message, autoArchiveMinutes });
|
||||
return jsonResult({ ok: true, thread });
|
||||
}
|
||||
case "threadList": {
|
||||
|
||||
@ -180,6 +180,7 @@ export async function handleDiscordMessageAction(
|
||||
if (action === "thread-create") {
|
||||
const name = readStringParam(params, "threadName", { required: true });
|
||||
const messageId = readStringParam(params, "messageId");
|
||||
const message = readStringParam(params, "message");
|
||||
const autoArchiveMinutes = readNumberParam(params, "autoArchiveMin", {
|
||||
integer: true,
|
||||
});
|
||||
@ -190,6 +191,7 @@ export async function handleDiscordMessageAction(
|
||||
channelId: resolveChannelId(),
|
||||
name,
|
||||
messageId,
|
||||
message,
|
||||
autoArchiveMinutes,
|
||||
},
|
||||
cfg,
|
||||
|
||||
@ -97,6 +97,14 @@ export async function createThreadDiscord(
|
||||
if (payload.autoArchiveMinutes) {
|
||||
body.auto_archive_duration = payload.autoArchiveMinutes;
|
||||
}
|
||||
// Forum channels (type 15) require a message object for thread creation
|
||||
if (payload.message) {
|
||||
body.message = { content: payload.message };
|
||||
// For forum posts, POST directly to /channels/{channelId}/threads
|
||||
const route = `/channels/${channelId}/threads`;
|
||||
return await rest.post(route, { body });
|
||||
}
|
||||
// Regular thread from an existing message
|
||||
const route = Routes.threads(channelId, payload.messageId);
|
||||
return await rest.post(route, { body });
|
||||
}
|
||||
|
||||
@ -68,6 +68,7 @@ export type DiscordMessageEdit = {
|
||||
|
||||
export type DiscordThreadCreate = {
|
||||
messageId?: string;
|
||||
message?: string;
|
||||
name: string;
|
||||
autoArchiveMinutes?: number;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user