(channelId: string)
| 710 | * Get members of a channel |
| 711 | */ |
| 712 | export async function getChannelMembers(channelId: string): Promise<string[]> { |
| 713 | const members: string[] = []; |
| 714 | let cursor: string | undefined; |
| 715 | |
| 716 | do { |
| 717 | const response = await slackRequest<{ |
| 718 | members: string[]; |
| 719 | response_metadata?: { next_cursor?: string }; |
| 720 | }>('conversations.members', { |
| 721 | channel: channelId, |
| 722 | limit: 200, |
| 723 | cursor, |
| 724 | }); |
| 725 | |
| 726 | if (response.members) { |
| 727 | members.push(...response.members); |
| 728 | } |
| 729 | |
| 730 | cursor = response.response_metadata?.next_cursor; |
| 731 | |
| 732 | if (cursor) { |
| 733 | await sleep(RATE_LIMIT_DELAY_MS); |
| 734 | } |
| 735 | } while (cursor); |
| 736 | |
| 737 | return members; |
| 738 | } |
| 739 | |
| 740 | /** |
| 741 | * Check if a user has access to a channel |
no test coverage detected