djs-builder

๐ŸŽ‰ Package Update! ๐Ÿฅ

Example Image

Typing SVG

Welcome to the ultimate Discord Bot Utilities package! ๐Ÿฅ Boost your Discord bot development with ease, speed, and all-in-one features.


๐Ÿ“‘ Table of Contents

  1. ๐ŸŽฏ Starter โ€“ Initialize your bot with commands, events, presence, and more.
  2. โš™๏ธ Functions โ€“ Utilities like CreateRow, CreateBar, Wait, and GetUser.
  3. โšก Commands & Events โ€“ Easy setup with cooldowns, permissions, logging, and anti-crash.

๐ŸŽฏ STARTER

The starter function is the ultimate initializer for your Discord bot ๐Ÿค–. It handles everything from logging in, loading commands/events, setting the bot presence, anti-crash protection, logging commands usage, and even checking for library updates.

Features:

  • ๐Ÿ› ๏ธ One-line loader for both Slash & Prefix commands ๐Ÿ”ฉ
  • ๐Ÿ“œ Comprehensive terminal info display (commands, events, bot stats) ๐Ÿ“Š
  • ๐Ÿงฐ Event handler loader in one line ๐ŸŽ‰
  • โš ๏ธ Anti-crash system with automatic webhook reporting ๐Ÿ“ƒ
  • ๐Ÿ”‹ MongoDB connection support ๐Ÿ“ฅ
  • ๐Ÿ“‘ Command logger for both Slash and Prefix commands ๐Ÿงญ
  • ๐Ÿ’ก Supports custom prefixes per guild and cooldowns โณ
  • ๐Ÿ”ผ Automatic update checker for djs-builder ๐Ÿ“ฆ

๐Ÿ’ก Tip: Any option you donโ€™t want, just remove it ๐Ÿ—‘๏ธ.


Starter Usage โš™๏ธ
const { starter } = require("djs-builder");
const { Client, GatewayIntentBits } = require("discord.js");

const client = new Client({
  intents: Object.keys(GatewayIntentBits).map((a) => GatewayIntentBits[a]),
});

// Define starter options
const starterOptions = {
  bot: {
    token: "YOUR_BOT_TOKEN", // ๐Ÿ”‘ Discord bot token
    ownerId: "YOUR_USER_ID", // ๐Ÿ‘ค Bot owner ID
  },
  terminal: true, // ๐Ÿ–ฅ๏ธ Show bot info in terminal

  Status: {
    status: "online", // Required: Bot presence state ['online', 'dnd', 'idle', 'offline', 'streaming']
    activities: ["Game 1", "Game 2"], // ๐ŸŽฎ List of activities
    type: 0, // Optional: Activity type (0 = PLAYING, 1 = STREAMING, 2 = LISTENING, 3 = WATCHING)
    time: 60000, // โฑ๏ธ Activity rotation delay in ms
    url: "https://twitch.tv/example", // Optional: Required only for STREAMING type
  },

  database: {
    url: "mongodb://localhost:27017", // ๐Ÿ’พ MongoDB URI for direct connection
  },

  slash: {
    path: "./path/to/slash_commands", // ๐Ÿ“ Path to slash commands
    log: "LOG_CHANNEL_ID", // ๐Ÿ“ Optional: log channel ID for slash commands
  },

  prefix: {
    path: "./path/to/prefixes", // ๐Ÿ“ Path to prefix commands
    prefix: "!", // Default prefix
    log: "LOG_CHANNEL_ID", // Optional: log channel ID for prefix commands
    custom_prefix: {
      // โš™๏ธ Guild-specific prefixes
      GUILD_ID_1: "?",
      GUILD_ID_2: "$",
    },
  },

  events: {
    path: "./path/to/events", // ๐Ÿ“ Path to event handlers
  },

  anticrash: {
    url: "https://your.crash.webhook.url", // ๐Ÿšจ Webhook for crash alerts
    mention_id: "YOUR_USER_ID", // Optional: Mention this user on crash
  },
};

// Start the bot
await starter(client, starterOptions);

๐Ÿ“Œ How Starter Works

1๏ธโƒฃ Bot Login & Presence

  • Logs the bot in using the token ๐Ÿ”‘.
  • Sets the presence (status + activities) with automatic rotation โฑ๏ธ.
  • Supports multiple activity types (PLAYING, STREAMING, LISTENING, WATCHING) ๐ŸŽฎ.
  • Supports Twitch streaming URL if type = 1 ๐ŸŒ.

5๏ธโƒฃ Anticrash System โš ๏ธ

  • Monitors:

    • unhandledRejection
    • uncaughtException
    • uncaughtExceptionMonitor
    • unhandledRejectionMonitor
    • warning
  • Sends errors to a webhook with optional user mention ๐Ÿ“ฃ.

  • Prevents bot from crashing unexpectedly.

