ApplicationCommandManager
ApplicationCommandManager ⇐ Base
Section titled “ApplicationCommandManager ⇐ Base”Represents a manager for application commands.
Kind: global class
Extends: Base
- ApplicationCommandManager ⇐
Base- new ApplicationCommandManager(client)
- instance
- .permissions ⇒
ApplicationCommandPermissionManager - .cache ⇒
- ._add(commands, [guild], [options]) ⇒
ApplicationCommand - .create([options], [guild]) ⇒
Promise.<ApplicationCommand> - .set([options], [guild]) ⇒
Promise.<Cache> - .fetch(command, options) ⇒
Promise - .delete(command, [guild]) ⇒
Promise.<ApplicationCommand> - .edit(command, [options], [guild]) ⇒
Promise.<ApplicationCommand> - ._fetchId(command, [cache], [force], [guild]) ⇒
Promise.<object>
- .permissions ⇒
- static
- .transformOptions(options) ⇒
object - .transformPayload(payload) ⇒
Object
- .transformOptions(options) ⇒
new ApplicationCommandManager(client)
Section titled “new ApplicationCommandManager(client)”Constructs a new instance of the class.
| Param | Type | Description |
|---|---|---|
| client | Client | The client object used for communication with the server. |
applicationCommandManager.permissions ⇒ ApplicationCommandPermissionManager
Section titled “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 ⇒
Section titled “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
Section titled “applicationCommandManager._add(commands, [guild], [options]) ⇒ ApplicationCommand”Adds a command to the command cache.
Kind: instance method of ApplicationCommandManager
Returns: ApplicationCommand - The added command.
| Param | Type | Default | Description |
|---|---|---|---|
| commands | string | ApplicationCommand | The 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] | boolean | true | Whether to cache the command. |
| [options.force] | boolean | false | Whether to force adding the command even if it already exists in the cache. |
applicationCommandManager.create([options], [guild]) ⇒ Promise.<ApplicationCommand>
Section titled “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:
ErrorIf the command creation fails.
| Param | Type | Default | Description |
|---|---|---|---|
| [options] | Object | The 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>
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| [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
Section titled “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.
| Param | Type | Description |
|---|---|---|
| command | string | ApplicationCommand | The command to fetch. Can be an ID, a string, or an object. |
| options | object | The options for fetching the commands. |
| options.cache | boolean | Whether to use the cache for fetching the commands. |
| options.force | boolean | Whether to force fetch the commands. |
| options.guild | string | The ID of the guild to fetch the commands from. |
| options.withLocalizations | boolean | Whether to include localizations in the fetched commands. |
applicationCommandManager.delete(command, [guild]) ⇒ Promise.<ApplicationCommand>
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| command | string | ApplicationCommand | The 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>
Section titled “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:
RangeErrorIf the application command is required but not provided.
| Param | Type | Default | Description |
|---|---|---|---|
| command | string | ApplicationCommand | The command ID or the command object to edit. | |
| [options] | object | The 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>
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| command | string | object | The command ID or command object. | |
| [cache] | boolean | true | Whether to cache the fetched command. |
| [force] | boolean | false | Whether 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
Section titled “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.
| Param | Type | Description |
|---|---|---|
| options | object | The options object to transform. |
ApplicationCommandManager.transformPayload(payload) ⇒ Object
Section titled “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.
| Param | Type | Description |
|---|---|---|
| payload | Object | The payload object containing the command details. |