mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
24 lines
788 B
TypeScript
24 lines
788 B
TypeScript
import type { Channel } from "../../../types/channels/channel.ts";
|
|
import type { StartThreadBase } from "../../../types/channels/threads/startThread.ts";
|
|
import type { Bot } from "../../../bot.ts";
|
|
|
|
/** Creates a new public thread from an existing message. Returns a thread channel. */
|
|
export async function startThreadWithMessage(
|
|
bot: Bot,
|
|
channelId: bigint,
|
|
messageId: bigint,
|
|
options: StartThreadBase,
|
|
) {
|
|
const result = await bot.rest.runMethod<Channel>(
|
|
bot.rest,
|
|
"post",
|
|
bot.constants.endpoints.THREAD_START_PUBLIC(channelId, messageId),
|
|
{
|
|
name: options.name,
|
|
auto_archive_duration: options.autoArchiveDuration,
|
|
},
|
|
);
|
|
|
|
return bot.transformers.channel(bot, { channel: result, guildId: bot.transformers.snowflake(result.guild_id!) });
|
|
}
|