TypeScript
If you want type safety, you should probably consider TypeScript. Reciple supports building TypeScript module files out of the box thanks to tsdown.
During setup, reciple will prompt you if you want to use TypeScript. Select yes to use TypeScript for your project.
Modules
To create a new TypeScript module, just create a new file with the .ts extension. Reciple will automatically build it into a JavaScript module when you run npm run build.
import { SlashCommandModule } from "reciple";
class ExampleCommand extends SlashCommandModule {
public data: SlashCommandBuilder.Data = new SlashCommandBuilder()
.setName("example")
.setDescription("An example command")
.toJSON();
public async execute(data: SlashCommand.ExecuteData): Promise<void> {
const { interaction } = data;
await interaction.reply("Hello, world!");
}
}
export default new ExampleCommand();