6๏ธโƒฃ Terminal Info ๐Ÿ–ฅ๏ธ

  • Displays colorful bot info:

    • Bot name, users, guilds, channels
    • Number of prefix/slash commands
    • Number of events loaded
    • Owner & database connection status
    • Started time
  • Uses cli-table3 + chalk for readable output.

7๏ธโƒฃ Automatic Update Checker ๐Ÿ”ผ

  • Checks for new versions of djs-builder every hour.
  • Sends notification to the webhook if a new version is available ๐ŸŽ‰.

๐Ÿ’ก Notes & Tips

  • Remove any unwanted option: If you donโ€™t need a feature (like anticrash or database), just delete that key ๐Ÿ—‘๏ธ.
  • Custom Prefix: Each server can have its own prefix via custom_prefix.
  • Fast Use Commands: Allows commands to run without a prefix if fastUse = true.
  • Slash & Prefix Logging: Works for both types of commands.


โš™๏ธ function

  • Easyest โœจ / Fastest โšก /Clear ๐Ÿงต

Than the discord.js


CreateRow ๐Ÿ”ต

๐Ÿ”ต CreateRow โ€“ Easily create Discord Action Rows with Buttons & Select Menus โœจ

CreateRow is a powerful utility to build Discord Action Rows. It supports:

  • Buttons โœ…
  • Select Menus ๐ŸŽฏ (string, role, user, channel)
  • Advanced options like defaultValues and channelTypes.

๐Ÿ“Œ Example Usage:

const { CreateRow } = require("djs-builder");

const actionRow = new CreateRow([
  //// For each new row, use [] for buttons or {} for a select menu

  // ๐Ÿ”น Row #1: Buttons
  [
    {
      id: "button1", // customId for the button
      style: 1, // Button styles: Primary(1), Secondary(2), Success(3), Danger(4), Link(5)
      label: "Primary Button", // Text shown on button
      emoji: "๐Ÿ˜ƒ", // Emoji displayed
      disabled: false, // true = disabled
    },
    {
      id: "button2",
      style: 2,
      emoji: "๐Ÿš€",
      disabled: true, // Button is disabled
    },
  ],

  // ๐Ÿ”น Row #2: Select Menu
  {
    type: "string", // Options: "string" | "role" | "user" | "channel"
    options: {
      id: "menu1", // customId for the select menu
      placeholder: "Select an option",
      min: 1, // Minimum selection
      max: 2, // Maximum selection

      // ๐Ÿ”ธ Data for string select only
      data: [
        {
          name: "Option 1",
          id: "opt1",
          about: "First option",
          icon: "๐ŸŒŸ",
          default: true,
        },
        { name: "Option 2", id: "opt2", about: "Second option", icon: "๐Ÿš€" },
        { name: "Option 3", id: "opt3", about: "Third option", icon: "๐Ÿ”—" },
      ],

      // ๐Ÿ”ธ Map keys
      label: "name", // Which field is the label
      value: "id", // Which field is the value
      description: "about", // Description for each option
      emoji: "icon", // Emoji for each option

      // ๐Ÿ”ธ Extra options
      disabled: false, // Disable the entire menu
      defaultValues: [
        // For role/user/channel menus
        { id: "123456789012345678", type: "user" }, // Pre-selected
      ],
      channelTypes: [0, 2], // Only for ChannelSelectMenu (0 = Text, 2 = Voice)
    },
  },
]);

๐Ÿ“– Explanation

๐Ÿ”น Buttons

  • id โ†’ customId for the button
  • style โ†’ 1: Primary, 2: Secondary, 3: Success, 4: Danger, 5: Link
  • label โ†’ Button text
  • emoji โ†’ Displayed emoji
  • disabled โ†’ true = button is unclickable

๐Ÿ”น Select Menus

  • type โ†’ "string" | "user" | "role" | "channel"

  • id โ†’ customId for menu

  • placeholder โ†’ Text shown before selection

  • min / max โ†’ Min/Max selectable values

  • data โ†’ Options array (for string select only)

    • label โ†’ Visible text
    • value โ†’ Internal value
    • description โ†’ Short description
    • emoji โ†’ Option emoji
    • default โ†’ Pre-selected option
  • disabled โ†’ Disable menu completely

  • defaultValues โ†’ Pre-selected user/role/channel options

  • channelTypes โ†’ Restrict selectable channel types


CreateBar ๐Ÿงพ

๐Ÿงพ CreateBar โ€“ Text-based Progress Bar for Discord โœจ

CreateBar allows you to display a customizable progress bar with optional percentages and partial symbols. Perfect for showing progress, loading, or stats in messages.


