Table of Contents

Class SelectMenuBuilder

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents a class used to build SelectMenuComponent's.

public class SelectMenuBuilder
Inheritance
SelectMenuBuilder
Inherited Members

Constructors

SelectMenuBuilder()

Creates a new instance of a SelectMenuBuilder.

public SelectMenuBuilder()

SelectMenuBuilder(SelectMenuComponent)

Creates a new instance of a SelectMenuBuilder from instance of SelectMenuComponent.

public SelectMenuBuilder(SelectMenuComponent selectMenu)

Parameters

selectMenu SelectMenuComponent

SelectMenuBuilder(string, List<SelectMenuOptionBuilder>, string, int, int, bool, ComponentType, List<ChannelType>, List<SelectMenuDefaultValue>)

Creates a new instance of a SelectMenuBuilder.

public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options = null, string placeholder = null, int maxValues = 1, int minValues = 1, bool isDisabled = false, ComponentType type = ComponentType.SelectMenu, List<ChannelType> channelTypes = null, List<SelectMenuDefaultValue> defaultValues = null)

Parameters

customId string

The custom id of this select menu.

options List<SelectMenuOptionBuilder>

The options for this select menu.

placeholder string

The placeholder of this select menu.

maxValues int

The max values of this select menu.

minValues int

The min values of this select menu.

isDisabled bool

Disabled this select menu or not.

type ComponentType

The ComponentType of this select menu.

channelTypes List<ChannelType>

The types of channels this menu can select (only valid on ChannelSelects)

defaultValues List<SelectMenuDefaultValue>

Fields

MaxOptionCount

The maximum number of options a SelectMenuComponent can have.

public const int MaxOptionCount = 25

Field Value

int

MaxPlaceholderLength

The max length of a Placeholder.

public const int MaxPlaceholderLength = 100

Field Value

int

MaxValuesCount

The maximum number of values for the MinValues and MaxValues properties.

public const int MaxValuesCount = 25

Field Value

int

Properties

ChannelTypes

Gets or sets the menu's channel types (only valid on ChannelSelects).

public List<ChannelType> ChannelTypes { get; set; }

Property Value

List<ChannelType>

CustomId

Gets or sets the custom id of the current select menu.

public string CustomId { get; set; }

Property Value

string

Exceptions

ArgumentException

CustomId length exceeds MaxCustomIdLength

ArgumentException

CustomId length subceeds 1.

DefaultValues

public List<SelectMenuDefaultValue> DefaultValues { get; set; }

Property Value

List<SelectMenuDefaultValue>

IsDisabled

Gets or sets whether the current menu is disabled.

public bool IsDisabled { get; set; }

Property Value

bool

MaxValues

Gets or sets the maximum values of the current select menu.

public int MaxValues { get; set; }

Property Value

int

Exceptions

ArgumentException

MaxValues exceeds MaxValuesCount.

MinValues

Gets or sets the minimum values of the current select menu.

public int MinValues { get; set; }

Property Value

int

Exceptions

ArgumentException

MinValues exceeds MaxValuesCount.

Options

Gets or sets a collection of SelectMenuOptionBuilder for this current select menu.

public List<SelectMenuOptionBuilder> Options { get; set; }

Property Value

List<SelectMenuOptionBuilder>

Exceptions

ArgumentException

Options count exceeds MaxOptionCount.

ArgumentNullException

Options is null.

Placeholder

Gets or sets the placeholder text of the current select menu.

public string Placeholder { get; set; }

Property Value

string

Exceptions

ArgumentException

Placeholder length exceeds MaxPlaceholderLength.

ArgumentException

Placeholder length subceeds 1.

Type

Gets or sets the type of the current select menu.

public ComponentType Type { get; set; }

Property Value

ComponentType

Exceptions

ArgumentException

Type must be a select menu type.

Methods

AddDefaultValue(SelectMenuDefaultValue)

Add one default value to menu options.

public SelectMenuBuilder AddDefaultValue(SelectMenuDefaultValue value)

Parameters

value SelectMenuDefaultValue

The default value to add.

Returns

SelectMenuBuilder

The current builder.

Exceptions

InvalidOperationException

Default values count reached MaxOptionCount.

AddDefaultValue(ulong, SelectDefaultValueType)

Add one default value to menu options.

public SelectMenuBuilder AddDefaultValue(ulong id, SelectDefaultValueType type)

