A modular Discord bot developed with discord.js v14, designed so anyone can clone it and easily build their own bot with custom commands.
- β Modular command structure (Slash Commands)
- βοΈ Automatic command loading system
- Node.js v18 or higher
- A bot account in the Discord Developer Portal
Clone the repository:
git clone https://github.com/Smokyy14/discord.js-bot.git
cd discord.js-botSet your variables in the .env file:
DISCORD_TOKEN=your_token_here
CLIENT_ID=your_clientID_here
GUILD_ID=your_guildID_hereRun this to:
npm run start- Install dependencies
- Start the program
This will also automatically register the slash commands.
ποΈ Project structure
.
βββ commands/ # Folder for your slash commands
βββ handlers/
β βββ deploy.js #
β βββ loadCommands.js # Dynamic command loader
βββ .env # Token and sensitive configurations
βββ package.json
βββ main.js # Main entry point of the botAll commands should be in this folder:
/commands/Each command is a .js file that exports a valid Slash Command object, using the SlashCommandBuilder from discord.js.
// commands/ping.js
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('reply with Pong!'),
async execute(interaction) {
await interaction.reply('π Pong!');
},
};data: Defines the name and description of the command. execute: This is the function that is executed when the user uses the command.
The bot already includes a system that automatically detects these files thanks to loadCommands.js. You will need to restart the bot to be able to register slash commands.
Make sure:
The file is in /commands/ The bot has the correct application permissions Handlers/deploy.js was successfully executed on startup
Contributions are welcome! You can submit issues, suggestions, or pull requests.
This project is under the ISC license. Use, modify, and distribute it as you wish.
Created by Smoky with π for the Discord community.