Skip to main content

Class SlashCommandBuilder

Represents a class used to build slash commands.

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

Properties​

Name​

Gets or sets the name of this slash command.

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

Description​

Gets or sets a 1-100 length description of this slash command

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

Options​

Gets or sets the options for this command.

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

IsDefaultPermission​

Gets or sets whether the command is enabled by default when the app is added to a guild

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

Fields​

MaxNameLength​

Returns the maximum length a commands name allowed by Discord

View Source​
Declaration
public const int MaxNameLength = 32

MaxDescriptionLength​

Returns the maximum length of a commands description allowed by Discord.

View Source​
Declaration
public const int MaxDescriptionLength = 100

MaxOptionsCount​

Returns the maximum count of command options allowed by Discord

View Source​
Declaration
public const int MaxOptionsCount = 25

Methods​

Build()​

Build the current builder into a Discord.SlashCommandProperties class.

View Source​
Declaration
public SlashCommandProperties Build()
Returns​

Discord.SlashCommandProperties: A Discord.SlashCommandProperties that can be used to create slash commands.### WithName(String) Sets the field name.

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

Discord.SlashCommandBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringnameThe value to set the field name to.

WithDescription(String)​

Sets the description of the current command.

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

Discord.SlashCommandBuilder: The current builder.

Parameters​
TypeNameDescription
System.StringdescriptionThe description of this command.

WithDefaultPermission(Boolean)​

Sets the default permission of the current command.

View Source​
Declaration
public SlashCommandBuilder WithDefaultPermission(bool value)
Returns​

Discord.SlashCommandBuilder: The current builder.

Parameters​
TypeNameDescription
System.BooleanvalueThe default permission value to set.

AddOption(String, ApplicationCommandOptionType, String, Nullable<Boolean>, Nullable<Boolean>, Boolean, Nullable<Double>, Nullable<Double>, List<SlashCommandOptionBuilder>, List<ChannelType>, ApplicationCommandOptionChoiceProperties[])​

Adds an option to the current slash command.

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

Discord.SlashCommandBuilder: 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>isRequiredIf this option is required for this command.
System.Nullable<System.Boolean>isDefaultIf this option is the default option.
System.BooleanisAutocompleteIf this option is set to 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 an option to this slash command.

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

Discord.SlashCommandBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.SlashCommandOptionBuilderoptionThe option to add.

AddOptions(SlashCommandOptionBuilder[])​

Adds a collection of options to the current slash command.

View Source​
Declaration
public SlashCommandBuilder AddOptions(params SlashCommandOptionBuilder[] options)
Returns​

Discord.SlashCommandBuilder: The current builder.

Parameters​
TypeNameDescription
Discord.SlashCommandOptionBuilder[]optionsThe collection of options to add.