@@ -199,14 +199,35 @@ module.exports = async ({ github, context }) => {
199199 }
200200
201201 if ( completedGfiCount < REQUIRED_GFI_COUNT ) {
202- const comments = await github . rest . issues . listComments ( {
203- owner : repo . owner . login ,
204- repo : repo . name ,
205- issue_number : issue . number ,
206- } ) ;
207202
208- if ( ! comments . data . some ( ( c ) => c . body ?. includes ( BEGINNER_GUARD_MARKER ) ) ) {
209- await github . rest . issues . createComment ( {
203+ let allComments = [ ] ;
204+
205+ try {
206+ allComments = await github . paginate (
207+ github . rest . issues . listComments ,
208+ {
209+ owner : repo . owner . login ,
210+ repo : repo . name ,
211+ issue_number : issue . number ,
212+ per_page : 100 ,
213+ }
214+ ) ;
215+ } catch ( error ) {
216+ console . error ( "[Beginner Bot] Failed to fetch comments for GFI guard:" , {
217+ issue : issue . number ,
218+ commenter,
219+ message : error . message ,
220+ } ) ;
221+ return ;
222+ }
223+
224+ const guardAlreadyPosted = allComments . some ( ( c ) =>
225+ c . body ?. includes ( BEGINNER_GUARD_MARKER )
226+ ) ;
227+
228+ if ( ! guardAlreadyPosted ) {
229+ try {
230+ await github . rest . issues . createComment ( {
210231 owner : repo . owner . login ,
211232 repo : repo . name ,
212233 issue_number : issue . number ,
@@ -215,8 +236,18 @@ module.exports = async ({ github, context }) => {
215236
216237Before taking on a **beginner** issue, we ask contributors to complete at least one **Good First Issue** to get familiar with the workflow.
217238
239+ 👉 [Find a Good First Issue here](https://github.com/${ repo . owner . login } /${ repo . name } /issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+First+Issue%22)
240+
218241Please try a GFI first, then come back — we’ll be happy to assign this! 😊` ,
219242 } ) ;
243+ console . log ( "[Beginner Bot] GFI guard comment posted." ) ;
244+ } catch ( error ) {
245+ console . error ( "[Beginner Bot] Failed to post GFI guard comment:" , {
246+ issue : issue . number ,
247+ commenter,
248+ message : error . message ,
249+ } ) ;
250+ }
220251 }
221252 return ;
222253 }
0 commit comments