@@ -235,7 +235,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
235235 throw new ArgumentException ( "Provided message does not contain any components." ) ;
236236
237237 string [ ] ? ids = null ;
238-
238+
239239 if ( message . Flags . HasValue && message . Flags . Value . HasMessageFlag ( MessageFlags . IsComponentsV2 ) )
240240 {
241241 if ( message . Components . OfType < DiscordContainerComponent > ( ) . SelectMany ( c => c . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) ) . All ( c => c . Type != ComponentType . Button ) )
@@ -301,7 +301,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
301301 if ( message . Components . Count == 0 )
302302 throw new ArgumentException ( "Provided message does not contain any components." ) ;
303303
304-
304+
305305 if ( message . Flags . HasValue && message . Flags . Value . HasMessageFlag ( MessageFlags . IsComponentsV2 ) )
306306 {
307307 if ( message . Components . OfType < DiscordContainerComponent > ( ) . SelectMany ( c => c . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) ) . All ( c => c . Type != ComponentType . Button ) )
@@ -362,7 +362,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
362362 if ( message . Components . Count is 0 )
363363 throw new ArgumentException ( "Provided message does not contain any components." ) ;
364364
365-
365+
366366 if ( message . Flags . HasValue && message . Flags . Value . HasMessageFlag ( MessageFlags . IsComponentsV2 ) )
367367 {
368368 if ( message . Components . OfType < DiscordContainerComponent > ( ) . SelectMany ( c => c . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) ) . All ( c => c . Type != ComponentType . Button ) )
@@ -468,7 +468,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
468468 else
469469 {
470470 if ( message . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) . All ( c => c . Type != selectType ) )
471- throw new ArgumentException ( "Message does not contain any select components." ) ;
471+ throw new ArgumentException ( "Message does not contain any select components." ) ;
472472 }
473473
474474 var result = await this
@@ -524,7 +524,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
524524 else
525525 {
526526 if ( message . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) . All ( c => c . Type != selectType ) )
527- throw new ArgumentException ( "Message does not contain any select components." ) ;
527+ throw new ArgumentException ( "Message does not contain any select components." ) ;
528528
529529 if ( message . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) . OfType < DiscordBaseSelectComponent > ( ) . All ( c => c . CustomId != id ) )
530530 throw new ArgumentException ( $ "Message does not contain select with Id of '{ id } '.") ;
@@ -584,7 +584,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
584584 else
585585 {
586586 if ( message . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) . All ( c => c . Type != selectType ) )
587- throw new ArgumentException ( "Message does not contain any select components." ) ;
587+ throw new ArgumentException ( "Message does not contain any select components." ) ;
588588
589589 if ( message . Components . OfType < DiscordActionRowComponent > ( ) . SelectMany ( c => c . Components ) . OfType < DiscordBaseSelectComponent > ( ) . All ( c => c . CustomId != id ) )
590590 throw new ArgumentException ( $ "Message does not contain select with Id of '{ id } '.") ;
@@ -970,22 +970,40 @@ public async Task SendPaginatedResponseAsync(DiscordInteraction interaction, boo
970970 {
971971 var page = pages . First ( ) ;
972972 var builder = new DiscordWebhookBuilder ( ) ;
973- if ( page . Content is not null )
974- builder . WithContent ( page . Content ) ;
975- if ( page . Embed is not null )
976- builder . AddEmbed ( page . Embed ) ;
977- builder . AddComponents ( bts . ButtonArray . ToList ( ) ) ;
973+ if ( ! page . UsesCV2 )
974+ {
975+ if ( page . Content is not null )
976+ builder . WithContent ( page . Content ) ;
977+ if ( page . Embed is not null )
978+ builder . AddEmbed ( page . Embed ) ;
979+ builder . AddComponents ( bts . ButtonArray . ToList ( ) ) ;
980+ }
981+ else
982+ {
983+ builder . WithV2Components ( ) ;
984+ builder . AddComponents ( page . ComponentsInternal ) ;
985+ builder . AddComponents ( new DiscordActionRowComponent ( bts . ButtonArray ) ) ;
986+ }
978987 message = await interaction . EditOriginalResponseAsync ( builder ) . ConfigureAwait ( false ) ;
979988 }
980989 else
981990 {
982991 var page = pages . First ( ) ;
983992 var builder = new DiscordInteractionResponseBuilder ( ) ;
984- if ( page . Content is not null )
985- builder . WithContent ( page . Content ) ;
986- if ( page . Embed is not null )
987- builder . AddEmbed ( page . Embed ) ;
988- builder . AddComponents ( bts . ButtonArray . ToList ( ) ) ;
993+ if ( ! page . UsesCV2 )
994+ {
995+ if ( page . Content is not null )
996+ builder . WithContent ( page . Content ) ;
997+ if ( page . Embed is not null )
998+ builder . AddEmbed ( page . Embed ) ;
999+ builder . AddComponents ( bts . ButtonArray . ToList ( ) ) ;
1000+ }
1001+ else
1002+ {
1003+ builder . WithV2Components ( ) ;
1004+ builder . AddComponents ( page . ComponentsInternal ) ;
1005+ builder . AddComponents ( new DiscordActionRowComponent ( bts . ButtonArray ) ) ;
1006+ }
9891007 if ( ephemeral )
9901008 builder = builder . AsEphemeral ( ) ;
9911009 message = ( await interaction . CreateResponseAsync ( InteractionResponseType . ChannelMessageWithSource , builder ) . ConfigureAwait ( false ) ) . Message ! ;
0 commit comments