Skip to main content

Class SlashCommandOptionBuilder

Represents a class used to build options for the Discord.SlashCommandBuilder.

Assembly: Discord.Net.Core.dll​
View Source​
Declaration
public class SlashCommandOptionBuilder

Properties​

Name​

Gets or sets the name of this option.

View Source​
Declaration
public string Name { get; set; }

Description​

Gets or sets the description of this option.

View Source​
Declaration
public string Description { get; set; }

Type​

Gets or sets the type of this option.

View Source​
Declaration
public ApplicationCommandOptionType Type { get; set; }

IsDefault​

Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default.

View Source​
Declaration
public bool? IsDefault { get; set; }

IsRequired​

Gets or sets if the option is required.

View Source​
Declaration
public bool? IsRequired { get; set; }

IsAutocomplete​

Gets or sets whether or not this option supports autocomplete.

View Source​
Declaration
public bool IsAutocomplete { get; set; }

MinValue​

Gets or sets the smallest number value the user can input.

View Source​
Declaration
public double? MinValue { get; set; }

MaxValue​

Gets or sets the largest number value the user can input.

View Source​
Declaration
public double? MaxValue { get; set; }

Choices​

Gets or sets the choices for string and int types for the user to pick from.

View Source​
Declaration
public List<ApplicationCommandOptionChoiceProperties> Choices { get; set; }

Options​

Gets or sets if this option is a subcommand or subcommand group type, these nested options will be the parameters.

View Source​
Declaration
public List<SlashCommandOptionBuilder> Options { get; set; }

ChannelTypes​

Gets or sets the allowed channel types for this option.

View Source​
Declaration
public List<ChannelType> ChannelTypes { get; set; }

Fields​

ChoiceNameMaxLength​

The max length of a choice's name allowed by Discord.

View Source​
Declaration
public const int ChoiceNameMaxLength = 100

MaxChoiceCount​

The maximum number of choices allowed by Discord.

View Source​
Declaration
public const int MaxChoiceCount = 25

Methods​

Build()​

Builds the current option.

View Source​
Declaration
public ApplicationCommandOptionProperties Build()
Returns​

Discord.ApplicationCommandOptionProperties: The built version of this option.### AddOption(String, ApplicationCommandOptionType, String, Nullable<Boolean>, Boolean, Boolean, Nullable<Double>, Nullable<Double>, List<SlashCommandOptionBuilder>, List<ChannelType>, ApplicationCommandOptionChoiceProperties[]) Adds an option to the current slash command.

View Source​
Declaration
public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOptionType type, string description, bool? required = null, bool isDefault = false, bool isAutocomplete = false, double? minValue = null, double? maxValue = null, List<SlashCommandOptionBuilder> options = null, List<ChannelType> channelTypes = null, params ApplicationCommandOptionChoiceProperties[] choices)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name of the option to add.
Discord.ApplicationCommandOptionTypetypeThe type of this option.
System.StringdescriptionThe description of this option.
System.Nullable<System.Boolean>required
System.BooleanisDefaultIf this option is the default option.
System.BooleanisAutocompleteIf this option supports autocomplete.
System.Nullable<System.Double>minValueThe smallest number value the user can input.
System.Nullable<System.Double>maxValueThe largest number value the user can input.
System.Collections.Generic.List<Discord.SlashCommandOptionBuilder>optionsThe options of the option to add.
System.Collections.Generic.List<Discord.ChannelType>channelTypesThe allowed channel types for this option.
Discord.ApplicationCommandOptionChoiceProperties[]choicesThe choices of this option.

AddOption(SlashCommandOptionBuilder)​

Adds a sub option to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddOption(SlashCommandOptionBuilder option)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.SlashCommandOptionBuilderoptionThe sub option to add.

AddChoice(String, Int32)​

Adds a choice to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddChoice(string name, int value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name of the choice.
System.Int32valueThe value of the choice.

AddChoice(String, String)​

Adds a choice to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddChoice(string name, string value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name of the choice.
System.StringvalueThe value of the choice.

AddChoice(String, Double)​

Adds a choice to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddChoice(string name, double value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name of the choice.
System.DoublevalueThe value of the choice.

AddChoice(String, Single)​

Adds a choice to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddChoice(string name, float value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name of the choice.
System.SinglevalueThe value of the choice.

AddChoice(String, Int64)​

Adds a choice to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddChoice(string name, long value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name of the choice.
System.Int64valueThe value of the choice.

AddChannelType(ChannelType)​

Adds a channel type to the current option.

View Source​
Declaration
public SlashCommandOptionBuilder AddChannelType(ChannelType channelType)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.ChannelTypechannelTypeThe Discord.ChannelType to add.

WithName(String)​

Sets the current builders name.

View Source​
Declaration
public SlashCommandOptionBuilder WithName(string name)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe name to set the current option builder.

WithDescription(String)​

Sets the current builders description.

View Source​
Declaration
public SlashCommandOptionBuilder WithDescription(string description)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringdescriptionThe description to set.

WithRequired(Boolean)​

Sets the current builders required field.

View Source​
Declaration
public SlashCommandOptionBuilder WithRequired(bool value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.BooleanvalueThe value to set.

WithDefault(Boolean)​

Sets the current builders default field.

View Source​
Declaration
public SlashCommandOptionBuilder WithDefault(bool value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.BooleanvalueThe value to set.

WithAutocomplete(Boolean)​

Sets the current builders autocomplete field.

View Source​
Declaration
public SlashCommandOptionBuilder WithAutocomplete(bool value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.BooleanvalueThe value to set.

WithMinValue(Double)​

Sets the current builders min value field.

View Source​
Declaration
public SlashCommandOptionBuilder WithMinValue(double value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.DoublevalueThe value to set.

WithMaxValue(Double)​

Sets the current builders max value field.

View Source​
Declaration
public SlashCommandOptionBuilder WithMaxValue(double value)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
System.DoublevalueThe value to set.

WithType(ApplicationCommandOptionType)​

Sets the current type of this builder.

View Source​
Declaration
public SlashCommandOptionBuilder WithType(ApplicationCommandOptionType type)
Returns​

Discord.SlashCommandOptionBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.ApplicationCommandOptionTypetypeThe type to set.