Skip to content

ApplicationCommand

classe · Source

Represents an application command.

Extends: Base

Properties

id

id: Snowflake

The command's id Source

applicationId

applicationId: Snowflake

The parent application's id Source

guild

nullable

guild: Guild

The guild this command is part of Source

guildId

nullable

guildId: Snowflake

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

permissions: ApplicationCommandPermissionsManager

The manager for permissions of this command on its guild or arbitrary guilds when the command is global Source

type

type: ApplicationCommandType

The type of this application command Source

name

name: string

The name of this command Source

nameLocalizations

nullable

nameLocalizations: Object<Locale, string>

The name localizations for this command Source

nameLocalized

nullable

nameLocalized: string

The localized name for this command Source

description

description: string

The description of this command Source

descriptionLocalizations

nullable

descriptionLocalizations: Object<Locale, string>

The description localizations for this command Source

descriptionLocalized

nullable

descriptionLocalized: string

The localized description for this command Source

options

options: Array<ApplicationCommandOption>

The options of this command Source

defaultPermission

deprecated

defaultPermission: boolean

Whether the command is enabled by default when the app is added to a guild Source

defaultMemberPermissions

nullable

defaultMemberPermissions: Readonly<Permissions>

The default bitfield used to determine whether this command be used in a guild Source

dmPermission

nullable

dmPermission: boolean

Whether the command can be used in DMs This property is always null on guild commands Source

version

version: Snowflake

Autoincrementing version identifier updated during substantial record changes Source

createdTimestamp

readonly

createdTimestamp: number

The timestamp the command was created at Source

createdAt

readonly

createdAt: Date

The time the command was created at Source

manager

readonly

manager: ApplicationCommandManager

The manager that this command belongs to Source

client

readonly

client: Client

The client that instantiated this Source

Methods

edit

edit(data: Partial<ApplicationCommandData>): Promise<ApplicationCommand>

Edits this application command. Parameters

NameTypeDescription
dataPartial<ApplicationCommandData>The data to update the command with

Returns: Promise<ApplicationCommand>

js
// Edit the description of this command
command.edit({
  description: 'New description',
})
  .then(console.log)
  .catch(console.error);

Source

setName

setName(name: string): Promise<ApplicationCommand>

Edits the name of this ApplicationCommand Parameters

NameTypeDescription
namestringThe new name of the command

Returns: Promise<ApplicationCommand>Source

setNameLocalizations

setNameLocalizations(nameLocalizations: Object<Locale, string>): Promise<ApplicationCommand>

Edits the localized names of this ApplicationCommand Parameters

NameTypeDescription
nameLocalizationsObject<Locale, string>The new localized names for the command

Returns: Promise<ApplicationCommand>

js
// Edit the name localizations of this command
command.setLocalizedNames({
  'en-GB': 'test',
  'pt-BR': 'teste',
})
  .then(console.log)
  .catch(console.error)

Source

setDescription

setDescription(description: string): Promise<ApplicationCommand>

Edits the description of this ApplicationCommand Parameters

NameTypeDescription
descriptionstringThe new description of the command

Returns: Promise<ApplicationCommand>Source

setDescriptionLocalizations

setDescriptionLocalizations(descriptionLocalizations: Object<Locale, string>): Promise<ApplicationCommand>

Edits the localized descriptions of this ApplicationCommand Parameters

NameTypeDescription
descriptionLocalizationsObject<Locale, string>The new localized descriptions for the command

Returns: Promise<ApplicationCommand>

js
// 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)

Source

setDefaultPermission

deprecated

setDefaultPermission(defaultPermission?: boolean): Promise<ApplicationCommand>

Edits the default permission of this ApplicationCommand Parameters

NameTypeDescription
defaultPermission?booleanThe default permission for this command Default: true.

Returns: Promise<ApplicationCommand>Source

setDefaultMemberPermissions

setDefaultMemberPermissions(defaultMemberPermissions: PermissionResolvable): Promise<ApplicationCommand>

Edits the default member permissions of this ApplicationCommand Parameters

NameTypeDescription
defaultMemberPermissionsPermissionResolvableThe default member permissions required to run this command

Returns: Promise<ApplicationCommand>Source

setDMPermission

setDMPermission(dmPermission?: boolean): Promise<ApplicationCommand>

Edits the DM permission of this ApplicationCommand Parameters

NameTypeDescription
dmPermission?booleanWhether the command can be used in DMs Default: true.

Returns: Promise<ApplicationCommand>Source

setOptions

setOptions(options: Array<ApplicationCommandOptionData>): Promise<ApplicationCommand>

Edits the options of this ApplicationCommand Parameters

NameTypeDescription
optionsArray<ApplicationCommandOptionData>The options to set for this command

Returns: Promise<ApplicationCommand>Source

delete

delete(): Promise<ApplicationCommand>

Deletes this command. Returns: Promise<ApplicationCommand>

js
// Delete this command
command.delete()
  .then(console.log)
  .catch(console.error);

Source

equals

equals(command: ApplicationCommand | ApplicationCommandData | APIApplicationCommand, enforceOptionOrder?: boolean): boolean

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

NameTypeDescription
commandApplicationCommand | ApplicationCommandData | APIApplicationCommandThe command to compare with
enforceOptionOrder?booleanWhether 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

static

optionsEqual(existing: Array<ApplicationCommandOptionData>, options: Array<ApplicationCommandOptionData> | Array<APIApplicationCommandOption>, enforceOptionOrder?: boolean): boolean

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

NameTypeDescription
existingArray<ApplicationCommandOptionData>The options on the existing command,
should be ApplicationCommand#options
optionsArray<ApplicationCommandOptionData> | Array<APIApplicationCommandOption>The options to compare against
enforceOptionOrder?booleanWhether 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

static · private

_optionEquals(existing: ApplicationCommandOptionData, option: ApplicationCommandOptionData | APIApplicationCommandOption, enforceOptionOrder?: boolean): boolean

Checks that an option for an ApplicationCommand is equal to the provided option In most cases it is better to compare using ApplicationCommand#equalsParameters

NameTypeDescription
existingApplicationCommandOptionDataThe option on the existing command,
should be from ApplicationCommand#options
optionApplicationCommandOptionData | APIApplicationCommandOptionThe option to compare against
enforceOptionOrder?booleanWhether 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

static · private

transformOption(option: ApplicationCommandOptionData | ApplicationCommandOption, received?: boolean): APIApplicationCommandOption

Transforms an ApplicationCommandOptionData object into something that can be used with the API. Parameters

NameTypeDescription
optionApplicationCommandOptionData | ApplicationCommandOptionThe option to transform
received?booleanWhether this option has been received from Discord

Returns: APIApplicationCommandOptionSource

Unofficial software. Not affiliated with or supported by Discord.