A streamlined library for creating Discord bots with Discord.js, featuring a simple command and event handler structure.
npm install @ad1m/djbDJB is a powerful and intuitive library that simplifies Discord bot development using Discord.js. It offers a structured approach to managing events, commands, and client configurations, making bot development easier and more organized.
---
- Easy-to-use DJBClient class for streamlined bot initialization.
- Clean file structure for commands and events.
- Built-in support for MongoDB (optional).
- Advanced command and event handling with type safety.
- Fully compatible with the latest version of Discord.js.
---
Install DJB using npm:
``bash`
npm install @ad1m/djb
---
DJB follows a structured approach to organizing commands and events.
- Events are located in the app/events directory.config
- Each event file exports a object and an execute function.
Example Event File: app/events/client-ready.ts
`typescript
import { log } from "@ad1m/logger";
import { EventConfig, EventExecute } from "@ad1m/djb";
import { Events } from "discord.js";
export const config: EventConfig = {
name: Events.ClientReady,
once: true,
};
const ClientReady: EventExecute
log.success("client", Client is ready @${client.user?.tag});
};
export default ClientReady;
`
- Commands are located in the app/commands directory.config
- Each command file exports a object and a default execute function.app/commands/ping.ts
c
Example Command File:
`typescript
import { CommandConfig, CommandExecute } from "@ad1m/djb";
export const config: CommandConfig = {
description: "Pings the bot",
};
const Ping: CommandExecute = (client, message) => {
message.reply("Pong 🏓!");
};
export default Ping;
`
---
Here is an example of how to set up a bot using DJB:
Index File: index.ts
`typescript
import { GatewayIntentBits, Partials } from "discord.js";
import { DJBClient } from "@ad1m/djb";
const djbClient = new DJBClient(
{
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Channel],
},
{ mongoDb: true }
);
djbClient.start();
``
---
Contributions are welcome! Feel free to submit issues or pull requests to improve DJB.
---
This project is licensed under the MIT License.
---