From 8774bb637df01589f5e363c6ca64203001e094e5 Mon Sep 17 00:00:00 2001 From: ITOH Date: Wed, 9 Jun 2021 21:39:04 +0200 Subject: [PATCH] Update get_archived_threads.ts --- src/helpers/channels/threads/get_archived_threads.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/helpers/channels/threads/get_archived_threads.ts b/src/helpers/channels/threads/get_archived_threads.ts index 75078fd4f..e9cd45507 100644 --- a/src/helpers/channels/threads/get_archived_threads.ts +++ b/src/helpers/channels/threads/get_archived_threads.ts @@ -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(["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"