Skip to content
This repository has been archived by the owner on Aug 7, 2020. It is now read-only.
/ create-djsbot Public archive

⚡Bootstrapping CLI tool for quickly setting up a Discord bot project

License

Notifications You must be signed in to change notification settings

favware/create-djsbot

Repository files navigation

logo

Create DJS Bort

Bootstrapping CLI tool for quickly setting up a Discord bot project


Project Status

GitHub CircleCI

NPM Versions

npm

Social Media and Donations

Join Discord server Twitter Follow Patreon Donate PayPal Donate

Install

Using Yarn

yarn create djsbot
# or for reusability
yarn global add create-djsbot
create-djsbot mybot

Using NPM

npx create-djsbot mybot
# or for reusability
npm install --global create-djsbot
create-djsbot mybot

Answer some basic prompts about your module, and then the CLI will perform the following steps:

  • copy over the template
  • install dependencies via yarn or npm
  • initialize local git repo

Documentation

Status of this project

Before documenting anything else I just want to put out here that I'll maintain this project in terms of (security) issues, major updates are less likely to come quickly if at all. This is because these templates are based on the Commando framework whilst I have moved to the Klasa framework myself for my own bot. That said however this generator is still a great way to get started with any bot regardless of framework you end up using.

Features

  • Easy to use CLI
  • ESLint for linting
  • Utilizes the DiscordJS-Commando framework
  • Optional support for TypeScript
  • (TypeScript only) Interactive reloading script for single files for hot-reloading

Usage

Create DJSBot - Easily bootstrap your bot!

Usage:
    create-djsbot
    create-djsbot --help
    create-djsbot --name mybot

Options:
  --help         Show help                                             [boolean]
  --version      Show version number                                   [boolean]
  --interactive                                                        [default: true]
  --name         What is the name of your bot project?
  --description  What is the description for this bot?
  --author       Who is the author of the bot? (GitHub username)
  --license      What license do you want the bot to have?             [choices: "MIT", "GPL-3.0-or-later", "Apache-2.0", "Unlicense", "MPL-2.0"]
  --repo         Do you have an URL for the Git repository for the bot?
  --gitinit      Should a the repo be initialized with "git init"?
  --manager      Do you want to use Yarn or NPM?                       [choices: "npm", "yarn"]
  --template     Do you want to use JavaScript or TypeScript?          [choices: "javascript", "typescript"]
  --prefix       What is the bot prefix you want to set as default?
  --ownerid      What is your Discord userID that will be registered as the bot owner?
  --token        And lastly, do you already have a token the bot will use?

Setting up development environment

If the template fails to run the npm install or yarn install, please follow these instructions before getting support:

  • Windows:
    • run npm i windows-build-tools --production --vs2015 --add-python-to-PATH --global in an administrative CMD or Powershell
  • MacOS:
    • Install the XCode Selects tools: xcode-select --install
    • Install Brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Linux Debian / Ubuntu:
    • Install build-essential: sudo apt-get install -y build-essential
  • Other OS / distro's:
    • Please google how to install build essentials such as GCC and Make

Notes about the TypeScript template

A few notes should be shared about the TypeScript template that are important to note

  1. It uses forks of Discord.JS and Discord.JS-Commando that are based on the "master" branch so please refer to the "master" documentation. The reason for this is that Commando has added a lot of extra TypeScript support since it's latest stable release and when using the "master" branch for Discord.JS-Commando then the master branch for Discord.JS should also be used. I (Favna) manage these forks and ensure they are always stable before publishing any updates as I use them in my own bot

  2. In TypeScript you should to use ES6 imports/exports rather than CommonJS module.exports and require as it's far more efficient, adds a lot of cool features such as default exports, named exports and advanced imports and it's far easier to write and remember.

  3. You should not use ts-node to run your bot unless during development. It is very slow and inefficient for production environments.

  4. Therefore always compile your bot to JavaScript using npm run build or yarn build

  5. And do not remove anything from the build, prebuild, postbuild, copyfiles or replace scripts. Doing so will either cause your bot to not build properly at all, or cause inefficiencies in the long term. Adding to it is perfectly fine however!

  6. The TypeScript config allows you to use aliases for easier accessing the commands and utils folders. For example if you need to log something you can import log from '@utils/winston' (which imports the winston.ts file at src/utils/winston.ts, no matter how many subfolders deep you are) then use this as log.info().

  7. When getting support anywhere always specify that you are writing TypeScript to get the best support.

  8. You can always join my server for support as well.


About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

License

Copyright © 2018-2019, Favware. Released under the MIT License.

Special Thanks