Function: RegisterChatInputCommand()
RegisterChatInputCommand<
CMD>(optionsFn: (builder:SlashCommandBuilder,command:ThisType<CMD> &CMD) =>SlashCommandBuilder|SlashCommandOptionsOnlyBuilder|SlashCommandSubcommandsOnlyBuilder,registryOptions?:RegisterOptions):ClassDecorator
Defined in: piece-decorators.ts:148
Decorator for registering chat input command.
Type Parameters
| Type Parameter | Default type |
|---|---|
CMD extends Command<Args, CommandOptions> | Command<Args, CommandOptions> |
Parameters
| Parameter | Type | Description |
|---|---|---|
optionsFn | (builder: SlashCommandBuilder, command: ThisType<CMD> & CMD) => SlashCommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder | The function that returns options to pass to the registry. |
registryOptions? | RegisterOptions | - |
Returns
ClassDecorator
Examples
import { RegisterChatInputCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
(at)RegisterChatInputCommand((builder, command) => builder
.setName(command.name)
.setDescription(command.description)
)
export class UserCommand extends Command {
public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {
return interaction.reply({ content: 'HI!' });
}
}
import { RegisterChatInputCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
(at)RegisterChatInputCommand((builder, command) => builder
.setName(command.name)
.setDescription(command.description),
{
idHints: ['737141877803057244'],
guildIds: ['737141877803057244']
}
)
export class UserCommand extends Command {
public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {
return interaction.reply({ content: 'HI!' });
}
}
import { RegisterChatInputCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
(at)RegisterChatInputCommand((builder) => builder
.setName('hi')
.setDescription('Sends a hi message')
)
export class UserCommand extends Command {
public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {
return interaction.reply({ content: 'HI!' });
}
}
import { ApplyOptions, RegisterChatInputCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import type { Message } from 'discord.js';
(at)ApplyOptions<Command.Options>({
description: 'ping pong',
enabled: true
})
(at)RegisterChatInputCommand((builder, command) => builder
.setName(command.name)
.setDescription(command.description)
)
export class UserCommand extends Command { *
public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {
return interaction.reply({ content: 'HI!' });
}
}