Class RadioGroupBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a builder used to create a RadioGroupComponent.
public class RadioGroupBuilder : IInteractableComponentBuilder, IMessageComponentBuilder
- Inheritance
-
RadioGroupBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
RadioGroupBuilder()
Initializes a new instance of the RadioGroupBuilder.
public RadioGroupBuilder()
RadioGroupBuilder(RadioGroupComponent)
Initializes a new instance of the RadioGroupBuilder class from an existing RadioGroupComponent.
public RadioGroupBuilder(RadioGroupComponent radioGroup)
Parameters
radioGroupRadioGroupComponentThe component.
RadioGroupBuilder(string, IEnumerable<RadioGroupOptionProperties>, bool?, int?)
Initializes a new instance of the RadioGroupBuilder.
public RadioGroupBuilder(string customId, IEnumerable<RadioGroupOptionProperties> options = null, bool? isRequired = null, int? id = null)
Parameters
customIdstringThe custom id of the current radio group.
optionsIEnumerable<RadioGroupOptionProperties>The options for this radio group.
isRequiredbool?Whether the current radio group requires selection before submitting the modal.
idint?The id for the component.
Fields
MaxOptionCount
Gets the maximum amount of options a radio group can have.
public const int MaxOptionCount = 10
Field Value
MinOptionCount
Gets the minimum amount of options a radio group must have.
public const int MinOptionCount = 2
Field Value
Properties
CustomId
Gets or sets the custom id of the current file upload.
public string CustomId { get; set; }
Property Value
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength.
- ArgumentException
CustomId length subceeds 1.
Id
Gets or sets the id for the component. An autoincremented id will be assigned if not set.
public int? Id { get; set; }
Property Value
- int?
IsRequired
Gets or sets a value indicating whether the current radio group has to be filled in before submitting the modal (defaults to true).
public bool? IsRequired { get; set; }
Property Value
- bool?
Options
Gets or sets the options for this radio group.
public List<RadioGroupOptionProperties> Options { get; set; }
Property Value
Type
Gets the type of the component.
public ComponentType Type { get; }
Property Value
Methods
AddOption(RadioGroupOptionProperties)
Adds one option to the radio group.
public RadioGroupBuilder AddOption(RadioGroupOptionProperties option)
Parameters
optionRadioGroupOptionPropertiesThe option to add.
Returns
- RadioGroupBuilder
The current builder.
Exceptions
- InvalidOperationException
Options count reached MaxOptionCount.
AddOption(string, string, string, bool?)
Adds one option to the radio group.
public RadioGroupBuilder AddOption(string label, string value, string description = null, bool? isDefault = null)
Parameters
labelstringThe label for this option.
valuestringThe value of this option.
descriptionstringThe description of this option
isDefaultbool?Whether this option is selected by default.
Returns
- RadioGroupBuilder
The current builder.
Exceptions
- InvalidOperationException
Options count reached MaxOptionCount.
Build()
Runs validation checks and builds the component.
public RadioGroupComponent Build()
Returns
WithCustomId(string)
Sets the custom id of the current radio group.
public RadioGroupBuilder WithCustomId(string customId)
Parameters
customIdstringThe id to use for the current radio group.
Returns
- RadioGroupBuilder
The current builder.
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength.
- ArgumentException
CustomId length subceeds 1.
WithOptions(params List<RadioGroupOptionProperties>)
Sets the options for this radio group.
public RadioGroupBuilder WithOptions(params List<RadioGroupOptionProperties> options)
Parameters
optionsList<RadioGroupOptionProperties>The options to set.
Returns
- RadioGroupBuilder
The current builder.
Exceptions
- ArgumentException
Options count exceeds MaxOptionCount.
WithRequired(bool?)
Sets whether the current radio group requires selection before submitting the modal.
public RadioGroupBuilder WithRequired(bool? isRequired)
Parameters
isRequiredbool?Sets whether the current radio group requires selection before submitting the modal.
Returns
- RadioGroupBuilder
The current builder.