@@ -201,7 +201,7 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
201201 throw new ArgumentException ( "Provided message does not contain any components." ) ;
202202 }
203203
204- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( c => c . Type is DiscordComponentType . Button ) )
204+ if ( message . FilterComponents < DiscordButtonComponent > ( ) . Count == 0 )
205205 {
206206 throw new ArgumentException ( "Provided message does not contain any button components." ) ;
207207 }
@@ -246,12 +246,12 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
246246 throw new ArgumentException ( "Provided message does not contain any components." ) ;
247247 }
248248
249- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( c => c . Type is DiscordComponentType . Button ) )
249+ if ( message . FilterComponents < DiscordButtonComponent > ( ) . Count == 0 )
250250 {
251251 throw new ArgumentException ( "Provided message does not contain any button components." ) ;
252252 }
253253
254- IEnumerable < string > ids = message . Components . SelectMany ( m => m . Components ) . Select ( c => c . CustomId ) ;
254+ IEnumerable < string > ids = message . FilterComponents < DiscordComponent > ( ) . Select ( c => c . CustomId ) ;
255255
256256 ComponentInteractionCreatedEventArgs ? result =
257257 await
@@ -295,7 +295,7 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
295295 throw new ArgumentException ( "Provided message does not contain any components." ) ;
296296 }
297297
298- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( c => c . Type is DiscordComponentType . Button ) )
298+ if ( message . FilterComponents < DiscordButtonComponent > ( ) . Count == 0 )
299299 {
300300 throw new ArgumentException ( "Provided message does not contain any button components." ) ;
301301 }
@@ -342,12 +342,12 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
342342 throw new ArgumentException ( "Provided message does not contain any components." ) ;
343343 }
344344
345- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( c => c . Type is DiscordComponentType . Button ) )
345+ if ( message . FilterComponents < DiscordButtonComponent > ( ) . Count == 0 )
346346 {
347347 throw new ArgumentException ( "Provided message does not contain any button components." ) ;
348348 }
349349
350- if ( ! message . Components . SelectMany ( c => c . Components ) . OfType < DiscordButtonComponent > ( ) . Any ( c => c . CustomId == id ) )
350+ if ( ! message . FilterComponents < DiscordButtonComponent > ( ) . Any ( c => c . CustomId == id ) )
351351 {
352352 throw new ArgumentException ( $ "Provided message does not contain button with Id of '{ id } '.") ;
353353 }
@@ -387,7 +387,7 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
387387 throw new ArgumentException ( "Provided message does not contain any components." ) ;
388388 }
389389
390- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( c => c . Type is DiscordComponentType . Button ) )
390+ if ( message . FilterComponents < DiscordButtonComponent > ( ) . Count == 0 )
391391 {
392392 throw new ArgumentException ( "Provided message does not contain any button components." ) ;
393393 }
@@ -429,7 +429,7 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
429429 throw new ArgumentException ( "Provided message does not contain any components." ) ;
430430 }
431431
432- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( IsSelect ) )
432+ if ( ! message . FilterComponents < DiscordComponent > ( ) . Any ( IsSelect ) )
433433 {
434434 throw new ArgumentException ( "Provided message does not contain any select components." ) ;
435435 }
@@ -472,12 +472,12 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
472472 throw new ArgumentException ( "Provided message does not contain any components." ) ;
473473 }
474474
475- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( IsSelect ) )
475+ if ( ! message . FilterComponents < DiscordComponent > ( ) . Any ( IsSelect ) )
476476 {
477477 throw new ArgumentException ( "Provided message does not contain any select components." ) ;
478478 }
479479
480- if ( message . Components . SelectMany ( c => c . Components ) . Where ( IsSelect ) . All ( c => c . CustomId != id ) )
480+ if ( message . FilterComponents < DiscordComponent > ( ) . Where ( IsSelect ) . All ( c => c . CustomId != id ) )
481481 {
482482 throw new ArgumentException ( $ "Provided message does not contain select component with Id of '{ id } '.") ;
483483 }
@@ -532,12 +532,12 @@ public async Task<InteractivityResult<ComponentInteractionCreatedEventArgs>> Wai
532532 throw new ArgumentException ( "Provided message does not contain any components." ) ;
533533 }
534534
535- if ( ! message . Components . SelectMany ( c => c . Components ) . Any ( IsSelect ) )
535+ if ( ! message . FilterComponents < DiscordComponent > ( ) . Any ( IsSelect ) )
536536 {
537537 throw new ArgumentException ( "Provided message does not contain any select components." ) ;
538538 }
539539
540- if ( message . Components . SelectMany ( c => c . Components ) . Where ( IsSelect ) . All ( c => c . CustomId != id ) )
540+ if ( message . FilterComponents < DiscordComponent > ( ) . Where ( IsSelect ) . All ( c => c . CustomId != id ) )
541541 {
542542 throw new ArgumentException ( $ "Provided message does not contain button with Id of '{ id } '.") ;
543543 }
0 commit comments