Table of Contents

Class UserCommandBuilder

Namespace
Discord
Assembly
Discord.Net.Core.dll

A class used to build user commands.

public class UserCommandBuilder
Inheritance
UserCommandBuilder
Inherited Members

Fields

MaxNameLength

Returns the maximum length a commands name allowed by Discord.

public const int MaxNameLength = 32

Field Value

int

Properties

ContextTypes

Gets the context types this command can be executed in. null if not set.

public HashSet<InteractionContextType> ContextTypes { get; set; }

Property Value

HashSet<InteractionContextType>

DefaultMemberPermissions

Gets or sets the default permission required to use this slash command.

public GuildPermission? DefaultMemberPermissions { get; set; }

Property Value

GuildPermission?

IntegrationTypes

Gets the installation method for this command. null if not set.

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

Property Value

HashSet<ApplicationIntegrationType>

IsDMEnabled

Gets or sets whether or not this command can be used in DMs.

[Obsolete("This property will be deprecated soon. Configure with ContextTypes instead.")]
public bool IsDMEnabled { get; set; }

Property Value

bool

IsDefaultPermission

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

public bool IsDefaultPermission { get; set; }

Property Value

bool

IsNsfw

Gets or sets whether or not this command is age restricted.

public bool IsNsfw { get; set; }

Property Value

bool

Name

Gets or sets the name of this User command.

public string Name { get; set; }

Property Value

string

NameLocalizations

Gets the localization dictionary for the name field of this command.

public IReadOnlyDictionary<string, string> NameLocalizations { get; }

Property Value

IReadOnlyDictionary<string, string>

Methods

AddNameLocalization(string, string)

Adds a new entry to the NameLocalizations collection.

public UserCommandBuilder AddNameLocalization(string locale, string name)

Parameters

locale string

Locale of the entry.

name string

Localized string for the name field.

Returns

UserCommandBuilder

The current builder.

Exceptions

ArgumentException

Thrown if locale is an invalid locale string.

Build()

Build the current builder into a UserCommandProperties class.

public UserCommandProperties Build()

Returns

UserCommandProperties

A UserCommandProperties that can be used to create user commands.

WithContextTypes(params InteractionContextType[])

Sets context types this command can be executed in.

public UserCommandBuilder WithContextTypes(params InteractionContextType[] contextTypes)

Parameters

contextTypes InteractionContextType[]

Context types the command can be executed in.

Returns

UserCommandBuilder

The builder instance.

WithDMPermission(bool)

Sets whether or not this command can be used in dms.

[Obsolete("This method will be deprecated soon. Configure with WithContextTypes instead.")]
public UserCommandBuilder WithDMPermission(bool permission)

Parameters

permission bool

true if the command is available in dms, otherwise false.

Returns

UserCommandBuilder

The current builder.

WithDefaultMemberPermissions(GuildPermission?)

Sets the default member permissions required to use this application command.

public UserCommandBuilder WithDefaultMemberPermissions(GuildPermission? permissions)

Parameters

permissions GuildPermission?

The permissions required to use this command.

Returns

UserCommandBuilder

The current builder.

WithDefaultPermission(bool)

Sets the default permission of the current command.

public UserCommandBuilder WithDefaultPermission(bool isDefaultPermission)

Parameters

isDefaultPermission bool

The default permission value to set.

Returns

UserCommandBuilder

The current builder.

WithIntegrationTypes(params ApplicationIntegrationType[])

Sets the installation method for this command.

public UserCommandBuilder WithIntegrationTypes(params ApplicationIntegrationType[] integrationTypes)

Parameters

integrationTypes ApplicationIntegrationType[]

Installation types for this command.

Returns

UserCommandBuilder

The builder instance.

WithName(string)

Sets the field name.

public UserCommandBuilder WithName(string name)

Parameters

name string

The value to set the field name to.

Returns

UserCommandBuilder

The current builder.

WithNameLocalizations(IDictionary<string, string>)

Sets the NameLocalizations collection.

public UserCommandBuilder WithNameLocalizations(IDictionary<string, string> nameLocalizations)

Parameters

nameLocalizations IDictionary<string, string>

The localization dictionary to use for the name field of this command.

Returns

UserCommandBuilder

The current builder.

Exceptions

ArgumentNullException

Thrown if nameLocalizations is null.

ArgumentException

Thrown if any dictionary key is an invalid locale string.

WithNsfw(bool)

Sets whether or not this command is age restricted.

public UserCommandBuilder WithNsfw(bool permission)

Parameters

permission bool

true if the command is age restricted, otherwise false.

Returns

UserCommandBuilder

The current builder.