Class SelectMenuBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a class used to build SelectMenuComponent's.
public class SelectMenuBuilder : IInteractableComponentBuilder, IMessageComponentBuilder
- Inheritance
-
SelectMenuBuilder
- Implements
- Inherited Members
- Extension Methods
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
selectMenuSelectMenuComponent
SelectMenuBuilder(string, List<SelectMenuOptionBuilder>, string, int, int, bool, ComponentType, List<ChannelType>, List<SelectMenuDefaultValue>, int?)
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, int? id = null)
Parameters
customIdstringThe custom id of this select menu.
optionsList<SelectMenuOptionBuilder>The options for this select menu.
placeholderstringThe placeholder of this select menu.
maxValuesintThe max values of this select menu.
minValuesintThe min values of this select menu.
isDisabledboolDisabled this select menu or not.
typeComponentTypeThe ComponentType of this select menu.
channelTypesList<ChannelType>The types of channels this menu can select (only valid on ChannelSelects)
defaultValuesList<SelectMenuDefaultValue>idint?
Fields
MaxOptionCount
The maximum number of options a SelectMenuComponent can have.
public const int MaxOptionCount = 25
Field Value
MaxPlaceholderLength
The max length of a Placeholder.
public const int MaxPlaceholderLength = 100
Field Value
MaxValuesCount
public const int MaxValuesCount = 25
Field Value
Properties
ChannelTypes
Gets or sets the menu's channel types (only valid on ChannelSelects).
public List<ChannelType> ChannelTypes { get; set; }
Property Value
CustomId
Gets or sets the custom id of the current select menu.
public string CustomId { get; set; }
Property Value
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength
- ArgumentException
CustomId length subceeds 1.
DefaultValues
public List<SelectMenuDefaultValue> DefaultValues { get; set; }
Property Value
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?
IsDisabled
Gets or sets whether the current menu is disabled.
public bool IsDisabled { get; set; }
Property Value
MaxValues
Gets or sets the maximum values of the current select menu.
public int MaxValues { get; set; }
Property Value
Exceptions
- ArgumentException
MaxValues exceeds MaxValuesCount.
MinValues
Gets or sets the minimum values of the current select menu.
public int MinValues { get; set; }
Property Value
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
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
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
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
valueSelectMenuDefaultValueThe 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
idulongThe id of an entity to add.
typeSelectDefaultValueTypeThe 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
optionSelectMenuOptionBuilderThe 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
labelstringThe label for this option.
valuestringThe value of this option.
descriptionstringThe description of this option.
emoteIEmoteThe emote of this option.
isDefaultbool?Render this option as selected by default or not.
Returns
- SelectMenuBuilder
The current builder.
Exceptions
- InvalidOperationException
Options count reached MaxOptionCount.
Build()
Builds a SelectMenuComponent
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
channelTypesChannelType[]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
channelTypesList<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
customIdstringThe 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
defaultValuesSelectMenuDefaultValue[]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
isDisabledboolWhether the current menu is disabled or not.
Returns
- SelectMenuBuilder
The current builder.
WithMaxValues(int)
Sets the field maxValues.
public SelectMenuBuilder WithMaxValues(int maxValues)
Parameters
maxValuesintThe 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
minValuesintThe 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
optionsList<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
placeholderstringThe 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
typeComponentTypeThe type of the menu.
Returns
- SelectMenuBuilder
The current builder.