CLI Tool

create-discordjs-nextgen

Start an interactive wizard with one command and create Discord bot projects for JavaScript or TypeScript in seconds.

Quick Start

1npx create-discordjs-nextgen
1npx create-discordjs-nextgen my-awesome-bot
2npx create-discordjs-nextgen my-awesome-bot --jsx

Wizard Flow

  • Ask for the project name.
  • Let you choose JavaScript or TypeScript.
  • Offer Voice, JSX and Cache plugin options.
  • Let you choose Starter, Basic or Advanced.
  • Optionally run npm install automatically.

JSX Setup

If JSX is selected or --jsx is passed, the project is prepared automatically for JSX usage.

  • discordjs-nextgen-jsx is added as a dependency.
  • JSXPlugin is imported and app.use(new JSXPlugin()) is inserted into index.js or index.ts.
  • jsconfig.json for JavaScript or tsconfig.json for TypeScript is created.
  • A sample commands/prefix/hello.jsx or commands/prefix/hello.tsx command is generated.
1import { JSXPlugin } from 'discordjs-nextgen-jsx';
2
3const app = new App({ intents: Intents.ALL });
4
5app.use(new JSXPlugin());
1{
2 "compilerOptions": {
3 "jsx": "react-jsx",
4 "jsxImportSource": "discordjs-nextgen-jsx"
5 },
6 "include": ["**/*"]
7}

Cache Setup

The CLI offers two cache options: Cache (Sade) and Cache (with Redis).

  • discordjs-nextgen-cache is added as a dependency.
  • ioredis is added automatically if 'Cache (with Redis)' is selected.
  • CachePlugin and the selected adapter (Memory or Redis) are injected into the entry file.
  • A sample commands/prefix/money.js or commands/prefix/money.ts command is generated in the Advanced template.
1import { CachePlugin, MemoryAdapter } from 'discordjs-nextgen-cache';
2
3const app = new App({ intents: Intents.ALL });
4
5// Injected automatically by CLI
6app.use(new CachePlugin({ adapter: new MemoryAdapter() }));

Voice Setup

If Voice is selected, the CLI adds the voice package, injects app.use(new VoicePlugin()) and writes a sample command in matching templates.

Templates

1Starter
2- index.js / index.ts
3
4Basic
5- commands/prefix
6- commands/slash
7- commands/hybrid
8- events
9
10Advanced
11- commands
12- events
13- buttons
14- modals
15- selects

JSX Example Command

1import { Container, TextDisplay } from 'discordjs-nextgen-jsx';
2
3const hello = {
4 name: 'hello',
5 description: 'JSX example command',
6 run: async (ctx) => {
7 const card = (
8 <Container accentColor={0x5865f2}>
9 <TextDisplay content="Hello from JSX." />
10 <TextDisplay content={`Author: ${ctx.user.username}`} />
11 </Container>
12 );
13
14 await ctx.reply({
15 components: [card],
16 });
17 },
18};
19
20export default hello;