A modular and scalable Discord bot built using discord.js.
It supports command and event handling, dotenv configuration, and code formatting via Biome.
src
├── commands/ # Command definitions
│ └── ping.js
├── events/ # Discord event handlers
│ └── ready.js
├── functions/ # Utility functions (e.g., loader)
│ └── loadCommands.js
└── index.js # Entry point
- Node.js v18 or higher
- A Discord bot token from the Discord Developer Portal
- Bun (or use
npxin place ofbunx)
git clone https://github.com/ahemtan/your-repo-name.git
cd your-repo-name
npm installCreate a .env file in the root of your project:
DISCORD_TOKEN=your-bot-token-herenpm run devnpm startThis project uses Biome for linting and formatting.
npm run lint
# or
npm run formatmodule.exports = {
name: "ping",
description: "Replies with Pong!",
async execute(interaction) {
await interaction.reply("Pong!");
},
};module.exports = {
name: "ready",
once: true,
execute(client) {
console.log(`✅ Logged in as ${client.user.tag}`);
},
};const fs = require("node:fs");
const path = require("node:path");
module.exports = (client) => {
const commandsPath = path.join(__dirname, "../commands");
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if (command.name) {
client.commands.set(command.name, command);
}
}
};discord.js— Main library for interacting with the Discord API.dotenv— Load environment variables from.env.axios— For making API requests (if needed).
@biomejs/biome— Code formatter and linter.nodemon— Auto-restarts the bot in dev mode.
Made with ❤️ by ahemtan
Licensed under the ISC License
---
Let me know if you'd like:
- Slash command support added
- Docker setup instructions
- A full working `index.js` example
- Make sure to add .env before running
Happy coding! 🚀