ApplicationCommandManager
classe · Source
Manages API methods for application commands and stores their cache.
Extends: CachedManager
Properties
permissions
The manager for permissions of arbitrary commands on arbitrary guilds Source
cache
The cache of this manager Source
_cache
The private cache of items for this manager. Source
holds
The data structure belonging to this manager. Source
client
The client that instantiated this Manager Source
Methods
commandPath
The APIRouter path to the commands Parameters
| Name | Type | Description |
|---|---|---|
options.id? | Snowflake | The application command's id |
options.guildId? | Snowflake | The guild's id to use in the path, ignored when using a GuildApplicationCommandManager |
Returns: ObjectSource
fetch
Obtains one or multiple application commands from Discord, or the cache if it's already available. Parameters
| Name | Type | Description |
|---|---|---|
id? | Snowflake | The application command's id |
options? | FetchApplicationCommandOptions | Additional options for this fetch |
Returns: Promise<(ApplicationCommand\|Collection<Snowflake, ApplicationCommand>)>
// Fetch a single command
client.application.commands.fetch('123456789012345678')
.then(command => console.log(`Fetched command ${command.name}`))
.catch(console.error);// Fetch all commands
guild.commands.fetch()
.then(commands => console.log(`Fetched ${commands.size} commands`))
.catch(console.error);create
Creates an application command. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommandDataResolvable | The command |
guildId? | Snowflake | The guild's id to create this command in, ignored when using a GuildApplicationCommandManager |
Returns: Promise<ApplicationCommand>
// Create a new command
client.application.commands.create({
name: 'test',
description: 'A test command',
})
.then(console.log)
.catch(console.error);set
Sets all the commands for this application or guild. Parameters
| Name | Type | Description |
|---|---|---|
commands | Array<ApplicationCommandDataResolvable> | The commands |
guildId? | Snowflake | The guild's id to create the commands in, ignored when using a GuildApplicationCommandManager |
Returns: Promise<Collection<Snowflake, ApplicationCommand>>
// Set all commands to just this one
client.application.commands.set([
{
name: 'test',
description: 'A test command',
},
])
.then(console.log)
.catch(console.error);// Remove all commands
guild.commands.set([])
.then(console.log)
.catch(console.error);edit
Edits an application command. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommandResolvable | The command to edit |
data | Partial<ApplicationCommandDataResolvable> | The data to update the command with |
guildId? | Snowflake | The guild's id where the command registered, ignored when using a GuildApplicationCommandManager |
Returns: Promise<ApplicationCommand>
// Edit an existing command
client.application.commands.edit('123456789012345678', {
description: 'New description',
})
.then(console.log)
.catch(console.error);delete
Deletes an application command. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommandResolvable | The command to delete |
guildId? | Snowflake | The guild's id where the command is registered, ignored when using a GuildApplicationCommandManager |
Returns: Promise<?ApplicationCommand>
// Delete a command
guild.commands.delete('123456789012345678')
.then(console.log)
.catch(console.error);resolve
Resolves a data entry to a data Object. Parameters
| Name | Type | Description |
|---|---|---|
idOrInstance | string | Object | The id or instance of something in this Manager |
Returns: Object — An instance from this Manager Source
resolveId
Resolves a data entry to an instance id. Parameters
| Name | Type | Description |
|---|---|---|
idOrInstance | string | Object | The id or instance of something in this Manager |
Returns: SnowflakeSource
transformCommand
Transforms an ApplicationCommandData object into something that can be used with the API. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommandDataResolvable | The command to transform |
Returns: APIApplicationCommandSource