mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
feat(create-discord-bot): Add prompts, command handler and deployment script (#9570)
* feat(create-discord-bot): Add prompts, command handler and deployment script * fix: revert package template name * chore: make requested changes * chore: make requested changes * fix: remove uneeded listeners * fix: use `0` for eslint * fix: remaining requested changes * chore: requested changes * fix: remove redundant call
This commit is contained in:
39
packages/create-discord-bot/src/index.ts
Normal file
39
packages/create-discord-bot/src/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { program } from 'commander';
|
||||
import prompts from 'prompts';
|
||||
import { createDiscordBot } from './create-discord-bot.js';
|
||||
|
||||
program
|
||||
.description('Create a basic discord.js bot.')
|
||||
.option('--directory', 'The directory where this will be created.')
|
||||
.option('--typescript', 'Whether to use the TypeScript template.')
|
||||
.option('--javascript', 'Whether to use the JavaScript template.')
|
||||
.parse();
|
||||
|
||||
let { typescript, javascript, directory } = program.opts();
|
||||
|
||||
if (!directory) {
|
||||
directory = (
|
||||
await prompts({
|
||||
type: 'text',
|
||||
name: 'directory',
|
||||
initial: 'my-bot',
|
||||
message: 'What is the name of the directory you want to create this project in?',
|
||||
})
|
||||
).directory;
|
||||
}
|
||||
|
||||
if (typescript === undefined && javascript === undefined) {
|
||||
const { useTypescript } = await prompts({
|
||||
type: 'toggle',
|
||||
name: 'useTypescript',
|
||||
message: 'Do you want to use TypeScript?',
|
||||
initial: true,
|
||||
active: 'Yes',
|
||||
inactive: 'No',
|
||||
});
|
||||
|
||||
typescript = useTypescript;
|
||||
javascript = !useTypescript;
|
||||
}
|
||||
|
||||
await createDiscordBot({ typescript, javascript, directory });
|
||||
Reference in New Issue
Block a user