mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
15 lines
566 B
TypeScript
15 lines
566 B
TypeScript
import { cacheHandlers } from "../../../cache.ts";
|
|
import { rest } from "../../../rest/rest.ts";
|
|
import { Errors } from "../../../types/discordeno/errors.ts";
|
|
import { endpoints } from "../../../util/constants.ts";
|
|
|
|
/** Adds the bot to the thread. Cannot join an archived thread. */
|
|
export async function joinThread(threadId: bigint) {
|
|
const thread = await cacheHandlers.get("threads", threadId);
|
|
if (thread?.archived) {
|
|
throw new Error(Errors.CANNOT_ADD_USER_TO_ARCHIVED_THREADS);
|
|
}
|
|
|
|
return await rest.runMethod("put", endpoints.THREAD_ME(threadId));
|
|
}
|