Class SlashCommandOptionBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a class used to build options for the SlashCommandBuilder.
public class SlashCommandOptionBuilder
- Inheritance
-
SlashCommandOptionBuilder
- Inherited Members
Fields
ChoiceNameMaxLength
The max length of a choice's name allowed by Discord.
public const int ChoiceNameMaxLength = 100
Field Value
MaxChoiceCount
The maximum number of choices allowed by Discord.
public const int MaxChoiceCount = 25
Field Value
Properties
ChannelTypes
Gets or sets the allowed channel types for this option.
public List<ChannelType> ChannelTypes { get; set; }
Property Value
Choices
Gets or sets the choices for string and int types for the user to pick from.
public List<ApplicationCommandOptionChoiceProperties> Choices { get; set; }
Property Value
Description
Gets or sets the description of this option.
public string Description { get; set; }
Property Value
DescriptionLocalizations
Gets the localization dictionary for the description field of this command.
public IReadOnlyDictionary<string, string> DescriptionLocalizations { get; }
Property Value
IsAutocomplete
Gets or sets whether or not this option supports autocomplete.
public bool IsAutocomplete { get; set; }
Property Value
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.
public bool? IsDefault { get; set; }
Property Value
- bool?
IsRequired
Gets or sets if the option is required.
public bool? IsRequired { get; set; }
Property Value
- bool?
MaxLength
Gets or sets the maximum allowed length for a string input.
public int? MaxLength { get; set; }
Property Value
- int?
MaxValue
Gets or sets the largest number value the user can input.
public double? MaxValue { get; set; }
Property Value
MinLength
Gets or sets the minimum allowed length for a string input.
public int? MinLength { get; set; }
Property Value
- int?
MinValue
Gets or sets the smallest number value the user can input.
public double? MinValue { get; set; }
Property Value
Name
Gets or sets the name of this option.
public string Name { get; set; }
Property Value
NameLocalizations
Gets the localization dictionary for the name field of this command.
public IReadOnlyDictionary<string, string> NameLocalizations { get; }
Property Value
Options
Gets or sets if this option is a subcommand or subcommand group type, these nested options will be the parameters.
public List<SlashCommandOptionBuilder> Options { get; set; }
Property Value
Type
Gets or sets the type of this option.
public ApplicationCommandOptionType Type { get; set; }
Property Value
Methods
AddChannelType(ChannelType)
Adds a channel type to the current option.
public SlashCommandOptionBuilder AddChannelType(ChannelType channelType)
Parameters
channelTypeChannelTypeThe ChannelType to add.
Returns
- SlashCommandOptionBuilder
The current builder.
AddChoice(string, double, IDictionary<string, string>)
Adds a choice to the current option.
public SlashCommandOptionBuilder AddChoice(string name, double value, IDictionary<string, string> nameLocalizations = null)
Parameters
namestringThe name of the choice.
valuedoubleThe value of the choice.
nameLocalizationsIDictionary<string, string>Localization dictionary for the description field of this command.
Returns
- SlashCommandOptionBuilder
The current builder.
AddChoice(string, int, IDictionary<string, string>)
Adds a choice to the current option.
public SlashCommandOptionBuilder AddChoice(string name, int value, IDictionary<string, string> nameLocalizations = null)
Parameters
namestringThe name of the choice.
valueintThe value of the choice.
nameLocalizationsIDictionary<string, string>The localization dictionary for to use the name field of this command option choice.
Returns
- SlashCommandOptionBuilder
The current builder.
AddChoice(string, long, IDictionary<string, string>)
Adds a choice to the current option.
public SlashCommandOptionBuilder AddChoice(string name, long value, IDictionary<string, string> nameLocalizations = null)
Parameters
namestringThe name of the choice.
valuelongThe value of the choice.
nameLocalizationsIDictionary<string, string>The localization dictionary to use for the name field of this command option choice.
Returns
- SlashCommandOptionBuilder
The current builder.
AddChoice(string, float, IDictionary<string, string>)
Adds a choice to the current option.
public SlashCommandOptionBuilder AddChoice(string name, float value, IDictionary<string, string> nameLocalizations = null)
Parameters
namestringThe name of the choice.
valuefloatThe value of the choice.
nameLocalizationsIDictionary<string, string>The localization dictionary to use for the name field of this command option choice.
Returns
- SlashCommandOptionBuilder
The current builder.
AddChoice(string, string, IDictionary<string, string>)
Adds a choice to the current option.
public SlashCommandOptionBuilder AddChoice(string name, string value, IDictionary<string, string> nameLocalizations = null)
Parameters
namestringThe name of the choice.
valuestringThe value of the choice.
nameLocalizationsIDictionary<string, string>The localization dictionary for to use the name field of this command option choice.
Returns
- SlashCommandOptionBuilder
The current builder.
AddDescriptionLocalization(string, string)
Adds a new entry to the DescriptionLocalizations collection.
public SlashCommandOptionBuilder AddDescriptionLocalization(string locale, string description)
Parameters
Returns
- SlashCommandOptionBuilder
The current builder.
Exceptions
- ArgumentException
Thrown if
localeis an invalid locale string.
AddNameLocalization(string, string)
Adds a new entry to the NameLocalizations collection.
public SlashCommandOptionBuilder AddNameLocalization(string locale, string name)
Parameters
Returns
- SlashCommandOptionBuilder
The current builder.
Exceptions
- ArgumentException
Thrown if
localeis an invalid locale string.
AddOption(SlashCommandOptionBuilder)
Adds a sub option to the current option.
public SlashCommandOptionBuilder AddOption(SlashCommandOptionBuilder option)
Parameters
optionSlashCommandOptionBuilderThe sub option to add.
Returns
- SlashCommandOptionBuilder
The current builder.
AddOption(string, ApplicationCommandOptionType, string, bool?, bool, bool, double?, double?, List<SlashCommandOptionBuilder>, List<ChannelType>, IDictionary<string, string>, IDictionary<string, string>, int?, int?, params ApplicationCommandOptionChoiceProperties[])
Adds an option to the current slash command.
public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOptionType type, string description, bool? isRequired = null, bool isDefault = false, bool isAutocomplete = false, double? minValue = null, double? maxValue = null, List<SlashCommandOptionBuilder> options = null, List<ChannelType> channelTypes = null, IDictionary<string, string> nameLocalizations = null, IDictionary<string, string> descriptionLocalizations = null, int? minLength = null, int? maxLength = null, params ApplicationCommandOptionChoiceProperties[] choices)
Parameters
namestringThe name of the option to add.
typeApplicationCommandOptionTypeThe type of this option.
descriptionstringThe description of this option.
isRequiredbool?If this option is required for this command.
isDefaultboolIf this option is the default option.
isAutocompleteboolIf this option supports autocomplete.
minValuedouble?The smallest number value the user can input.
maxValuedouble?The largest number value the user can input.
optionsList<SlashCommandOptionBuilder>The options of the option to add.
channelTypesList<ChannelType>The allowed channel types for this option.
nameLocalizationsIDictionary<string, string>Localization dictionary for the description field of this command.
descriptionLocalizationsIDictionary<string, string>Localization dictionary for the description field of this command.
minLengthint?maxLengthint?choicesApplicationCommandOptionChoiceProperties[]The choices of this option.
Returns
- SlashCommandOptionBuilder
The current builder.
AddOptions(params SlashCommandOptionBuilder[])
Adds a collection of options to the current option.
public SlashCommandOptionBuilder AddOptions(params SlashCommandOptionBuilder[] options)
Parameters
optionsSlashCommandOptionBuilder[]The collection of options to add.
Returns
- SlashCommandOptionBuilder
The current builder.
Build()
Builds the current option.
public ApplicationCommandOptionProperties Build()
Returns
- ApplicationCommandOptionProperties
The built version of this option.
WithAutocomplete(bool)
Sets the current builders autocomplete field.
public SlashCommandOptionBuilder WithAutocomplete(bool value)
Parameters
valueboolThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithDefault(bool)
Sets the current builders default field.
public SlashCommandOptionBuilder WithDefault(bool value)
Parameters
valueboolThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithDescription(string)
Sets the current builders description.
public SlashCommandOptionBuilder WithDescription(string description)
Parameters
descriptionstringThe description to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithDescriptionLocalizations(IDictionary<string, string>)
Sets the DescriptionLocalizations collection.
public SlashCommandOptionBuilder WithDescriptionLocalizations(IDictionary<string, string> descriptionLocalizations)
Parameters
descriptionLocalizationsIDictionary<string, string>The localization dictionary to use for the description field of this command option.
Returns
- SlashCommandOptionBuilder
The current builder.
Exceptions
- ArgumentNullException
Thrown if
descriptionLocalizationsis null.- ArgumentException
Thrown if any dictionary key is an invalid locale string.
WithMaxLength(int)
Sets the current builders max length field.
public SlashCommandOptionBuilder WithMaxLength(int length)
Parameters
lengthintThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithMaxValue(double)
Sets the current builders max value field.
public SlashCommandOptionBuilder WithMaxValue(double value)
Parameters
valuedoubleThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithMinLength(int)
Sets the current builders min length field.
public SlashCommandOptionBuilder WithMinLength(int length)
Parameters
lengthintThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithMinValue(double)
Sets the current builders min value field.
public SlashCommandOptionBuilder WithMinValue(double value)
Parameters
valuedoubleThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithName(string)
Sets the current builders name.
public SlashCommandOptionBuilder WithName(string name)
Parameters
namestringThe name to set the current option builder.
Returns
- SlashCommandOptionBuilder
The current builder.
WithNameLocalizations(IDictionary<string, string>)
Sets the NameLocalizations collection.
public SlashCommandOptionBuilder WithNameLocalizations(IDictionary<string, string> nameLocalizations)
Parameters
nameLocalizationsIDictionary<string, string>The localization dictionary to use for the name field of this command option.
Returns
- SlashCommandOptionBuilder
The current builder.
Exceptions
- ArgumentNullException
Thrown if
nameLocalizationsis null.- ArgumentException
Thrown if any dictionary key is an invalid locale string.
WithRequired(bool)
Sets the current builders required field.
public SlashCommandOptionBuilder WithRequired(bool value)
Parameters
valueboolThe value to set.
Returns
- SlashCommandOptionBuilder
The current builder.
WithType(ApplicationCommandOptionType)
Sets the current type of this builder.
public SlashCommandOptionBuilder WithType(ApplicationCommandOptionType type)
Parameters
typeApplicationCommandOptionTypeThe type to set.
Returns
- SlashCommandOptionBuilder
The current builder.