buncord is a Discord bot template built using Discord.js and Bun as the runtime. It provides a simple foundation for creating Discord bots with Bun for fast performance and modern JavaScript/TypeScript features.
- Built with Discord.js for interacting with the Discord API.
- Uses Bun as the runtime for fast performance.
- Modern TypeScript support.
- Easy-to-use structure for extending bot functionality.
Before you start, ensure you have the following installed:
- Bun: Bun is a modern JavaScript runtime like Node, but faster. You can install it from the official Bun website.
- Git: Git is required to clone the repository.
- Discord Bot Token: You’ll need to create a bot on Discord Developer Portal and obtain a token.
-
Clone the repository:
git clone https://github.com/f4id/bunCord.git cd bunCord
-
Install dependencies: Since we are using Bun as the runtime, you can install the dependencies with:
bun install
-
Configure environment variables: Create a
.env
file in the root of the project and add your Discord bot token:DISCORD_TOKEN=your_discord_bot_token
Once the dependencies are installed and the .env
file is set up, you can start the bot using Bun's built-in command:
bun start
This will execute the src/index.ts
file and launch your bot.
For local development, you can use Bun’s fast refresh to automatically reload the bot when files are modified. Simply run:
bun dev
This will start your bot with automatic file watching and reloading on changes.
Here is the basic directory structure:
/bunCord
│
├── /src # Source code for the bot
│ ├── index.ts # Main entry point for the bot
│ ├── /commands # Command files for the bot
│ └── /handlers # Event handlers, components, etc.
│
├── /node_modules # Dependencies installed via Bun
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
└── .env # Environment variables (including bot token)
-
Environment Variables: Make sure to define
DISCORD_TOKEN
in your.env
file. The bot uses this token to authenticate with the Discord API. -
Command Registration: The bot uses a command manager to register and cache commands. The bot will automatically cache and publish commands during startup.
-
Event Handling: Event listeners are set up in the
EventListenerManager
to handle events like message creation, interactions, etc. You can extend these to fit your bot’s functionality.
To add a new command:
- Create a new file inside the
/src/commands
folder. - Extend the
Command
class, implement the required methods (build
,execute
, etc.), and define the command data (name, description). - The command will be cached and published automatically upon bot startup.
If you want to contribute to the project, feel free to fork the repository and submit a pull request. Please follow the established coding standards and include tests if applicable.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by f4id