Update get_archived_threads.ts

This commit is contained in:
ITOH
2021-06-09 21:39:04 +02:00
parent 4ad3d1a359
commit 8774bb637d

View File

@@ -1,17 +1,24 @@
import { rest } from "../../../rest/rest.ts";
import { ListPublicArchivedThreads } from "../../../types/channels/threads/list_public_archived_threads.ts";
import { PermissionStrings } from "../../../types/permissions/permission_strings.ts";
import { endpoints } from "../../../util/constants.ts";
import { requireBotChannelPermissions } from "../../../util/permissions.ts";
import { snakelize } from "../../../util/utils.ts";
/** Get the archived threads for this channel, defaults to public */
export async function getArchivedThreads(
channelId: bigint,
options?: ListPublicArchivedThreads & {
type?: "public" | "private" | "privateJoinedThreads";
}
) {
// TODO(threads): perm check
const permissions = new Set<PermissionStrings>(["READ_MESSAGE_HISTORY"]);
if (options?.type === "private") permissions.add("MANAGE_THREADS");
requireBotChannelPermissions(channelId, [...permissions]);
// TODO(threads): check if this works
// TODO: v12 map the result to a nice collection or maybe not, check what it returns
return await rest.runMethod(
"get",
options?.type === "privateJoinedThreads"