Command and use decorators to describe the application command Discord should register.
Create a Chat Input Command
client.load(). The loader discovers the class and adds its builder
to the application-command registry.
Add Subcommands
Use@RegisterSubcommand on methods that should receive a specific subcommand:
Restrict Who Can Run a Command
Preconditions are checks that run before a command. Write one as a piece that extendsPrecondition in the
preconditions directory:
preconditions option of the command:
chatInputCommandDenied with the
error. Reply to the user from a listener on that event. See Preconditions
for AND/OR combinations, parallel runs, global preconditions, and interaction handlers.
Publish Command Definitions
To keep Discord in sync automatically, enable startup registration on theClient. After listen() runs its
postListen hooks, the client compares the loaded commands with the deployed ones and writes only the differences:
removeUnknown: true. If registration fails, the
client logs a warning and keeps serving interactions. In sharder or broker deployments, use when to register from one
process only. Bots that use client.fetch() instead of listen() call await client.registry.sync() after
client.load(). See Sync commands on startup for
every option.
To overwrite whole scopes instead, push the registry to Discord after loading pieces: