Skip to content

Commit

Permalink
Fix component model options validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Quahu committed Jul 31, 2024
1 parent 971e634 commit 6db87ea
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
{
Expand Down

0 comments on commit 6db87ea

Please sign in to comment.