Class CheckboxGroupBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a builder used to create a CheckboxGroupComponent.
public class CheckboxGroupBuilder : IInteractableComponentBuilder, IMessageComponentBuilder
- Inheritance
-
CheckboxGroupBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
CheckboxGroupBuilder()
Initializes a new instance of the CheckboxGroupBuilder.
public CheckboxGroupBuilder()
CheckboxGroupBuilder(CheckboxGroupComponent)
Initializes a new instance of the CheckboxGroupBuilder class from an existing CheckboxGroupComponent.
public CheckboxGroupBuilder(CheckboxGroupComponent checkboxGroup)
Parameters
checkboxGroupCheckboxGroupComponentThe component.
CheckboxGroupBuilder(string, IEnumerable<CheckboxGroupOptionProperties>, int?, int?, bool?, int?)
Initializes a new instance of the CheckboxGroupBuilder.
public CheckboxGroupBuilder(string customId, IEnumerable<CheckboxGroupOptionProperties> options = null, int? minValues = null, int? maxValues = null, bool? isRequired = null, int? id = null)
Parameters
customIdstringThe custom id of the current checkbox group.
optionsIEnumerable<CheckboxGroupOptionProperties>The options for this checkbox group.
minValuesint?The minimum number of options that must be selected.
maxValuesint?The maximum number of options that can be selected.
isRequiredbool?Whether the current checkbox group requires selection before submitting the modal.
idint?The id for the component.
Fields
MaxOptionCount
Gets the maximum number of options a checkbox group can have.
public const int MaxOptionCount = 10
Field Value
MinOptionCount
Gets the minimum number of options a checkbox group must have.
public const int MinOptionCount = 1
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 checkbox group has to be filled in before submitting the modal (defaults to true).
public bool? IsRequired { get; set; }
Property Value
- bool?
MaxValues
Gets or sets the minimum number of options to be checked.
public int? MaxValues { get; set; }
Property Value
- int?
Exceptions
- ArgumentException
MaxValues exceeds MaxOptionCount.
- ArgumentException
MaxValues length subceeds MinOptionCount.
MinValues
Gets or sets the minimum number of options to be checked.
public int? MinValues { get; set; }
Property Value
- int?
Exceptions
- ArgumentException
MinValues exceeds MaxOptionCount.
- ArgumentException
MinValues length subceeds 0.
Options
Gets or sets the options for this checkbox group.
public List<CheckboxGroupOptionProperties> Options { get; set; }
Property Value
Type
Gets the type of the component.
public ComponentType Type { get; }
Property Value
Methods
AddOption(CheckboxGroupOptionProperties)
Adds one option to the checkbox group.
public CheckboxGroupBuilder AddOption(CheckboxGroupOptionProperties option)
Parameters
optionCheckboxGroupOptionPropertiesThe option to add.
Returns
- CheckboxGroupBuilder
The current builder.
Exceptions
- InvalidOperationException
Options count reached MaxOptionCount.
AddOption(string, string, string, bool?)
Adds one option to the checkbox group.
public CheckboxGroupBuilder AddOption(string label, string value, string description = null, bool? defaultState = null)
Parameters
labelstringThe label for this option.
valuestringThe value of this option.
descriptionstringThe description of this option
defaultStatebool?Whether this option is checked by default.
Returns
- CheckboxGroupBuilder
The current builder.
Exceptions
- InvalidOperationException
Options count reached MaxOptionCount.
Build()
Runs validation checks and builds the component.
public CheckboxGroupComponent Build()
Returns
WithCustomId(string)
Sets the custom id of the current checkbox.
public CheckboxGroupBuilder WithCustomId(string customId)
Parameters
customIdstringThe id to use for the current checkbox.
Returns
- CheckboxGroupBuilder
The current builder.
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength.
- ArgumentException
CustomId length subceeds 1.
WithMaxValues(int?)
Sets the maximum number of options that can be selected.
public CheckboxGroupBuilder WithMaxValues(int? maxValues)
Parameters
maxValuesint?The maximum number of options that must be selected.
Returns
- CheckboxGroupBuilder
The current builder.
WithMinValues(int?)
Sets the minimum number of options that must be selected.
public CheckboxGroupBuilder WithMinValues(int? minValues)
Parameters
minValuesint?The minimum number of options that must be selected.
Returns
- CheckboxGroupBuilder
The current builder.
Exceptions
- ArgumentException
MinValues exceeds MaxOptionCount.
- ArgumentException
MinValues length subceeds 0.
WithOptions(params List<CheckboxGroupOptionProperties>)
Sets the options for this checkbox group.
public CheckboxGroupBuilder WithOptions(params List<CheckboxGroupOptionProperties> options)
Parameters
optionsList<CheckboxGroupOptionProperties>The options to set.
Returns
- CheckboxGroupBuilder
The current builder.
Exceptions
- ArgumentException
Options count exceeds MaxOptionCount.
WithRequired(bool?)
Sets whether the current checkbox group requires selection before submitting the modal.
public CheckboxGroupBuilder WithRequired(bool? isRequired)
Parameters
isRequiredbool?Sets whether the current checkbox group requires selection before submitting the modal.
Returns
- CheckboxGroupBuilder
The current builder.