File tree Expand file tree Collapse file tree 3 files changed +37
-14
lines changed
Expand file tree Collapse file tree 3 files changed +37
-14
lines changed Original file line number Diff line number Diff line change @@ -337,13 +337,20 @@ export async function createDiscordBot(
337337 // Handle continue with session ID pattern: "continue:sessionId"
338338 if ( buttonId . startsWith ( 'continue:' ) ) {
339339 const sessionId = buttonId . split ( ':' ) [ 1 ] ;
340- const continueHandler = buttonHandlers . get ( 'continue' ) ;
341- if ( continueHandler ) {
342- try {
343- await continueHandler ( ctx ) ;
344- } catch ( error ) {
345- console . error ( `Error handling continue button:` , error ) ;
346- }
340+ try {
341+ await ctx . update ( {
342+ embeds : [ {
343+ color : 0xffff00 ,
344+ title : '\u27a1\ufe0f Continue Session' ,
345+ description : `Use \`/continue\` or \`/claude session_id:${ sessionId } \` to continue this conversation.` ,
346+ fields : [
347+ { name : 'Session ID' , value : `\`${ sessionId } \`` , inline : false }
348+ ] ,
349+ timestamp : true
350+ } ]
351+ } ) ;
352+ } catch ( error ) {
353+ console . error ( `Error handling continue button:` , error ) ;
347354 }
348355 return ;
349356 }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export interface PaginationState {
1818 totalPages : number ;
1919 content : string [ ] ;
2020 options : PaginationOptions ;
21+ title : string ;
2122 messageId ?: string ;
2223}
2324
@@ -203,7 +204,8 @@ export function initializePagination(
203204 currentPage : 0 ,
204205 totalPages : paginatedContent . totalPages ,
205206 content : smartSplit ( content , options . pageSize || 4000 ) ,
206- options
207+ options,
208+ title
207209 } ;
208210
209211 paginationStates . set ( paginationId , paginationState ) ;
@@ -259,7 +261,7 @@ export function handlePaginationInteraction(
259261
260262 // Create new embed for the current page
261263 const paginatedContent = createPaginatedEmbeds (
262- 'Content' , // We'll update this with the original title
264+ state . title ,
263265 state . content [ newPage ] ,
264266 { ...state . options , includePageInfo : true }
265267 ) ;
@@ -269,9 +271,9 @@ export function handlePaginationInteraction(
269271 return {
270272 embed : {
271273 ...paginatedContent . embeds [ 0 ] ,
272- title : state . options . includePageInfo
273- ? `Content (Page ${ newPage + 1 } /${ state . totalPages } )`
274- : 'Content'
274+ title : state . options . includePageInfo !== false
275+ ? `${ state . title } (Page ${ newPage + 1 } /${ state . totalPages } )`
276+ : state . title
275277 } ,
276278 components : buttons . length > 0 ? buttons : undefined
277279 } ;
Original file line number Diff line number Diff line change @@ -9,8 +9,22 @@ export function sanitizeChannelName(name: string): string {
99
1010export function splitText ( text : string , maxLength : number ) : string [ ] {
1111 const chunks : string [ ] = [ ] ;
12- for ( let i = 0 ; i < text . length ; i += maxLength ) {
13- chunks . push ( text . substring ( i , i + maxLength ) ) ;
12+ let current = '' ;
13+
14+ for ( const codePoint of text ) {
15+ if ( ( current + codePoint ) . length > maxLength ) {
16+ if ( current ) {
17+ chunks . push ( current ) ;
18+ }
19+ current = codePoint ;
20+ } else {
21+ current += codePoint ;
22+ }
23+ }
24+
25+ if ( current ) {
26+ chunks . push ( current ) ;
1427 }
28+
1529 return chunks ;
1630}
You can’t perform that action at this time.
0 commit comments