@@ -14,6 +14,7 @@ import {
1414 SelectMenuComponent ,
1515 InteractionCollector ,
1616 SelectMenuInteraction ,
17+ InteractionReplyOptions ,
1718 WebhookEditMessageOptions ,
1819 MessageComponentInteraction ,
1920 ChatInputCommandInteraction ,
@@ -239,7 +240,7 @@ export class PagesBuilder extends EmbedBuilder {
239240
240241 resultPage . setFooter ( {
241242 ...resultPage . data . footer ,
242- text : pageNumber
243+ text : ` ${ pageNumber } ${ pageNumber ? ' • ' : '' } ${ resultPage . data . footer ?. text } `
243244 } ) ;
244245 }
245246
@@ -541,7 +542,7 @@ export class PagesBuilder extends EmbedBuilder {
541542 /**
542543 * Build method
543544 */
544- async build ( ) : Promise < void | Message | APIMessage > {
545+ async build ( options : Pick < InteractionReplyOptions , 'ephemeral' > = { } ) : Promise < void | Message | APIMessage > {
545546 if ( this . pages . length === 0 ) {
546547 throw new TypeError ( 'Pages not set' ) ;
547548 }
@@ -560,7 +561,8 @@ export class PagesBuilder extends EmbedBuilder {
560561 components : this . simplifyKeyboard ( [
561562 ...this . defaultButtons ,
562563 ...this . components
563- ] )
564+ ] ) ,
565+ ...options
564566 } )
565567 . then ( ( message ) => {
566568 if ( message ) {
@@ -674,7 +676,19 @@ export class PagesBuilder extends EmbedBuilder {
674676 this . handleSelectMenuComponent ( event ) ;
675677 }
676678 } )
677- . on ( 'end' , async ( ) => {
679+ . on ( 'end' , async ( collection ) => {
680+ const messageComponentId = this . messageComponent ?. id ;
681+
682+ if ( ! messageComponentId ) {
683+ return ;
684+ }
685+
686+ const interaction = collection . get ( messageComponentId ) ;
687+
688+ if ( ! interaction ) {
689+ return ;
690+ }
691+
678692 switch ( this . endMethod ) {
679693 case EndMethod . EDIT : {
680694 const embeds = await this . getPage ( ) ;
@@ -683,27 +697,27 @@ export class PagesBuilder extends EmbedBuilder {
683697
684698 embed . setColor ( this . endColor ) ;
685699
686- this . message . edit ( {
700+ interaction . editReply ( {
687701 embeds,
688702 components : [ ]
689703 } )
690704 . catch ( ( ) => null ) ;
691705 break ;
692706 }
693707 case EndMethod . REMOVE_COMPONENTS :
694- this . message . edit ( {
708+ interaction . editReply ( {
695709 components : [ ]
696710 } )
697711 . catch ( ( ) => null ) ;
698712 break ;
699713 case EndMethod . REMOVE_EMBEDS :
700- this . message . edit ( {
714+ interaction . editReply ( {
701715 embeds : [ ]
702716 } )
703717 . catch ( ( ) => null ) ;
704718 break ;
705719 case EndMethod . DELETE :
706- this . message . delete ( )
720+ interaction . deleteReply ( )
707721 . catch ( ( ) => null ) ;
708722 break ;
709723 }
0 commit comments