Files
discordeno/helpers/channels/threads/startThreadWithoutMessage.ts
2022-02-11 09:49:53 +00:00

22 lines
787 B
TypeScript

import type { Channel } from "../../../types/channels/channel.ts";
import type { StartThreadWithoutMessage } from "../../../types/channels/threads/startThread.ts";
import type { Bot } from "../../../bot.ts";
/** Creates a new private thread. Returns a thread channel. */
export async function startThreadWithoutMessage(bot: Bot, channelId: bigint, options: StartThreadWithoutMessage) {
const result = await bot.rest.runMethod<Channel>(
bot.rest,
"post",
bot.constants.endpoints.THREAD_START_PRIVATE(channelId),
{
name: options.name,
auto_archive_duration: options.autoArchiveDuration,
},
);
return bot.transformers.channel(bot, {
channel: result,
guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined,
});
}