Class SlashCommandBuilder
Represents a class used to build slash commands.
Assembly: Discord.Net.Core.dll​
View Source​
public class SlashCommandBuilder
Properties​
Name​
Gets or sets the name of this slash command.
View Source​
public string Name { get; set; }
Description​
Gets or sets a 1-100 length description of this slash command
View Source​
public string Description { get; set; }
Options​
Gets or sets the options for this command.
View Source​
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​
public bool IsDefaultPermission { get; set; }
Fields​
MaxNameLength​
Returns the maximum length a commands name allowed by Discord
View Source​
public const int MaxNameLength = 32
MaxDescriptionLength​
Returns the maximum length of a commands description allowed by Discord.
View Source​
public const int MaxDescriptionLength = 100
MaxOptionsCount​
Returns the maximum count of command options allowed by Discord
View Source​
public const int MaxOptionsCount = 25
Methods​
Build()​
Build the current builder into a Discord.SlashCommandProperties class.
View Source​
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​
public SlashCommandBuilder WithName(string name)
Returns​
Discord.SlashCommandBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
System.String | name | The value to set the field name to. |
WithDescription(String)​
Sets the description of the current command.
View Source​
public SlashCommandBuilder WithDescription(string description)
Returns​
Discord.SlashCommandBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
System.String | description | The description of this command. |
WithDefaultPermission(Boolean)​
Sets the default permission of the current command.
View Source​
public SlashCommandBuilder WithDefaultPermission(bool value)
Returns​
Discord.SlashCommandBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
System.Boolean | value | The 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​
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​
Type | Name | Description |
---|---|---|
System.String | name | The name of the option to add. |
Discord.ApplicationCommandOptionType | type | The type of this option. |
System.String | description | The description of this option. |
System.Nullable<System.Boolean> | isRequired | If this option is required for this command. |
System.Nullable<System.Boolean> | isDefault | If this option is the default option. |
System.Boolean | isAutocomplete | If this option is set to autocomplete. |
System.Nullable<System.Double> | minValue | The smallest number value the user can input. |
System.Nullable<System.Double> | maxValue | The largest number value the user can input. |
System.Collections.Generic.List<Discord.SlashCommandOptionBuilder> | options | The options of the option to add. |
System.Collections.Generic.List<Discord.ChannelType> | channelTypes | The allowed channel types for this option. |
Discord.ApplicationCommandOptionChoiceProperties[] | choices | The choices of this option. |
AddOption(SlashCommandOptionBuilder)​
Adds an option to this slash command.
View Source​
public SlashCommandBuilder AddOption(SlashCommandOptionBuilder option)
Returns​
Discord.SlashCommandBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
Discord.SlashCommandOptionBuilder | option | The option to add. |
AddOptions(SlashCommandOptionBuilder[])​
Adds a collection of options to the current slash command.
View Source​
public SlashCommandBuilder AddOptions(params SlashCommandOptionBuilder[] options)
Returns​
Discord.SlashCommandBuilder: The current builder.
Parameters​
Type | Name | Description |
---|---|---|
Discord.SlashCommandOptionBuilder[] | options | The collection of options to add. |