@@ -82,17 +82,28 @@ const getRandomActivity = (): string => {
8282export const getChannelMembers = async (
8383 channelId : string ,
8484) : Promise < string [ ] > => {
85- const result = await slackbot . client . conversations . members ( {
86- channel : channelId ,
87- } ) ;
85+ const allMemberIds : string [ ] = [ ] ;
86+ let cursor : string | undefined = undefined ;
87+
88+ // Paginate through all members using Slack's cursor-based pagination
89+ do {
90+ const result = await slackbot . client . conversations . members ( {
91+ channel : channelId ,
92+ limit : 200 ,
93+ ...( cursor ? { cursor } : { } ) ,
94+ } ) ;
8895
89- if ( ! result . ok || ! result . members ) {
90- throw new Error ( `Failed to get members for channel ${ channelId } ` ) ;
91- }
96+ if ( ! result . ok || ! result . members ) {
97+ throw new Error ( `Failed to get members for channel ${ channelId } ` ) ;
98+ }
99+
100+ allMemberIds . push ( ...result . members ) ;
101+ cursor = result . response_metadata ?. next_cursor || undefined ;
102+ } while ( cursor ) ;
92103
93104 // Filter out bots
94105 const memberDetails = await Promise . all (
95- result . members . map ( async ( userId ) => {
106+ allMemberIds . map ( async ( userId ) => {
96107 const userInfo = await slackbot . client . users . info ( { user : userId } ) ;
97108 return {
98109 id : userId ,
@@ -481,6 +492,8 @@ export const createCoffeeChatsForChannel = async (
481492 logWithTime (
482493 `Not enough members in ${ config . channelName } for coffee chats (need at least 2)` ,
483494 ) ;
495+ // Still clear skip flags so users who skipped this round aren't permanently excluded
496+ await clearSkipFlags ( config . channelId ) ;
484497 return ;
485498 }
486499
0 commit comments