Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DisCatSharp/Entities/Components/DiscordLabelComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public DiscordLabelComponent WithFileUploadComponent(DiscordFileUploadComponent
}

/// <summary>
/// Sets the radio group component for the label.
/// Sets the radio group component for the label.
/// </summary>
/// <param name="component">The radio group component to attach to the label.</param>
public DiscordLabelComponent WithRadioGroupComponent(DiscordRadioGroupComponent component)
Expand All @@ -88,7 +88,7 @@ public DiscordLabelComponent WithRadioGroupComponent(DiscordRadioGroupComponent
}

/// <summary>
/// Sets the checkbox group component for the label.
/// Sets the checkbox group component for the label.
/// </summary>
/// <param name="component">The checkbox group component to attach to the label.</param>
public DiscordLabelComponent WithCheckboxGroupComponent(DiscordCheckboxGroupComponent component)
Expand All @@ -98,7 +98,7 @@ public DiscordLabelComponent WithCheckboxGroupComponent(DiscordCheckboxGroupComp
}

/// <summary>
/// Sets the checkbox component for the label.
/// Sets the checkbox component for the label.
/// </summary>
/// <param name="component">The checkbox component to attach to the label.</param>
public DiscordLabelComponent WithCheckboxComponent(DiscordCheckboxComponent component)
Expand Down Expand Up @@ -126,7 +126,7 @@ public DiscordLabelComponent WithCheckboxComponent(DiscordCheckboxComponent comp
public ILabelComponent Component { get; internal set; }

/// <summary>
/// Helper to determine whether a <see cref="DiscordTextInputComponent"/> or <see cref="DiscordBaseSelectComponent"/> is attached to the label.
/// Helper to determine the type of component attached to the label (e.g., <see cref="DiscordTextInputComponent"/>, <see cref="DiscordBaseSelectComponent"/>, <see cref="DiscordRadioGroupComponent"/>, <see cref="DiscordCheckboxGroupComponent"/>, <see cref="DiscordCheckboxComponent"/>, or <see cref="DiscordFileUploadComponent"/>).
/// </summary>
[JsonIgnore]
public ComponentType SubComponentType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public DiscordCheckboxGroupComponent(IEnumerable<DiscordCheckboxGroupComponentOp
/// The minimum number of selections.
/// </summary>
[JsonProperty("min_values", NullValueHandling = NullValueHandling.Ignore)]
public int? MinimumValues { get; internal set; } = 1;
public int? MinimumValues { get; internal set; } = 0;

/// <summary>
/// The maximum number of selections.
Expand Down
3 changes: 2 additions & 1 deletion DisCatSharp/Entities/Core/DisCatSharpBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public class DisCatSharpBuilder
{
/// <summary>
/// Component types that Discord only allows inside modal submissions.
/// Note: Checkbox components are allowed only as children of DiscordLabelComponent.
/// </summary>
private static readonly HashSet<ComponentType> s_modalOnlyComponentTypes = [ComponentType.RadioGroup, ComponentType.CheckboxGroup, ComponentType.Checkbox];
private static readonly HashSet<ComponentType> s_modalOnlyComponentTypes = [ComponentType.RadioGroup, ComponentType.CheckboxGroup];

/// <summary>
/// The attachments of this builder.
Expand Down
6 changes: 3 additions & 3 deletions DisCatSharp/Enums/Interaction/ComponentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ public enum ComponentType
CheckpointCard = 20,

/// <summary>
/// A radio group.
/// A radio group.
/// </summary>
RadioGroup = 21,

/// <summary>
/// A checkbox group.
/// A checkbox group.
/// </summary>
CheckboxGroup = 22,

/// <summary>
/// A checkbox.
/// A checkbox.
/// </summary>
Checkbox = 23
}
6 changes: 3 additions & 3 deletions DisCatSharp/Net/Rest/DiscordApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7362,9 +7362,9 @@ internal async Task CreateInteractionModalResponseAsync(ulong interactionId, str
{
var oldHook = builder.Components.All(x => x.Type is ComponentType.ActionRow);
if (oldHook && builder.ModalComponents.Any(mc => mc.Components.Any(c => c.Type is not ComponentType.TextInput)))
throw new NotSupportedException("Can't send any other type then Input Text as Modal Component.");
else if (!oldHook && builder.Components.Any(x => x.Type is not (ComponentType.Label or ComponentType.TextDisplay or ComponentType.RadioGroup or ComponentType.CheckboxGroup or ComponentType.Checkbox)))
throw new NotSupportedException("Can't send any other type then Label, Text Display, Radio Group, Checkbox Group or Checkbox as Modal Component.");
throw new NotSupportedException("Can't send any other type than Input Text as Modal Component.");
else if (!oldHook && builder.Components.Any(x => x.Type is not (ComponentType.Label or ComponentType.TextDisplay or ComponentType.RadioGroup or ComponentType.CheckboxGroup)))
throw new NotSupportedException("Can't send any other type than Label, Text Display, Radio Group, or Checkbox Group as Modal Component.");

var pld = new RestInteractionModalResponsePayload
{
Expand Down
6 changes: 3 additions & 3 deletions DisCatSharp/Net/Serialization/ILabelComponentJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public override bool CanConvert(Type objectType)
ComponentType.ChannelSelect => job.ToObject<DiscordChannelSelectComponent>(serializer),
ComponentType.MentionableSelect => job.ToObject<DiscordMentionableSelectComponent>(serializer),
ComponentType.FileUpload => job.ToObject<DiscordFileUploadComponent>(serializer),
ComponentType.RadioGroup => job.ToObject<DiscordRadioGroupComponent>(serializer),
ComponentType.CheckboxGroup => job.ToObject<DiscordCheckboxGroupComponent>(serializer),
ComponentType.Checkbox => job.ToObject<DiscordCheckboxComponent>(serializer),
ComponentType.RadioGroup => job.ToObject<DiscordRadioGroupComponent>(serializer),
ComponentType.CheckboxGroup => job.ToObject<DiscordCheckboxGroupComponent>(serializer),
ComponentType.Checkbox => job.ToObject<DiscordCheckboxComponent>(serializer),
_ => throw new JsonSerializationException($"Unknown ILabelComponent type: {type}")
};

Expand Down