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
stringThe custom id of this select menu.
options
List<SelectMenuOptionBuilder>The options for this select menu.
placeholder
stringThe placeholder of this select menu.
maxValues
intThe max values of this select menu.
minValues
intThe min values of this select menu.
isDisabled
boolDisabled this select menu or not.
type
ComponentTypeThe 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
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
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
value
SelectMenuDefaultValueThe 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
ulongThe id of an entity to add.
type
SelectDefaultValueTypeThe 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
SelectMenuOptionBuilderThe 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
stringThe label for this option.
value
stringThe value of this option.
description
stringThe description of this option.
emote
IEmoteThe 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()
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
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
stringThe 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
boolWhether 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
intThe 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
intThe 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
stringThe 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
ComponentTypeThe type of the menu.
Returns
- SelectMenuBuilder
The current builder.