Files
discord.js/packages/create-discord-bot/src/index.ts
Suneet Tipirneni 84f1b1890d 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
2023-07-16 17:13:18 +00:00

40 lines
1.0 KiB
TypeScript

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 });