Table of Contents

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

Constructors

SlashCommandBuilder(ModuleBuilder, string, ExecuteCallback)

Initializes a new SlashCommandBuilder.

public SlashCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback)

Parameters

module ModuleBuilder

Parent module of this command.

name string

Name of this command.

callback ExecuteCallback

Execution 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

HashSet<InteractionContextType>

DefaultMemberPermissions

Gets the default permissions needed for executing this command.

public GuildPermission? DefaultMemberPermissions { get; set; }

Property Value

GuildPermission?

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

bool

Description

Gets and sets the description of this command.

public string Description { get; set; }

Property Value

string

Instance

protected override SlashCommandBuilder Instance { get; }

Property Value

SlashCommandBuilder

IntegrationTypes

Gets or sets the install method for this command.

public HashSet<ApplicationIntegrationType> IntegrationTypes { get; set; }

Property Value

HashSet<ApplicationIntegrationType>

IsEnabledInDm

Gets whether this command can be used in DMs.

public bool IsEnabledInDm { get; set; }

Property Value

bool

IsNsfw

Gets whether this command is age restricted.

public bool IsNsfw { get; set; }

Property Value

bool

Methods

AddParameter(Action<SlashCommandParameterBuilder>)

Adds a command parameter to the parameters collection.

public override SlashCommandBuilder AddParameter(Action<SlashCommandParameterBuilder> configure)

Parameters

configure Action<SlashCommandParameterBuilder>

SlashCommandParameterBuilder factory.

Returns

SlashCommandBuilder

The builder instance.

SetEnabledInDm(bool)

public SlashCommandBuilder SetEnabledInDm(bool isEnabled)

Parameters

isEnabled bool

New value of the IsEnabledInDm.

Returns

SlashCommandBuilder

The builder instance.

SetNsfw(bool)

Sets IsNsfw.

public SlashCommandBuilder SetNsfw(bool isNsfw)

Parameters

isNsfw bool

New value of the IsNsfw.

Returns

SlashCommandBuilder

The builder instance.

WithContextTypes(params InteractionContextType[])

public SlashCommandBuilder WithContextTypes(params InteractionContextType[] contextTypes)

Parameters

contextTypes InteractionContextType[]

Context types the command can be executed in.

Returns

SlashCommandBuilder

The builder instance.

WithDefaultMemberPermissions(GuildPermission)

public SlashCommandBuilder WithDefaultMemberPermissions(GuildPermission permissions)

Parameters

permissions GuildPermission

New value of the DefaultMemberPermissions.

Returns

SlashCommandBuilder

The builder instance.

WithDefaultPermission(bool)

[Obsolete("To be deprecated soon, use SetEnabledInDm and WithDefaultMemberPermissions instead.")]
public SlashCommandBuilder WithDefaultPermission(bool permission)

Parameters

permission bool

New value of the DefaultPermission.

Returns

SlashCommandBuilder

The builder instance.

WithDescription(string)

public SlashCommandBuilder WithDescription(string description)

Parameters

description string

New value of the Description.

Returns

SlashCommandBuilder

The builder instance.

WithIntegrationTypes(params ApplicationIntegrationType[])

public SlashCommandBuilder WithIntegrationTypes(params ApplicationIntegrationType[] integrationTypes)

Parameters

integrationTypes ApplicationIntegrationType[]

Install types for this command.

Returns

SlashCommandBuilder

The builder instance.