Slash Commands

Create Discord slash commands and integrate them with application commands.

Example Usage

Create it inside commands/slash/register.ts.

1import { Modal, SlashCommandBuilder } from 'discordjs-nextgen';
2
3const registerCommand = {
4 data: new SlashCommandBuilder()
5 .setName('register')
6 .setDescription('Open the registration form'),
7 category: 'user',
8 usage: 'register',
9 aliases: ['signup'],
10 run: async (ctx) => {
11 const modal = Modal.create('reg_modal')
12 .title('Registration')
13 .short('username', { label: 'Username' })
14 .paragraph('bio', { label: 'About', required: false });
15
16 await ctx.showModal(modal);
17 }
18};
19
20export default registerCommand;

Features

  • Compatible with SlashCommandBuilder.
  • Automatic registration via app.slash().
  • Alias support for additional slash names.
  • Modal support directly from slash flows.