Skip to content

Commit 4b90bc1

Browse files
committed
fix: wrong impl
1 parent cb607f4 commit 4b90bc1

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

DisCatSharp/Entities/Core/DisCatSharpBuilder.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ namespace DisCatSharp.Entities.Core;
1111
/// </summary>
1212
public class DisCatSharpBuilder
1313
{
14-
/// <summary>
15-
/// Component types that Discord only allows inside modal submissions.
16-
/// Note: Checkbox components are allowed only as children of DiscordLabelComponent.
17-
/// </summary>
18-
private static readonly HashSet<ComponentType> s_modalOnlyComponentTypes = [ComponentType.RadioGroup, ComponentType.CheckboxGroup];
19-
2014
/// <summary>
2115
/// The attachments of this builder.
2216
/// </summary>
@@ -271,22 +265,17 @@ internal virtual void Validate()
271265
{
272266
HashSet<int> ids = [];
273267
Dictionary<int, List<string>> duplicateIds = [];
274-
HashSet<ComponentType> modalOnlyUsage = [];
275268

276269
foreach (var component in this.Components)
277270
{
278271
this.CheckComponentIds(component, ids, duplicateIds);
279-
this.CheckModalOnlyComponents(component, modalOnlyUsage);
280272
}
281273

282274
if (duplicateIds.Count > 0)
283275
{
284276
var duplicateDetails = string.Join(", ", duplicateIds.Select(kvp => $"ID: {kvp.Key}, Types: {string.Join(", ", kvp.Value)}"));
285277
throw new AggregateException($"You provided one or more components with the same id. They have to be unique. Duplicates: {duplicateDetails}");
286278
}
287-
288-
if (modalOnlyUsage.Count > 0)
289-
throw new InvalidOperationException($"Component types {string.Join(", ", modalOnlyUsage)} are only valid for modals.");
290279
}
291280
}
292281

@@ -313,20 +302,6 @@ private void CheckComponentIds(DiscordComponent component, HashSet<int> ids, Dic
313302
this.CheckComponentIds(child, ids, duplicateIds);
314303
}
315304

316-
/// <summary>
317-
/// Validates that modal-only components are not used in message contexts.
318-
/// </summary>
319-
/// <param name="component">The component to validate.</param>
320-
/// <param name="modalOnlyUsage">A set of modal-only component types that were found.</param>
321-
private void CheckModalOnlyComponents(DiscordComponent component, ISet<ComponentType> modalOnlyUsage)
322-
{
323-
if (s_modalOnlyComponentTypes.Contains(component.Type))
324-
modalOnlyUsage.Add(component.Type);
325-
326-
foreach (var child in component.GetChildren())
327-
this.CheckModalOnlyComponents(child, modalOnlyUsage);
328-
}
329-
330305
/// <summary>
331306
/// Adds the identifier of the specified <see cref="DiscordComponent" /> to the provided collection of identifiers.
332307
/// </summary>

DisCatSharp/Net/Rest/DiscordApiClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7363,8 +7363,8 @@ internal async Task CreateInteractionModalResponseAsync(ulong interactionId, str
73637363
var oldHook = builder.Components.All(x => x.Type is ComponentType.ActionRow);
73647364
if (oldHook && builder.ModalComponents.Any(mc => mc.Components.Any(c => c.Type is not ComponentType.TextInput)))
73657365
throw new NotSupportedException("Can't send any other type than Input Text as Modal Component.");
7366-
else if (!oldHook && builder.Components.Any(x => x.Type is not (ComponentType.Label or ComponentType.TextDisplay or ComponentType.RadioGroup or ComponentType.CheckboxGroup)))
7367-
throw new NotSupportedException("Can't send any other type than Label, Text Display, Radio Group, or Checkbox Group as Modal Component.");
7366+
else if (!oldHook && builder.Components.Any(x => x.Type is not (ComponentType.Label or ComponentType.TextDisplay)))
7367+
throw new NotSupportedException("Can't send any other type than Label or Text Display as Modal Component.");
73687368

73697369
var pld = new RestInteractionModalResponsePayload
73707370
{

0 commit comments

Comments
 (0)