1- import {
2- SlashCommandBuilder ,
3- CommandInteraction ,
4- ActionRowBuilder ,
5- ButtonBuilder ,
6- ButtonStyle ,
7- Interaction ,
8- CacheType ,
9- } from "discord.js" ;
1+ import { SlashCommandBuilder , CommandInteraction } from "discord.js" ;
102import { GithubAPI } from "@infrastructure/github" ;
113import { filterForUnassigned } from "@src/items" ;
124import logger from "@config/logger" ;
135import { can } from "../authz" ;
6+ import { buildIssueButtonRow } from "../builders" ;
147
158export const data = new SlashCommandBuilder ( )
169 . setName ( "unassigned-issues" )
@@ -83,24 +76,10 @@ export async function execute(interaction: CommandInteraction) {
8376 for ( const item of limitedItems ) {
8477 const link = item . url ?? "https://github.com/" ;
8578
86- const buttons = new ActionRowBuilder < ButtonBuilder > ( ) . addComponents (
87- new ButtonBuilder ( )
88- . setCustomId ( `issue:edit:${ item . githubId } ` )
89- . setLabel ( "Edit" )
90- . setStyle ( ButtonStyle . Primary ) ,
91- new ButtonBuilder ( )
92- . setCustomId ( `issue:assign:${ item . githubId } ` )
93- . setLabel ( "Assign" )
94- . setStyle ( ButtonStyle . Secondary ) ,
95- new ButtonBuilder ( )
96- . setCustomId ( `issue:delete:${ item . githubId } ` )
97- . setLabel ( "Delete" )
98- . setStyle ( ButtonStyle . Danger ) ,
99- new ButtonBuilder ( )
100- . setLabel ( "Open" )
101- . setStyle ( ButtonStyle . Link )
102- . setURL ( link ) ,
103- ) ;
79+ const buttons = buildIssueButtonRow ( item . githubId , link , [
80+ "assign" ,
81+ "open" ,
82+ ] ) ;
10483
10584 await interaction . followUp ( {
10685 content : `## ${ item . title } ` ,
@@ -114,49 +93,3 @@ export async function execute(interaction: CommandInteraction) {
11493 body : `${ unassignedItems . length } unassigned issues returned.` ,
11594 } ) ;
11695}
117-
118- export async function handleButtonInteraction (
119- interaction : Interaction < CacheType > ,
120- ) {
121- if ( ! interaction . isButton ( ) ) return ;
122-
123- const [ _issue , action , githubId ] = interaction . customId . split ( ":" ) ;
124-
125- if ( ! githubId ) {
126- await interaction . reply ( {
127- content : "⚠️ Invalid button ID." ,
128- ephemeral : true ,
129- } ) ;
130- return ;
131- }
132-
133- switch ( action ) {
134- case "edit" :
135- await interaction . reply ( {
136- content : `✏️ Editing issue with ID \`${ githubId } \` (not yet implemented).` ,
137- ephemeral : true ,
138- } ) ;
139- break ;
140-
141- case "assign" :
142- await interaction . reply ( {
143- content : `👤 Assigning you to issue \`${ githubId } \` (not yet implemented).` ,
144- ephemeral : true ,
145- } ) ;
146- break ;
147-
148- case "delete" :
149- await interaction . reply ( {
150- content : `🗑️ Deleting issue \`${ githubId } \` (not yet implemented).` ,
151- ephemeral : true ,
152- } ) ;
153- break ;
154-
155- default :
156- // logger.warn({ event: "button.unknownAction", action });
157- await interaction . reply ( {
158- content : `❌ Unknown action: \`${ action } \`` ,
159- ephemeral : true ,
160- } ) ;
161- }
162- }
0 commit comments