Table of Contents

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

checkboxGroup CheckboxGroupComponent

The 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

customId string

The custom id of the current checkbox group.

options IEnumerable<CheckboxGroupOptionProperties>

The options for this checkbox group.

minValues int?

The minimum number of options that must be selected.

maxValues int?

The maximum number of options that can be selected.

isRequired bool?

Whether the current checkbox group requires selection before submitting the modal.

id int?

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

int

MinOptionCount

Gets the minimum number of options a checkbox group must have.

public const int MinOptionCount = 1

Field Value

int

Properties

CustomId

Gets or sets the custom id of the current file upload.

public string CustomId { get; set; }

Property Value

string

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

List<CheckboxGroupOptionProperties>

Type

Gets the type of the component.

public ComponentType Type { get; }

Property Value

ComponentType

Methods

AddOption(CheckboxGroupOptionProperties)

Adds one option to the checkbox group.

public CheckboxGroupBuilder AddOption(CheckboxGroupOptionProperties option)

Parameters

option CheckboxGroupOptionProperties

The 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

label string

The label for this option.

value string

The value of this option.

description string

The description of this option

defaultState bool?

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

CheckboxGroupComponent

WithCustomId(string)

Sets the custom id of the current checkbox.

public CheckboxGroupBuilder WithCustomId(string customId)

Parameters

customId string

The 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

maxValues int?

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

minValues int?

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

options List<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

isRequired bool?

Sets whether the current checkbox group requires selection before submitting the modal.

Returns

CheckboxGroupBuilder

The current builder.