From 6db87eac30ab212d7b3f786d4d64ec5c9d83d375 Mon Sep 17 00:00:00 2001 From: Quahu Date: Wed, 31 Jul 2024 16:45:46 +0200 Subject: [PATCH] Fix component model options validation --- .../Interactions/Components/ComponentJsonModel.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs b/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs index 34d7c3529..54f55167a 100644 --- a/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs +++ b/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs @@ -116,11 +116,18 @@ protected override void OnValidate() } case ComponentType.StringSelection or >= ComponentType.UserSelection and <= ComponentType.ChannelSelection: { - OptionalGuard.HasValue(Options); - Guard.IsLessThanOrEqualTo(Options.Value.Length, Discord.Limits.Component.Selection.MaxOptionAmount); + if (Type == ComponentType.StringSelection) + { + OptionalGuard.HasValue(Options); + Guard.IsLessThanOrEqualTo(Options.Value.Length, Discord.Limits.Component.Selection.MaxOptionAmount); - for (var i = 0; i < Options.Value.Length; i++) - Options.Value[i].Validate(); + for (var i = 0; i < Options.Value.Length; i++) + Options.Value[i].Validate(); + } + else + { + OptionalGuard.HasNoValue(Options, "Options are not supported by entity selection components."); + } OptionalGuard.CheckValue(Placeholder, placeholder => {