Skip to main content

Acquiring an Application Command Registry

To work with an application command registry, you must "acquire" one for your commands. We can do this by using the pre-defined registry for a command through the registerApplicationCommands method argument of the Command class.

import { ApplicationCommandRegistry, Command } from '@sapphire/framework';export class PingCommand extends Command {  public override registerApplicationCommands(registry: ApplicationCommandRegistry) {    // registry is unique to this command  }}

Acquiring and accessing the application command registry this way is only associated with PingCommand - it will not interact with any other of your commands.

caution

For most users, the method above should suffice. Another way of acquiring an application command registry is through ApplicationCommandRegistries.acquire(), but it should only be chosen for advanced usage such as handling application command registration outside a command or creating TypeScript decorators.

import { ApplicationCommandRegistries } from '@sapphire/framework';// Acquires the registry keyed by 'ping'const pingRegistry = ApplicationCommandRegistries.acquire('ping');

Read Registering Application Commands outside a Command for more details