N

commands

namespace commands

Functions

F

createCommands(owner: string, options?: CommandsOptions): CommandsHandle

Creates the commands handle for one owner, like createPatcher does for patches. A plugin passes its manifest id, so its commands are removed when it stops; a built-in passes 'unbound'. Text is message keys.

Returns

The handle.

F

register<T>(commands: CommandTree<T>): () => void

Adds commands to the shared Unbound section of the / picker. Registering a root name again replaces that whole command; a root name another owner has throws CommandDefinitionError.

Returns

A function that removes this call's commands; it is safe to call twice.

F

unregister(name: string): void

Removes a root command added with register, with its subcommands. Does nothing when there is none.

Types

Suggests values for an option while the user types. At most 25 are shown.

What autocomplete sees: where it runs and the raw values of the other options filled in so far.

A value, or a promise of one.

Settings every builder accepts.

Settings of option.channel.

An autocomplete suggestion: a bare value, shown as itself, or a value with a label.

Settings option.choice accepts.

Each value option.choice allows, mapped to the message key of its label. Labels must differ in en-US.

An autocomplete suggestion's value with the label the picker shows for it.

A Discord channel, as the channel store returns it.

Where a command runs. Discord never runs a command without a channel.

A command that only groups subcommands: /root sub or /root group sub.

A Discord guild.

A key of the owner's i18n/en-US.json. The picker shows its message in the user's locale, falling back to en-US; a plugin's keys come from its generated src/unbound-i18n.d.ts.

A leaf or a group.

A Discord guild role.

The handle createCommands returns, scoped to one owner.

Options of createCommands.

Commands keyed by name, at every level. TypeScript infers T per key by reversing this mapped type, from options on a leaf and from subcommands on a group. A conditional type here breaks inference.

A Discord user, as the user store returns it. Only the fields commands rely on.

Shown only to the user, as a bot message.

An asset id from assets.Icons, or a data: or https: uri.

A command that runs. O is inferred from options and types execute's args. execute uses method syntax so its parameter stays bivariant and the registry can hold it erased.

The settings of an option kind that takes none.

Settings of option.integer and option.number.

A handler's args, derived from its options: a required option is V, an optional one V | undefined.

One kind's builder.

The option builders: one per kind, plus choice.

The option kinds: one builder each on option.

Each option kind's handler value and builder settings. The client's kind table implements every key.

The settings a kind's builder accepts beyond description and required.

One declared option, made by an option builder.

The value a handler receives for a kind.

Sent by Discord as a normal message from the user.

An option value as Discord passes it. User, channel and role options arrive as id strings.

What execute returns. A string is shorthand for { content }; nothing means the command did its own work.

An embed in an ephemeral reply.

A field of an embed in an ephemeral reply.

A section of the / picker owned by one owner.

Settings of option.string.

Variables

Option builders, one per kind: option.string({ required: true }), option.user(), option.choice({ ... }).