ApplicationCommand
classe · Source
Represents an application command.
Extends: Base
Properties
id
The command's id Source
applicationId
The parent application's id Source
guild
The guild this command is part of Source
guildId
The guild's id this command is part of, this may be non-null when guild is null if the command was fetched from the ApplicationCommandManagerSource
permissions
The manager for permissions of this command on its guild or arbitrary guilds when the command is global Source
type
The type of this application command Source
name
The name of this command Source
nameLocalizations
The name localizations for this command Source
nameLocalized
The localized name for this command Source
description
The description of this command Source
descriptionLocalizations
The description localizations for this command Source
descriptionLocalized
The localized description for this command Source
options
The options of this command Source
defaultPermission
Whether the command is enabled by default when the app is added to a guild Source
defaultMemberPermissions
The default bitfield used to determine whether this command be used in a guild Source
dmPermission
Whether the command can be used in DMs This property is always null on guild commands Source
version
Autoincrementing version identifier updated during substantial record changes Source
createdTimestamp
The timestamp the command was created at Source
createdAt
The time the command was created at Source
manager
The manager that this command belongs to Source
client
The client that instantiated this Source
Methods
edit
Edits this application command. Parameters
| Name | Type | Description |
|---|---|---|
data | Partial<ApplicationCommandData> | The data to update the command with |
Returns: Promise<ApplicationCommand>
// Edit the description of this command
command.edit({
description: 'New description',
})
.then(console.log)
.catch(console.error);setName
Edits the name of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
name | string | The new name of the command |
Returns: Promise<ApplicationCommand>Source
setNameLocalizations
Edits the localized names of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
nameLocalizations | Object<Locale, string> | The new localized names for the command |
Returns: Promise<ApplicationCommand>
// Edit the name localizations of this command
command.setLocalizedNames({
'en-GB': 'test',
'pt-BR': 'teste',
})
.then(console.log)
.catch(console.error)setDescription
Edits the description of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
description | string | The new description of the command |
Returns: Promise<ApplicationCommand>Source
setDescriptionLocalizations
Edits the localized descriptions of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
descriptionLocalizations | Object<Locale, string> | The new localized descriptions for the command |
Returns: Promise<ApplicationCommand>
// Edit the description localizations of this command
command.setLocalizedDescriptions({
'en-GB': 'A test command',
'pt-BR': 'Um comando de teste',
})
.then(console.log)
.catch(console.error)setDefaultPermission
Edits the default permission of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
defaultPermission? | boolean | The default permission for this command Default: true. |
Returns: Promise<ApplicationCommand>Source
setDefaultMemberPermissions
Edits the default member permissions of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
defaultMemberPermissions | PermissionResolvable | The default member permissions required to run this command |
Returns: Promise<ApplicationCommand>Source
setDMPermission
Edits the DM permission of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
dmPermission? | boolean | Whether the command can be used in DMs Default: true. |
Returns: Promise<ApplicationCommand>Source
setOptions
Edits the options of this ApplicationCommand Parameters
| Name | Type | Description |
|---|---|---|
options | Array<ApplicationCommandOptionData> | The options to set for this command |
Returns: Promise<ApplicationCommand>Source
delete
Deletes this command. Returns: Promise<ApplicationCommand>
// Delete this command
command.delete()
.then(console.log)
.catch(console.error);equals
Whether this command equals another command. It compares all properties, so for most operations it is advisable to just compare command.id === command2.id as it is much faster and is often what most users need. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommand | ApplicationCommandData | APIApplicationCommand | The command to compare with |
enforceOptionOrder? | boolean | Whether to strictly check that options and choices are in the same order in the array The client may not always respect this ordering! Default: false. |
Returns: booleanSource
optionsEqual
Recursively checks that all options for an ApplicationCommand are equal to the provided options. In most cases it is better to compare using ApplicationCommand#equalsParameters
| Name | Type | Description |
|---|---|---|
existing | Array<ApplicationCommandOptionData> | The options on the existing command, should be ApplicationCommand#options |
options | Array<ApplicationCommandOptionData> | Array<APIApplicationCommandOption> | The options to compare against |
enforceOptionOrder? | boolean | Whether to strictly check that options and choices are in the same order in the array The client may not always respect this ordering! Default: false. |
Returns: booleanSource
_optionEquals
Checks that an option for an ApplicationCommand is equal to the provided option In most cases it is better to compare using ApplicationCommand#equalsParameters
| Name | Type | Description |
|---|---|---|
existing | ApplicationCommandOptionData | The option on the existing command, should be from ApplicationCommand#options |
option | ApplicationCommandOptionData | APIApplicationCommandOption | The option to compare against |
enforceOptionOrder? | boolean | Whether to strictly check that options or choices are in the same order in their array The client may not always respect this ordering! Default: false. |
Returns: booleanSource
transformOption
Transforms an ApplicationCommandOptionData object into something that can be used with the API. Parameters
| Name | Type | Description |
|---|---|---|
option | ApplicationCommandOptionData | ApplicationCommandOption | The option to transform |
received? | boolean | Whether this option has been received from Discord |
Returns: APIApplicationCommandOptionSource