discord-handler-js is an optimized Discord bot structure that lets you easily create your own Discord Bot.
- The discord-handler-js uses ES6 modules.
- The discord-handler-js uses the latest version of discord.js v^1.14.
-
- Slash commands
- User contexts
- Message contexts
-
- Buttons
- Modals
- Select Menus
- Node.js v^16.9.1 or newer
- Discord Application's credentials
Please read Requirements before starting installation.
-
Install this project (2 options):
- Using command:
git clone https://github.com/agonkolgeci/discord-handler-js.git
- Download the project ZIP then extract it
- Using command:
-
Open the new folder with your favorite text editor
-
Configure the following files:
.env
- Application Credentialssrc/resources/config.js
- Client Configuration
-
Install required packages:
npm install
- Run your bot in normal mode: (otherwise see sharding mode)
node src/index.js
To run your application in sharding mode:
node src/shard.js
You can implement various commands in the same file.
export default [
{
structure: SlashCommandBuilder | ContextMenuCommandBuilder,
onCommand: async(client, interaction) => {
await interaction.reply(`Command ${interaction.commandName} used by ${interaction.user} !`);
}
},
... // More commands
]
You can implement various components in the same file.
export default [
{
customId: string,
onButton: async(client, interaction) => {
await interaction.reply(`Button ${interaction.customId} used by ${interaction.user} !`);
},
onModalSubmit: async(client, interaction) => {
await interaction.reply(`Modal ${interaction.customId} submited by ${interaction.user} !`);
},
onSelectMenu: async(client, interaction) => {
await interaction.reply(`Select Menu ${interaction.customId} used by ${interaction.user} !`);
}
},
... // More components
]
You can implement various events in the same file.
Note that you must replace ...args
with the event arguments.
export default [
{
name: string,
once: true,
onEvent: async(client, ...args) => {
await client.logger.log("info", `Event ${name} called !`);
}
},
... // More events
]
discord-handler-js uses a custom logger system (using colors thanks to chalk).
You can configure it from the Logger Module
- Import the Logger Module:
import logger from "path/to/logger.js";
discord-handler-js uses a message formatting system intended for users.
You can configure it from the configuration
- Use from Extended Client
ExtendedClient#formatter
discord-handler-js lets you open a connection to a MongoDB.
- Configure it from the .env
- Enable it from the configuration
This project is published under the GNU General Public License v^3.0. You can download, modify or redistribute - even commercially - this software freely, as long as you specify that your work is a reworking of this project. For more details, please refer to the license text.
- Inspiration from DiscordJS-V14-Bot-Template