Skip to content

ApplicationCommandManager

ApplicationCommandManager ⇐ Base

Represents a manager for application commands.

Kind: global class
Extends: Base

new ApplicationCommandManager(client)

Constructs a new instance of the class.

ParamTypeDescription
clientClientThe client object used for communication with the server.

applicationCommandManager.permissions ⇒ ApplicationCommandPermissionManager

Returns the ApplicationCommandPermissionManager for managing permissions of application commands in a guild.

Kind: instance property of ApplicationCommandManager
Returns: ApplicationCommandPermissionManager - The ApplicationCommandPermissionManager instance.

applicationCommandManager.cache ⇒

Getter method for the cache property.

Kind: instance property of ApplicationCommandManager
Returns: The Collection object representing the cache.

applicationCommandManager._add(commands, [guild], [options]) ⇒ ApplicationCommand

Adds a command to the command cache.

Kind: instance method of ApplicationCommandManager
Returns: ApplicationCommand - The added command.

ParamTypeDefaultDescription
commandsstring | ApplicationCommandThe command or command ID to add.
[guild]string”this.guildId”The ID of the guild to add the command to.
[options]object{cache: true, force: false}Additional options for adding the command.
[options.cache]booleantrueWhether to cache the command.
[options.force]booleanfalseWhether to force adding the command even if it already exists in the cache.

applicationCommandManager.create([options], [guild]) ⇒ Promise.<ApplicationCommand>

Creates a new application command.

Kind: instance method of ApplicationCommandManager
Returns: Promise.<ApplicationCommand> - A promise that resolves with the created application command.
Throws:

  • Error If the command creation fails.
ParamTypeDefaultDescription
[options]ObjectThe options for the command.
[guild]string | Guild”this.guildId”The guild ID or guild object where the command should be created.

applicationCommandManager.set([options], [guild]) ⇒ Promise.<Cache>

Sets the application commands for the specified guild or globally.

Kind: instance method of ApplicationCommandManager
Returns: Promise.<Cache> - A promise that resolves to a new instance of the cache with the updated commands.

ParamTypeDefaultDescription
[options]Array.<Object>[{}]An array of options for the application commands.
[guild]string | Guild”this.guildId”The guild ID or guild object to set the commands for.

applicationCommandManager.fetch(command, options) ⇒ Promise

Fetches commands from the API based on the provided command and options.

Kind: instance method of ApplicationCommandManager
Returns: Promise - A promise that resolves to the fetched commands.

ParamTypeDescription
commandstring | ApplicationCommandThe command to fetch. Can be an ID, a string, or an object.
optionsobjectThe options for fetching the commands.
options.cachebooleanWhether to use the cache for fetching the commands.
options.forcebooleanWhether to force fetch the commands.
options.guildstringThe ID of the guild to fetch the commands from.
options.withLocalizationsbooleanWhether to include localizations in the fetched commands.

applicationCommandManager.delete(command, [guild]) ⇒ Promise.<ApplicationCommand>

Deletes an application command from the specified guild or the default guild.

Kind: instance method of ApplicationCommandManager
Returns: Promise.<ApplicationCommand> - - The deleted ApplicationCommand object.
Throws:

  • RangeError - If no command ID is specified.
ParamTypeDefaultDescription
commandstring | ApplicationCommandThe ID or the ApplicationCommand object to delete.
[guild]string | Guild”this.guildId”The ID or the Guild object where the command is located.

applicationCommandManager.edit(command, [options], [guild]) ⇒ Promise.<ApplicationCommand>

Edits an application command with the given command ID and options.

Kind: instance method of ApplicationCommandManager
Returns: Promise.<ApplicationCommand> - A promise that resolves with the updated command object.
Throws:

  • RangeError If the application command is required but not provided.
ParamTypeDefaultDescription
commandstring | ApplicationCommandThe command ID or the command object to edit.
[options]objectThe options to update the command with.
[guild]string | Guild”this.guildId”The guild ID or the guild object where the command is located.

applicationCommandManager._fetchId(command, [cache], [force], [guild]) ⇒ Promise.<object>

Fetches the ID of a command from the API.

Kind: instance method of ApplicationCommandManager
Returns: Promise.<object> - - A promise that resolves to the fetched command object.

ParamTypeDefaultDescription
commandstring | objectThe command ID or command object.
[cache]booleantrueWhether to cache the fetched command.
[force]booleanfalseWhether to force fetch the command even if it is already cached.
[guild]string | object”this.guildId”The guild ID or guild object. Defaults to the guild ID of the instance.

ApplicationCommandManager.transformOptions(options) ⇒ object

Transforms the given options object into the appropriate JSON format based on its type.

Kind: static method of ApplicationCommandManager
Returns: object - The transformed options object in JSON format.

ParamTypeDescription
optionsobjectThe options object to transform.

ApplicationCommandManager.transformPayload(payload) ⇒ Object

Transforms the payload object into a standardized format for application commands.

Kind: static method of ApplicationCommandManager
Returns: Object - - The transformed payload object.
Throws:

  • RangeError - If the payload is missing required fields or if the field values are out of range.
ParamTypeDescription
payloadObjectThe payload object containing the command details.