Files
discordeno/src/helpers/channels/threads/join_thread.ts
T
2021-06-17 16:38:47 +00:00

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));
}