@@ -74,7 +74,7 @@ export async function deliverDiscordInteractionReply(params: {
7474 preferFollowUp : boolean ;
7575 responseEphemeral ?: boolean ;
7676 chunkMode : "length" | "newline" ;
77- } ) {
77+ } ) : Promise < boolean > {
7878 const { interaction, payload, textLimit, maxLinesPerMessage, preferFollowUp, chunkMode } = params ;
7979 const reply = resolveSendableOutboundReplyParts ( payload ) ;
8080 const discordData = payload . channelData ?. discord as
@@ -115,17 +115,19 @@ export async function deliverDiscordInteractionReply(params: {
115115 ? { ephemeral : params . responseEphemeral }
116116 : { } ) ,
117117 } ;
118- await safeDiscordInteractionCall ( "interaction send" , async ( ) => {
118+ const result = await safeDiscordInteractionCall ( "interaction send" , async ( ) => {
119119 if ( ! preferFollowUp && ! hasReplied ) {
120120 await interaction . reply ( payload ) ;
121121 hasReplied = true ;
122122 firstMessageComponents = undefined ;
123- return ;
123+ return true ;
124124 }
125125 await interaction . followUp ( payload ) ;
126126 hasReplied = true ;
127127 firstMessageComponents = undefined ;
128+ return true ;
128129 } ) ;
130+ return result === true ;
129131 } ;
130132
131133 if ( reply . hasMedia ) {
@@ -149,18 +151,18 @@ export async function deliverDiscordInteractionReply(params: {
149151 } ) ,
150152 ) ;
151153 const caption = chunks [ 0 ] ?? "" ;
152- await sendMessage ( caption , media , firstMessageComponents ) ;
154+ let delivered = await sendMessage ( caption , media , firstMessageComponents ) ;
153155 for ( const chunk of chunks . slice ( 1 ) ) {
154156 if ( ! chunk . trim ( ) ) {
155157 continue ;
156158 }
157- await sendMessage ( chunk ) ;
159+ delivered = ( await sendMessage ( chunk ) ) || delivered ;
158160 }
159- return ;
161+ return delivered ;
160162 }
161163
162164 if ( ! reply . hasText && ! firstMessageComponents ) {
163- return ;
165+ return false ;
164166 }
165167 let chunks =
166168 reply . text || firstMessageComponents
@@ -176,10 +178,12 @@ export async function deliverDiscordInteractionReply(params: {
176178 if ( chunks . length === 0 && firstMessageComponents ) {
177179 chunks = [ "" ] ;
178180 }
181+ let delivered = false ;
179182 for ( const chunk of chunks ) {
180183 if ( ! chunk . trim ( ) && ! firstMessageComponents ) {
181184 continue ;
182185 }
183- await sendMessage ( chunk , undefined , firstMessageComponents ) ;
186+ delivered = ( await sendMessage ( chunk , undefined , firstMessageComponents ) ) || delivered ;
184187 }
188+ return delivered ;
185189}
0 commit comments