add: getThreadMembers

This commit is contained in:
ITOH
2021-05-02 17:17:17 +02:00
parent 8c23b88dc5
commit 28e407ca03
@@ -0,0 +1,26 @@
import { cacheHandlers } from "../../../cache.ts";
import { rest } from "../../../rest/rest.ts";
import { ChannelTypes } from "../../../types/channels/channel_types.ts";
import { Errors } from "../../../types/misc/errors.ts";
import { endpoints } from "../../../util/constants.ts";
// TODO(threads): it seems like the documented return type is wrong
/** Returns array of thread members objects that are members of the thread. */
export async function getThreadMembers(channelId: string) {
// TODO(threads): perm check
// TODO(threads): intents check
const channel = await cacheHandlers.get("channels", channelId);
if (channel) {
if (
![
ChannelTypes.GuildNewsThread,
ChannelTypes.GuildPivateThread,
ChannelTypes.GuildPublicThread,
].includes(channel.type)
) {
throw new Error(Errors.NOT_A_THREAD_CHANNEL);
}
}
return await rest.runMethod("get", endpoints.THREAD_MEMBERS(channelId));
}