@@ -4,6 +4,7 @@ import { filterForUnassigned } from "@src/items";
44import logger from "@config/logger" ;
55import { can } from "../authz" ;
66import { buildIssueButtonRow } from "../builders" ;
7+ import { formatDiscordDate } from "../webhookMessages" ;
78
89export const data = new SlashCommandBuilder ( )
910 . setName ( "unassigned-issues" )
@@ -17,21 +18,29 @@ export const data = new SlashCommandBuilder()
1718 { name : "Today" , value : "today" } ,
1819 { name : "All Time" , value : "all-time" } ,
1920 ) ,
21+ )
22+ . addIntegerOption ( ( option ) =>
23+ option
24+ . setName ( "index" )
25+ . setDescription ( "Index of the specific issue to display" )
26+ . setRequired ( false ) ,
2027 ) ;
2128
2229export async function execute ( interaction : CommandInteraction ) {
2330 if ( ! can ( interaction ) ) {
2431 await interaction . reply ( {
25- content : "You do not have permission to create an issue ." ,
32+ content : "You do not have permission to view issues ." ,
2633 ephemeral : true ,
2734 } ) ;
2835 return ;
2936 }
3037
3138 await interaction . deferReply ( { ephemeral : true } ) ;
3239
33- //@ts -ignore // TODO fix this ignore
40+ // @ts -ignore // TODO: Fix types
3441 const dateRange = interaction . options . getString ( "date-range" , true ) ;
42+ // @ts -ignore
43+ const issueIndex = interaction . options . getInteger ( "index" ) ;
3544
3645 const githubItemsResult = await GithubAPI . fetchProjectItems ( ) ;
3746 if ( githubItemsResult . err ) {
@@ -67,27 +76,45 @@ export async function execute(interaction: CommandInteraction) {
6776 return ;
6877 }
6978
70- const limitedItems = unassignedItems . slice ( 0 , 5 ) ;
71-
72- await interaction . editReply ( {
73- content : `📋 Showing ${ limitedItems . length } unassigned issue(s).` ,
74- } ) ;
79+ if ( issueIndex !== null ) {
80+ if ( issueIndex < 0 || issueIndex >= unassignedItems . length ) {
81+ await interaction . editReply ( {
82+ content : `❌ Invalid issue index. Please use a number between 0 and ${ unassignedItems . length - 1 } .` ,
83+ } ) ;
84+ return ;
85+ }
7586
76- for ( const item of limitedItems ) {
87+ const item = unassignedItems [ issueIndex ] ;
7788 const link = item . url ?? "https://github.com/" ;
7889
7990 const buttons = buildIssueButtonRow ( item . githubIssueId , link , [
8091 "assign" ,
8192 "open" ,
8293 ] ) ;
8394
84- await interaction . followUp ( {
85- content : `## ${ item . title } ` ,
95+ await interaction . editReply ( {
96+ content : `📌 **Issue # ${ issueIndex } **\n ## ${ item . title } ` ,
8697 components : [ buttons ] ,
87- ephemeral : true ,
8898 } ) ;
99+
100+ return ;
89101 }
90102
103+ // Show list of issues with index numbers
104+ const list = unassignedItems
105+ . map ( ( item , idx ) => {
106+ const titleWithLink = `[${ item . title } ](<${ item . url } >)` ;
107+ const due = item . dueDate ? formatDiscordDate ( item . dueDate ) : "" ;
108+ const status = item . status ?? "" ;
109+
110+ return `\`${ idx } \` — ${ titleWithLink } ${ due ? ` - ${ due } ` : "" } ${ status ? ` - ${ status } ` : "" } ` ;
111+ } )
112+ . join ( "\n" ) ;
113+
114+ await interaction . editReply ( {
115+ content : `📋 ${ unassignedItems . length } unassigned issue(s) found:\n\n${ list } \n\nUse \`/unassigned-issues date-range:${ dateRange } index:<number>\` to view a specific issue.` ,
116+ } ) ;
117+
91118 logger . info ( {
92119 event : "unassignedIssues.success" ,
93120 body : `${ unassignedItems . length } unassigned issues returned.` ,
0 commit comments