Class SlashCommandBuilder
- Namespace
- Discord.Interactions.Builders
- Assembly
- Discord.Net.Interactions.dll
Represents a builder for creating SlashCommandInfo.
public sealed class SlashCommandBuilder : CommandBuilder<SlashCommandInfo, SlashCommandBuilder, SlashCommandParameterBuilder>, ICommandBuilder
- Inheritance
-
SlashCommandBuilder
- Implements
- Inherited Members
-
CommandBuilder<SlashCommandInfo, SlashCommandBuilder, SlashCommandParameterBuilder>.IgnoreGroupNamesCommandBuilder<SlashCommandInfo, SlashCommandBuilder, SlashCommandParameterBuilder>.TreatNameAsRegex
Constructors
SlashCommandBuilder(ModuleBuilder, string, ExecuteCallback)
Initializes a new SlashCommandBuilder.
public SlashCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback)
Parameters
moduleModuleBuilderParent module of this command.
namestringName of this command.
callbackExecuteCallbackExecution callback of this command.
Properties
ContextTypes
Gets or sets the context types this command can be executed in.
public HashSet<InteractionContextType> ContextTypes { get; set; }
Property Value
DefaultMemberPermissions
Gets the default permissions needed for executing this command.
public GuildPermission? DefaultMemberPermissions { get; set; }
Property Value
DefaultPermission
Gets and sets the default permission of this command.
[Obsolete("To be deprecated soon, use IsEnabledInDm and DefaultMemberPermissions instead.")]
public bool DefaultPermission { get; set; }
Property Value
Description
Gets and sets the description of this command.
public string Description { get; set; }
Property Value
Instance
protected override SlashCommandBuilder Instance { get; }
Property Value
IntegrationTypes
Gets or sets the install method for this command.
public HashSet<ApplicationIntegrationType> IntegrationTypes { get; set; }
Property Value
IsEnabledInDm
Gets whether this command can be used in DMs.
public bool IsEnabledInDm { get; set; }
Property Value
IsNsfw
Gets whether this command is age restricted.
public bool IsNsfw { get; set; }
Property Value
Methods
AddParameter(Action<SlashCommandParameterBuilder>)
Adds a command parameter to the parameters collection.
public override SlashCommandBuilder AddParameter(Action<SlashCommandParameterBuilder> configure)
Parameters
configureAction<SlashCommandParameterBuilder>SlashCommandParameterBuilder factory.
Returns
- SlashCommandBuilder
The builder instance.
SetEnabledInDm(bool)
Sets IsEnabledInDm.
public SlashCommandBuilder SetEnabledInDm(bool isEnabled)
Parameters
isEnabledboolNew value of the IsEnabledInDm.
Returns
- SlashCommandBuilder
The builder instance.
SetNsfw(bool)
Sets IsNsfw.
public SlashCommandBuilder SetNsfw(bool isNsfw)
Parameters
Returns
- SlashCommandBuilder
The builder instance.
WithContextTypes(params InteractionContextType[])
Sets the ContextTypes on this SlashCommandBuilder.
public SlashCommandBuilder WithContextTypes(params InteractionContextType[] contextTypes)
Parameters
contextTypesInteractionContextType[]Context types the command can be executed in.
Returns
- SlashCommandBuilder
The builder instance.
WithDefaultMemberPermissions(GuildPermission)
Sets DefaultMemberPermissions.
public SlashCommandBuilder WithDefaultMemberPermissions(GuildPermission permissions)
Parameters
permissionsGuildPermissionNew value of the DefaultMemberPermissions.
Returns
- SlashCommandBuilder
The builder instance.
WithDefaultPermission(bool)
Sets DefaultPermission.
[Obsolete("To be deprecated soon, use SetEnabledInDm and WithDefaultMemberPermissions instead.")]
public SlashCommandBuilder WithDefaultPermission(bool permission)
Parameters
permissionboolNew value of the DefaultPermission.
Returns
- SlashCommandBuilder
The builder instance.
WithDescription(string)
Sets Description.
public SlashCommandBuilder WithDescription(string description)
Parameters
descriptionstringNew value of the Description.
Returns
- SlashCommandBuilder
The builder instance.
WithIntegrationTypes(params ApplicationIntegrationType[])
Sets the IntegrationTypes on this SlashCommandBuilder.
public SlashCommandBuilder WithIntegrationTypes(params ApplicationIntegrationType[] integrationTypes)
Parameters
integrationTypesApplicationIntegrationType[]Install types for this command.
Returns
- SlashCommandBuilder
The builder instance.