@@ -377,6 +377,16 @@ program
377377async function runInteractive ( ) {
378378 const client = getSlackClient ( ) ;
379379
380+ // Fetch custom fields on startup
381+ let customFields = { } ;
382+ try {
383+ console . log ( '🔄 Fetching available fields...\n' ) ;
384+ const fields = await client . getTeamProfile ( ) ;
385+ customFields = fields || { } ;
386+ } catch ( error ) {
387+ console . log ( '⚠️ Could not fetch custom fields, but you can still enter field IDs manually\n' ) ;
388+ }
389+
380390 while ( true ) {
381391 console . log ( '🚀 Slack Profile CLI - Interactive Mode\n' ) ;
382392
@@ -462,7 +472,6 @@ async function runInteractive() {
462472 }
463473
464474 if ( action === 'list' ) {
465- const fields = await client . getTeamProfile ( ) ;
466475 console . log ( '\n📋 Available profile fields:' ) ;
467476 console . log ( '\nStandard fields:' ) ;
468477 const standardFields = [
@@ -473,9 +482,9 @@ async function runInteractive() {
473482 console . log ( ` • ${ field } ` ) ;
474483 } ) ;
475484
476- if ( fields && Object . keys ( fields ) . length > 0 ) {
485+ if ( customFields && Object . keys ( customFields ) . length > 0 ) {
477486 console . log ( '\nCustom fields:' ) ;
478- Object . entries ( fields ) . forEach ( ( [ id , field ] ) => {
487+ Object . entries ( customFields ) . forEach ( ( [ id , field ] ) => {
479488 console . log ( ` • ${ id } - ${ field . label } (${ field . type } )` ) ;
480489 } ) ;
481490 } else {
@@ -520,15 +529,6 @@ async function runInteractive() {
520529 }
521530
522531 if ( action === 'single' || action === 'batch_single' ) {
523- // Get custom fields for autocomplete
524- let customFields = { } ;
525- try {
526- const fields = await client . getTeamProfile ( ) ;
527- customFields = fields || { } ;
528- } catch ( error ) {
529- console . log ( '⚠️ Could not fetch custom fields, but you can still enter field IDs manually' ) ;
530- }
531-
532532 const standardFields = [
533533 'first_name' , 'last_name' , 'display_name' , 'title' ,
534534 'email' , 'phone' , 'pronouns' , 'real_name' , 'start_date'
0 commit comments