class RadioGroupBuilder
extends
ComponentBuilder<APIRadioGroupComponent>declare class RadioGroupBuilder extends ComponentBuilder<APIRadioGroupComponent>A builder that creates API-compatible JSON data for radio groups.
Constructors
constructor(data?: Partial<APIRadioGroupComponent>)
data?: Partial<APIRadioGroupComponent>
Creates a new radio group from API data.
Examples:Creating a radio group from an API data object:Creating a radio group using setters and API data:
const radioGroup = new RadioGroupBuilder({
custom_id: 'select_options',
options: [
{ label: 'Option 1', value: 'option_1' },
{ label: 'Option 2', value: 'option_2' },
],
});const radioGroup = new RadioGroupBuilder()
.setCustomId('choose_items')
.setOptions([
{ label: 'Item A', value: 'item_a' },
{ label: 'Item B', value: 'item_b' },
])readonlydata : Partial<APIRadioGroupComponent>
The API data associated with this component.
Inherited from: ComponentBuilder
readonlyoptions : RadioGroupOptionBuilder[]
The options within this radio group.
addOptions(...options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>) : this
...options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>
Adds options to this radio group.
Clears the id of this component, defaulting to a default incremented id.
Inherited from: ComponentBuilder
setCustomId(customId: string) : this
customId: string
Sets the custom id of this radio group.
setId(id: number) : this
id: number
Sets the id (not the custom id) for this component.
Inherited from: ComponentBuilder
setOptions(options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>) : this
options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>
Sets the options for this radio group.
setRequired(required: boolean) : this
required: boolean
Sets whether selecting options is required.
spliceOptions(index: numberdeleteCount: number...options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>) : this
index: number
deleteCount: number
...options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>
Removes, replaces, or inserts options for this radio group.
toJSON() : APIRadioGroupComponent
Serializes this builder to API-compatible JSON data.