Table of Contents

Class MessageCommandBuilder

Namespace
Discord
Assembly
Discord.Net.Core.dll

A class used to build Message commands.

public class MessageCommandBuilder
Inheritance
MessageCommandBuilder
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 specified.

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 install method for this command; null if not specified.

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 Message 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 MessageCommandBuilder AddNameLocalization(string locale, string name)

Parameters

locale string

Locale of the entry.

name string

Localized string for the name field.

Returns

MessageCommandBuilder

The current builder.

Exceptions

ArgumentException

Thrown if locale is an invalid locale string.

Build()

Build the current builder into a MessageCommandProperties class.

public MessageCommandProperties Build()

Returns

MessageCommandProperties

A MessageCommandProperties that can be used to create message commands.

WithContextTypes(params InteractionContextType[])

Sets context types this command can be executed in.

public MessageCommandBuilder WithContextTypes(params InteractionContextType[] contextTypes)

Parameters

contextTypes InteractionContextType[]

Context types the command can be executed in.

Returns

MessageCommandBuilder

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 MessageCommandBuilder WithDMPermission(bool permission)

Parameters

permission bool

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

Returns

MessageCommandBuilder

The current builder.

WithDefaultMemberPermissions(GuildPermission?)

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

public MessageCommandBuilder WithDefaultMemberPermissions(GuildPermission? permissions)

Parameters

permissions GuildPermission?

The permissions required to use this command.

Returns

MessageCommandBuilder

The current builder.

WithDefaultPermission(bool)

Sets the default permission of the current command.

public MessageCommandBuilder WithDefaultPermission(bool isDefaultPermission)

Parameters

isDefaultPermission bool

The default permission value to set.

Returns

MessageCommandBuilder

The current builder.

WithIntegrationTypes(params ApplicationIntegrationType[])

Sets the install method for this command.

public MessageCommandBuilder WithIntegrationTypes(params ApplicationIntegrationType[] integrationTypes)

Parameters

integrationTypes ApplicationIntegrationType[]

Install types for this command.

Returns

MessageCommandBuilder

The builder instance.

WithName(string)

Sets the field name.

public MessageCommandBuilder WithName(string name)

Parameters

name string

The value to set the field name to.

Returns

MessageCommandBuilder

The current builder.

WithNameLocalizations(IDictionary<string, string>)

Sets the NameLocalizations collection.

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

Parameters

nameLocalizations IDictionary<string, string>

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

Returns

MessageCommandBuilder

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 MessageCommandBuilder WithNsfw(bool permission)

Parameters

permission bool

true if the command is age restricted, otherwise false.

Returns

MessageCommandBuilder

The current builder.