Table of Contents

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

radioGroup RadioGroupComponent

The 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

customId string

The custom id of the current radio group.

options IEnumerable<RadioGroupOptionProperties>

The options for this radio group.

isRequired bool?

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

id int?

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

int

MinOptionCount

Gets the minimum amount of options a radio group must have.

public const int MinOptionCount = 2

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

List<RadioGroupOptionProperties>

Type

Gets the type of the component.

public ComponentType Type { get; }

Property Value

ComponentType

Methods

AddOption(RadioGroupOptionProperties)

Adds one option to the radio group.

public RadioGroupBuilder AddOption(RadioGroupOptionProperties option)

Parameters

option RadioGroupOptionProperties

The 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

label string

The label for this option.

value string

The value of this option.

description string

The description of this option

isDefault bool?

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

RadioGroupComponent

WithCustomId(string)

Sets the custom id of the current radio group.

public RadioGroupBuilder WithCustomId(string customId)

Parameters

customId string

The 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

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

isRequired bool?

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

Returns

RadioGroupBuilder

The current builder.