SlashCommandBuilder
export declare class SlashCommandBuilder
export declare class SlashCommandBuilder
A builder that creates API-compatible JSON data for slash commands.
Readonly
default_member_permissions
:
Permissions_2 | null | undefined
The set of permissions represented as a bit set for the command.
Deprecated
Readonly
default_permission
:
boolean | undefined
Use setDefaultMemberPermissions or setDMPermission instead.
Deprecated
Readonly
Optional
description_localizations?
:
LocalizationMap
The description localizations of this command.
Readonly
description
:
string
The description of this command.
Readonly
dm_permission
:
boolean | undefined
Indicates whether the command is available in direct messages with the application.
Remarks
By default, commands are visible. This property is only for global commands.Readonly
Optional
name_localizations?
:
LocalizationMap
The name localizations of this command.
Readonly
name
:
string
The name of this command.
Readonly
nsfw
:
boolean | undefined
Whether this command is NSFW.
Readonly
The options of this command.
Adds a new subcommand to this command.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder) | No | A function that returns a subcommand builder or an already built builder |
Adds a new subcommand group to this command.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder) | No | A function that returns a subcommand group builder or an already built builder |
setDefaultMemberPermissions(permissions)
:
this
Sets the default permissions a member should have in order to run the command.
Remarks
You can set this to'0'
to disable the command by default.Name | Type | Optional | Description |
---|---|---|---|
permissions | Permissions_2 | bigint | number | null | undefined | No | The permissions bit field to set |
Deprecated
setDefaultPermission(value)
:
this
Use or instead.
Deprecated
Remarks
If set tofalse
, you will have to later PUT
the permissions for this command.Name | Type | Optional | Description |
---|---|---|---|
value | boolean | No | Whether or not to enable this command by default |
setDMPermission(enabled)
:
this
Sets if the command is available in direct messages with the application.
Remarks
By default, commands are visible. This method is only for global commands.Name | Type | Optional | Description |
---|---|---|---|
enabled | boolean | null | undefined | No | Whether the command should be enabled in direct messages |
setNSFW(nsfw?)
:
this
Sets whether this command is NSFW.
Name | Type | Optional | Description |
---|---|---|---|
nsfw | boolean | Yes | Whether this command is NSFW |
toJSON()
:
RESTPostAPIChatInputApplicationCommandsJSONBody
Serializes this builder to API-compatible JSON data.
Remarks
This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.addAttachmentOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds an attachment option.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption) | No | A function that returns an option builder or an already built builder |
addBooleanOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a boolean option.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption) | No | A function that returns an option builder or an already built builder |
addChannelOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a channel option.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption) | No | A function that returns an option builder or an already built builder |
addIntegerOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds an integer option.
Name | Type | Optional | Description |
---|---|---|---|
input | Pick<SlashCommandIntegerOption, Exclude<keyof SlashCommandIntegerOption, 'addChoices'>> | Pick<SlashCommandIntegerOption, Exclude<keyof SlashCommandIntegerOption, 'setAutocomplete'>> | SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => Pick<SlashCommandIntegerOption, Exclude<keyof SlashCommandIntegerOption, 'addChoices'>> | Pick<SlashCommandIntegerOption, Exclude<keyof SlashCommandIntegerOption, 'setAutocomplete'>> | SlashCommandIntegerOption) | No | A function that returns an option builder or an already built builder |
addMentionableOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a mentionable option.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption) | No | A function that returns an option builder or an already built builder |
addNumberOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a number option.
Name | Type | Optional | Description |
---|---|---|---|
input | Pick<SlashCommandNumberOption, Exclude<keyof SlashCommandNumberOption, 'addChoices'>> | Pick<SlashCommandNumberOption, Exclude<keyof SlashCommandNumberOption, 'setAutocomplete'>> | SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => Pick<SlashCommandNumberOption, Exclude<keyof SlashCommandNumberOption, 'addChoices'>> | Pick<SlashCommandNumberOption, Exclude<keyof SlashCommandNumberOption, 'setAutocomplete'>> | SlashCommandNumberOption) | No | A function that returns an option builder or an already built builder |
addRoleOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a role option.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption) | No | A function that returns an option builder or an already built builder |
addStringOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a string option.
Name | Type | Optional | Description |
---|---|---|---|
input | Pick<SlashCommandStringOption, Exclude<keyof SlashCommandStringOption, 'addChoices'>> | Pick<SlashCommandStringOption, Exclude<keyof SlashCommandStringOption, 'setAutocomplete'>> | SlashCommandStringOption | ((builder: SlashCommandStringOption) => Pick<SlashCommandStringOption, Exclude<keyof SlashCommandStringOption, 'addChoices'>> | Pick<SlashCommandStringOption, Exclude<keyof SlashCommandStringOption, 'setAutocomplete'>> | SlashCommandStringOption) | No | A function that returns an option builder or an already built builder |
addUserOption(input)
:
ShouldOmitSubcommandFunctions extends true ? Pick<this, Exclude<keyof this, "addSubcommand" | "addSubcommandGroup">> : this
Adds a user option.
Name | Type | Optional | Description |
---|---|---|---|
input | SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption) | No | A function that returns an option builder or an already built builder |
setDescription(description)
:
this
Sets the description of this command.
Name | Type | Optional | Description |
---|---|---|---|
description | string | No | The description to use |
setDescriptionLocalization(locale, localizedDescription)
:
this
Sets a description localization for this command.
Name | Type | Optional | Description |
---|---|---|---|
locale | LocaleString | No | The locale to set |
localizedDescription | string | null | No | The localized description for the given locale |
setDescriptionLocalizations(localizedDescriptions)
:
this
Sets the description localizations for this command.
Name | Type | Optional | Description |
---|---|---|---|
localizedDescriptions | LocalizationMap | null | No | The object of localized descriptions to set |
setName(name)
:
this
Sets the name of this command.
Name | Type | Optional | Description |
---|---|---|---|
name | string | No | The name to use |
setNameLocalization(locale, localizedName)
:
this
Sets a name localization for this command.
Name | Type | Optional | Description |
---|---|---|---|
locale | LocaleString | No | The locale to set |
localizedName | string | null | No | The localized name for the given locale |
setNameLocalizations(localizedNames)
:
this
Sets the name localizations for this command.
Name | Type | Optional | Description |
---|---|---|---|
localizedNames | LocalizationMap | null | No | The object of localized names to set |