A simple template for your discord.js bot with discord.js Guide explanations.
- Slash commands support
- Status and activity configuration
- Command handler
- Event handler
- Components handler
- Working with databases (sequelize, keyv)
- Working with APIs (undici)
- Logging interactions and errors
- Using modern ES6 syntax
To install this repository properly, run this in your command-line interface.
git clone https://github.com/DevVali/djs14-template.git
After cloning the repository, you can install all required packages.
npm i
Tip: If you want to install only the packages of your choice, continue reading.
All packages are installed by default, but you may not need some packages (e.g. you will not be working with databases).
A package to interact with the Discord API. Required to run the bot properly.
npm i discord.js
Simple key-value storage that allows you to work with databases.
npm i keyv
Additionally, install @keyv/sqlite (we used SQLite in this template).
npm i @keyv/sqlite
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
npm i --save-dev eslint
Additionally, install the appropriate plugin(s) for your editor of choice.
Sequelize is an object-relational-mapper that allows you to work with databases.
npm i sequelize sqlite3
An excellent library for making HTTP requests.
npm i undici
Examples and explanations from the discord.js Guide.
- Buttons
- Select menus
- Modals
- Context Menus
- How do I check the bot's ping?
- Threads and Embeds
- Reactions, Permissions, Webhooks and Storing data with Keyv
- Storing data with Sequelize
- Using a REST API
Tip: Don't forget to edit the
config.json
file with your bot's configuration.
Before getting into the process of starting your discord.js bot, you will have to register your commands to Discord.
node deploy-commands.js
Refresh your Discord client and if you see your bot's commands, you're good to go!
Let's start your bot.
node index.js
If you see "Ready!" after a few seconds, congratulations on starting your discord.js bot. 🎉
node dbInit.sequelize.js
This project was made as a help for programmers learning discord.js on providing them some examples how discord.js code should look like. If you found that we are missing a resource, feel free to add one by yourself and open a PR. 💖 If you decide to do so, don't forget to use the recommended editor plugins.