Parameters

id ulong

The id of an entity to add.

type SelectDefaultValueType

The type of an entity to add.

Returns

SelectMenuBuilder

The current builder.

Exceptions

InvalidOperationException

Default values count reached MaxOptionCount.

AddOption(SelectMenuOptionBuilder)

Add one option to menu options.

public SelectMenuBuilder AddOption(SelectMenuOptionBuilder option)

Parameters

option SelectMenuOptionBuilder

The option builder class containing the option properties.

Returns

SelectMenuBuilder

The current builder.

Exceptions

InvalidOperationException

Options count reached MaxOptionCount.

AddOption(string, string, string, IEmote, bool?)

Add one option to menu options.

public SelectMenuBuilder AddOption(string label, string value, string description = null, IEmote emote = 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.

emote IEmote

The emote of this option.

isDefault bool?

Render this option as selected by default or not.

Returns

SelectMenuBuilder

The current builder.

Exceptions

InvalidOperationException

Options count reached MaxOptionCount.

Build()

public SelectMenuComponent Build()

Returns

SelectMenuComponent

The newly built SelectMenuComponent

WithChannelTypes(params ChannelType[])

Sets the menus valid channel types (only for ChannelSelects).

public SelectMenuBuilder WithChannelTypes(params ChannelType[] channelTypes)

Parameters

channelTypes ChannelType[]

The valid channel types of the menu.

Returns

SelectMenuBuilder

The current builder.

WithChannelTypes(List<ChannelType>)

Sets the menus valid channel types (only for ChannelSelects).

public SelectMenuBuilder WithChannelTypes(List<ChannelType> channelTypes)

Parameters

channelTypes List<ChannelType>

The valid channel types of the menu.

Returns

SelectMenuBuilder

The current builder.

WithCustomId(string)

Sets the field CustomId.

public SelectMenuBuilder WithCustomId(string customId)

Parameters

customId string

The value to set the field CustomId to.

Returns

SelectMenuBuilder

The current builder.

Exceptions

ArgumentException

CustomId length exceeds MaxCustomIdLength

ArgumentException

CustomId length subceeds 1.

WithDefaultValues(params SelectMenuDefaultValue[])

Sets the field default values.

public SelectMenuBuilder WithDefaultValues(params SelectMenuDefaultValue[] defaultValues)

Parameters

defaultValues SelectMenuDefaultValue[]

The value to set the field default values to.

Returns

SelectMenuBuilder

The current builder.

WithDisabled(bool)

Sets whether the current menu is disabled.

public SelectMenuBuilder WithDisabled(bool isDisabled)

Parameters

isDisabled bool

Whether the current menu is disabled or not.

Returns

SelectMenuBuilder

The current builder.

WithMaxValues(int)

Sets the field maxValues.

public SelectMenuBuilder WithMaxValues(int maxValues)

Parameters

maxValues int

The value to set the field maxValues to.

Returns

SelectMenuBuilder

The current builder.

Exceptions

ArgumentException

MaxValues exceeds MaxValuesCount.

WithMinValues(int)

Sets the field minValues.

public SelectMenuBuilder WithMinValues(int minValues)

Parameters

minValues int

The value to set the field minValues to.

Returns

SelectMenuBuilder

The current builder.

Exceptions

ArgumentException

MinValues exceeds MaxValuesCount.

WithOptions(List<SelectMenuOptionBuilder>)

Sets the field options.

public SelectMenuBuilder WithOptions(List<SelectMenuOptionBuilder> options)

Parameters

options List<SelectMenuOptionBuilder>

The value to set the field options to.

Returns

SelectMenuBuilder

The current builder.

Exceptions

ArgumentException

Options count exceeds MaxOptionCount.

ArgumentNullException

Options is null.

WithPlaceholder(string)

Sets the field placeholder.

public SelectMenuBuilder WithPlaceholder(string placeholder)

Parameters

placeholder string

The value to set the field placeholder to.

Returns

SelectMenuBuilder

The current builder.

Exceptions

ArgumentException

Placeholder length exceeds MaxPlaceholderLength.

ArgumentException

Placeholder length subceeds 1.

WithType(ComponentType)

Sets the menu's current type.

public SelectMenuBuilder WithType(ComponentType type)

Parameters

type ComponentType

The type of the menu.

Returns

SelectMenuBuilder

The current builder.