diff --git a/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs b/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs index 54f55167a..6b995b457 100644 --- a/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs +++ b/src/Disqord.Core/Models/Interactions/Components/ComponentJsonModel.cs @@ -119,14 +119,24 @@ protected override void OnValidate() if (Type == ComponentType.StringSelection) { OptionalGuard.HasValue(Options); - Guard.IsLessThanOrEqualTo(Options.Value.Length, Discord.Limits.Component.Selection.MaxOptionAmount); + Guard.HasSizeLessThanOrEqualTo(Options.Value, Discord.Limits.Component.Selection.MaxOptionAmount); 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(Options, options => + { + try + { + Guard.HasSizeEqualTo(options, 0); + } + catch (Exception ex) + { + throw new ArgumentException("Options are not supported by entity selection components.", ex); + } + }); } OptionalGuard.CheckValue(Placeholder, placeholder => diff --git a/src/Disqord.Extensions.Interactivity/Menus/View/Components/SelectionViewComponent.cs b/src/Disqord.Extensions.Interactivity/Menus/View/Components/SelectionViewComponent.cs index 0022931fe..4d48315ae 100644 --- a/src/Disqord.Extensions.Interactivity/Menus/View/Components/SelectionViewComponent.cs +++ b/src/Disqord.Extensions.Interactivity/Menus/View/Components/SelectionViewComponent.cs @@ -189,7 +189,6 @@ protected internal override LocalComponent ToLocalComponent() MinimumSelectedOptions = Optional.FromNullable(_minimumSelectedOptions), MaximumSelectedOptions = Optional.FromNullable(_maximumSelectedOptions), IsDisabled = _isDisabled, - Options = _options.ToArray() }; if (_type is SelectionComponentType.Channel or SelectionComponentType.Mentionable @@ -198,6 +197,11 @@ protected internal override LocalComponent ToLocalComponent() selection.WithChannelTypes(_channelTypes); } + if (_type != SelectionComponentType.String) + { + selection.WithOptions(_options); + } + return selection; } }