CommandBuilder
function in meocord/decorator Since 4.0.0
CommandBuilder<T extends BuildableCommandType>(
commandType: T,
options?: CommandBuilderOptions,
): (
target: new () => CommandBuilderBase<T>,
propertyKey?: string | symbol,
) => voidMarks a class as a command's builder, which describes the command MeoCord registers with Discord.
Use it for each slash or context menu command, and pass the class to @Command in place of a
CommandType. A subcommand handler, or a component's, takes a CommandType instead and registers nothing.
Parameters
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
commandType | T | The type of command the class builds. | ||
options? | CommandBuilderOptions | 4.1.0 | Where the command is registered, in place of the configured scope. | |
options.guilds? | (string | undefined)[] | the configured scope | 4.1.0 | The servers this command is registered to, in place of the configured scope. A command whose list is empty after dropping blank ids is not registered at all, rather than falling back to global. Under a development server, it goes there with every other command. |
Returns
Returns a property decorator.
(target: new () => CommandBuilderBase<T>, propertyKey?: string | symbol) => voidExamples
@CommandBuilder(CommandType.SLASH)
export class PingCommandBuilder implements CommandBuilderBase {
build(commandName: string): SlashCommandBuilder {
return new SlashCommandBuilder().setName(commandName).setDescription('Replies with pong')
}
}