A minimalist template for starting a new Discord bot project.
This template provides a basic Discord bot project containing a sample bot application that supports slash commands. The project is written in TypeScript and utilizes the Sapphire framework to help create the bot application. To simplify deployment, this template includes support for building a Docker image of the bot project.
- Minimal Discord bot project written in TypeScript with ESM support.
- Uses Sapphire as the framework for creating the Discord bot application.
- Supports building the Discord bot application as a Docker image.
- Uses Yarn as the package manager with Plug'n'Play support.
- Supports formatting with Prettier and linting with ESLint.
- Preconfigured workflows for Dependabot and GitHub Actions.
This guide explains how to use this template to start a new Discord bot project, from creation to deployment.
Follow this link to create a new project based on this template. For more information about creating a repository from a template on GitHub, refer to this documentation.
Alternatively, you can clone this repository locally to begin using this template.
By default, this template is unlicensed. Before modifying this template, replace the LICENSE
file with the license to be used by the new project. For more information about licensing a repository, refer to this documentation.
Alternatively, you can remove the LICENSE
file or leave it as-is to keep the new project unlicensed.
Update the content of this README.md
file with a description of the new project. For more information on adding READMEs to a project, refer to this documentation.
It is recommended to use nvm to manage the Node.js version in the project. By default, this template uses the Node.js version specified in the .nvmrc
file. Use the following command to install and use the correct Node.js version with nvm:
nvm install
This template uses Yarn with Plug'n'Play support as the package manager. If Yarn is not yet enabled, run the following command:
corepack enable yarn
Then, install the project dependencies with:
yarn install
For more information on Yarn, such as adding dependencies or running tools, refer to this documentation.
Before developing the bot application, ensure that you have set up a bot application and obtained a token to be used to access the bot. If not, refer to this documentation for setting up a new bot application and getting the access token.
After obtaining the access token, export it as a DISCORD_TOKEN
variable either in your shell environment or in an .env.yarn
file.
Develop the bot application by modifying the files under the src
directory according to the project requirements. For more detailed guidance on developing the bot application, refer to the Sapphire documentation and the TypeScript documentation.
Every time the code is written, check if it adheres to the standard conventions with the following command:
yarn check
After you're done, run the bot application using the following command:
yarn start
The bot application can simply be deployed by running the yarn start
command on a specific machine. Alternatively, the bot application can also be deployed as a Docker container, allowing it to run as a service while keeping the application contained in an isolated environment.
To do this, first, build the bot application into a Docker image using the following command:
docker build -t discord-bot .
Then run the Docker image as a service using the following command:
docker run -dt discord-bot
Refer to this documentation for more information on using Docker for managing containerized applications.