๐Ÿ“Œ Basic Example:

const { CreateBar } = require("djs-builder");

const bar = new CreateBar(7, 10, {
  length: 20, // Total length of the bar
  fill: "๐Ÿ’š", // Filled portion
  empty: "๐Ÿ–ค", // Empty portion
  partialChar: "๐Ÿ’›", // Partial fill
  showPercent: true, // Show percentage
  left: "โฐ", // Left bracket
  right: "โฑ", // Right bracket
});

console.log(bar);
// Output: โฐ๐Ÿ’š๐Ÿ’š๐Ÿ’š๐Ÿ’š๐Ÿ’š๐Ÿ’š๐Ÿ’š๐Ÿ’›๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–ค๐Ÿ–คโฑ 70%

๐Ÿ“Œ Another Example with different symbols:

console.log(
  CreateBar(3.7, 5, {
    fill: "๐ŸŸฆ",
    empty: "โฌ›",
    partialChar: "๐ŸŸจ",
    length: 10,
    left: "โฐ",
    right: "โฑ",
    showPercent: true,
  })
);

// Output: โฐ๐ŸŸฆ๐ŸŸฆ๐ŸŸฆ๐ŸŸจโฌ›โฌ›โฌ›โฌ›โฌ›โฌ›โฑ 74%

๐Ÿ“Œ Minimalist example without percentage:

console.log(
  CreateBar(4, 8, {
    fill: "๐Ÿ”ต",
    empty: "โšช",
    showPercent: false,
  })
);

// Output: ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšชโšชโšชโšช

๐Ÿ“Œ Fun Emoji example:

console.log(
  CreateBar(6, 10, {
    length: 12,
    fill: "๐Ÿ”ฅ",
    empty: "โ„๏ธ",
    partialChar: "๐ŸŒŸ",
    showPercent: true,
    left: "ยซ",
    right: "ยป",
  })
);

// Output: ยซ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐ŸŒŸโ„๏ธโ„๏ธโ„๏ธโ„๏ธยป 60%

๐Ÿ”น Options Summary

  • length โ†’ Total number of symbols
  • fill โ†’ Symbol for filled portion
  • empty โ†’ Symbol for empty portion
  • partialChar โ†’ Symbol for partial fill (e.g., half-filled)
  • showPercent โ†’ Show percentage at the end
  • left / right โ†’ Brackets or edges for the bar

๐Ÿ”น Notes

  • Supports fractional values for partial fill
  • Fully customizable with any emoji or character ๐ŸŽจ
  • Great for progress, stats, experience bars, or loading indicators


Wait โฐ

โฐ Wait โ€“ Await messages, buttons, select menus or modals easily โœจ

Wait is a replacement for traditional collectors. It supports:

  • Awaiting messages ๐Ÿ“
  • Awaiting interactions (buttons / select menus) ๐ŸŽ›๏ธ
  • Awaiting modal submissions ๐Ÿ“‹
  • Filtering by user and timeout

๐Ÿ“Œ Example Usage:

const { Wait } = require("djs-builder");

const response = await Wait({
  context: message, // Message or Interaction object
  userId: message.author.id, // Optional: filter by user
  type: "both", // "message" | "interaction" | "both"
  time: 30000, // Time in ms
  message_Wait: message, // Required if waiting for buttons/selects
});

if (!response) return console.log("โฑ๏ธ Timeout!");
console.log("โœ… Collected:", response);

๐Ÿ”น Options

  • context โ†’ The message or interaction context
  • userId โ†’ Only collect from this user (optional)
  • type โ†’ "message" | "interaction" | "both"
  • time โ†’ Timeout in milliseconds
  • message_Wait โ†’ Message containing buttons/select menus (for interaction/both type)

๐Ÿ”น Notes

  • Supports automatic cleanup of collectors after completion
  • Can return Message, Interaction, or ModalSubmitInteraction

GetUser ๐Ÿ‘ค

๐Ÿ‘ค GetUser โ€“ Fetch a GuildMember easily from a message โœจ

GetUser helps to detect a target member in multiple ways:

  1. Mention (@User)
  2. User ID (123456789012345678)
  3. Reply to another message

๐Ÿ“Œ Example Usage:

const { GetUser } = require("djs-builder");

const data = await GetUser(message);

if (!data) return message.reply("โŒ Could not find the user.");

const member = data.user; // GuildMember object
const args = data.args; // Remaining arguments
const reason = args.join(" ") || "No reason provided";

await member.ban({ reason });
message.reply(`๐Ÿšซ ${member.user.tag} was banned for: ${reason}`);

๐Ÿ”น Returns

{
  user: <GuildMember>,  // Targeted member
  args: [ "arg1", "arg2" ] // Remaining message arguments
}

๐Ÿ”น Detection Methods

  • Mention: !ban @Ahmed Spamming
  • User ID: !ban 123456789012345678 Spamming
  • Reply: Reply to user's message with !ban

๐Ÿ”น Notes

  • Automatically handles missing users
  • Returns null if user not found
  • Works in any text channel of the guild

Logging System ๐Ÿ›ก๏ธ

The Logging System is a powerful feature that keeps track of almost everything happening inside your Discord server ๐Ÿ”.
From messages ๐Ÿ“ to channels ๐Ÿ“‚, roles ๐ŸŽญ, invites ๐Ÿ”—, and even voice state changes ๐ŸŽ™๏ธ โ€“ nothing goes unnoticed!


โœจ Features

  • ๐Ÿ“ Messages โ€“ Deleted & edited messages are logged with details.
  • ๐Ÿ“‚ Channels โ€“ Creation, deletion, and updates are tracked.
  • ๐ŸŽญ Roles โ€“ Created, deleted, and updated roles, including member role changes.
  • ๐ŸŽ™๏ธ Voice State โ€“ Joins, leaves, and moves between channels.
  • ๐Ÿ”— Invites โ€“ Created invites & usage tracking.
  • ๐Ÿ˜€ Emojis & Stickers โ€“ Added, removed, or updated.
  • ๐Ÿšจ Audit Log Integration โ€“ Fetches the executor (who did what).
  • ๐ŸŽจ Beautiful Embeds โ€“ Every log is shown in a clean, styled embed with timestamps.

โš™๏ธ Setup Example

Using the log function is very simple โšก.
Just place this code inside an event (like clientReady) to start logging:

const { log } = require("djs-builder");

module.exports = {
  name: "clientReady",
  async run(client) {
    await log(
      client,
      "GUILD_ID", // ๐Ÿ  Guild ID (server)
      "CHANNEL_ID" // ๐Ÿ“ข Channel ID for logs
    );
  },
};

๐Ÿ’ก How It Works

  • โœ… Pass your Client, Guild ID, and Log Channel ID.
  • ๐Ÿ”” Instantly starts tracking events and sending them to the log channel.
  • ๐Ÿงฐ No extra setup required โ€“ plug and play!

โšก Commands & Events


๐Ÿ’ก Commands & Events made easy! With djs-builder, handling commands and events is smooth, fast, and fully customizable. You get built-in features like:

  • โš ๏ธ Anti-crash protection โ€“ your bot wonโ€™t crash unexpectedly.
  • โณ Cooldowns โ€“ prevent spam and control usage.
  • ๐Ÿ›ก๏ธ Permissions & owner/dev only checks โ€“ secure your commands.
  • โšก Fast Use & custom prefixes โ€“ run commands easily across guilds.
  • ๐Ÿ“ Logging โ€“ track every command usage for prefix or slash.

Below are all the available properties you can use for your commands and events:

โšก Commands & Events Options

โšก COMMAND OPTIONS (Prefix & Slash)


name: 'string',                // ๐Ÿท๏ธ Command name (required)
aliases: ['string'],           // ๐Ÿ” Alternative names (Prefix only)
description: 'string',         // โœ๏ธ Short description of the command
cooldown: 5,                   // โณ Cooldown in seconds before reusing the command
Permissions: ['ADMINISTRATOR'],// ๐Ÿ›ก๏ธ Required permissions to execute the command
ownerOnly: true,               // ๐Ÿ‘‘ Only server owner can use this command
devOnly: true,                 // ๐Ÿ› ๏ธ Only bot developer can use this command
guildOnly: true,               // ๐Ÿ  Command works only in servers
dmOnly: true,                  // โœ‰๏ธ Command works only in DMs
fastUse: true,                 // โšก Allow command to be executed without prefix (Prefix only)
run: Function,                 // ๐Ÿƒโ€โ™‚๏ธ Main function to run the command
execute: Function,             // ๐Ÿƒโ€โ™‚๏ธ Alternative function to run the command

โšก EVENT OPTIONS


name: 'string',                // ๐Ÿท๏ธ Event name (e.g., messageCreate, guildMemberAdd)
once: true,                    // ๐ŸŽฏ If true, the event will be executed only once
run: Function,                 // ๐Ÿƒโ€โ™‚๏ธ Function to run when the event triggers
execute: Function              // ๐Ÿƒโ€โ™‚๏ธ Alternative function to run the event

๐Ÿ’ก Tip: Use these properties to fully control command behavior, access, and event handling.


๐Ÿ’Œ Support

We welcome contributions! If you have any suggestions, bug reports, or feature requests, feel free to reach out to us on Discord.

๐Ÿ’ฌ Contact Me: <@679036538511687711>

๐ŸŒ Join our Discord:

Discord Banner