djs-builder
v0.7.9
Published
๐ Full-featured Discord.js utilities: CreateComponents, CreateModal, Dashboard, Logging & more! ๐ฅ
Readme

Welcome to the ultimate Discord Bot Utilities package! ๐ฅ Boost your Discord bot development with ease, speed, and all-in-one features.
๐ Table of Contents
- ๐ฏ Starter โ Initialize your bot with commands, events, presence, and more.
- โ๏ธ Functions โ Utilities like CreateRow, CreateBar, Wait, and GetUser.
- โก Commands & Events โ Easy setup with cooldowns, permissions, logging, and anti-crash.
- ๐ Dashboard โ Web-based control panel for managing your bot.
๐ฏ 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 ๐๏ธ.
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", // โ
Presence state: online, dnd, idle, offline
activities: ["Game 1", "Game 2"], // ๐ฎ Multiple activities
type: 0, // ๐ญ Activity type: (0=PLAYING, 1=STREAMING, 2=LISTENING, 3=WATCHING)
time: 60000, // โฑ๏ธ Rotate activities every X ms
url: "https://twitch.tv/example", // ๐ Twitch URL (only required for streaming)
},
database: {
url: "mongodb://localhost:27017", // ๐พ MongoDB connection
dbName: "yourDatabaseName", // ๐ Optional: Specify database name (default: "test")
},
anticrash: {
url: "https://your.crash.webhook.url", // ๐จ Webhook for crash reports
mention_id: "YOUR_USER_ID", // ๐ฃ Optional: mention user on crash
},
// ๐ Dashboard Configuration (Full docs at the end of this page)
dashboard: {
clientSecret: "YOUR_DISCORD_CLIENT_SECRET", // ๐ Discord Application Client Secret
callbackURL: "http://localhost:3000/auth/discord/callback", // ๐ OAuth2 Callback URL (OPTINAL)
sessionSecret: "your-super-secret-key", // ๐ Session encryption secret
port: 3000, // ๐ Dashboard port (OPTINAL / default: 3000)
},
};
// Start the bot
await starter(client, starterOptions);๐ How Starter Works
1๏ธโฃ Bot Login & Status
- Authenticates the bot using your token ๐.
- Supports multiple rotating activities (e.g.,
Game 1โGame 2โ โฆ) โฑ๏ธ. - Works with all Discord activity types: PLAYING, STREAMING, LISTENING, WATCHING ๐ญ.
- Twitch URL is supported for streaming mode ๐.
2๏ธโฃ Database Connection
- Connects automatically to MongoDB ๐พ.
- Useful for bots with persistent data storage.
- Specify the database name using the
dbNameoption. If not specified, MongoDB uses "test" as the default database name.
3๏ธโฃ Anticrash System
Catches and logs:
unhandledRejectionuncaughtExceptionuncaughtExceptionMonitorunhandledRejectionMonitorwarningโ ๏ธ
Sends error reports to a webhook ๐จ.
Optionally pings the owner ๐ฃ.
4๏ธโฃ Terminal Info
Displays colorful and structured information ๐ฅ๏ธ:
- Bot name, user, guild, and channel counts ๐.
- Owner ID ๐ค.
- Database connection status ๐พ.
- Uptime โณ.
Powered by
cli-table3+chalkfor a professional CLI look ๐จ.
5๏ธโฃ Auto Update Checker
- Monitors new versions of
djs-builderautomatically ๐. - Sends update notifications to the webhook ๐.
6๏ธโฃ Bot Files Information
Access detailed stats about loaded files directly from the client:
- Number of prefix commands โก.
- Number of slash commands โ๏ธ.
- Number of events ๐.
Available via
client.files, useful for debugging or terminal display ๐ ๏ธ.
7๏ธโฃ Dashboard (Web Control Panel)
- Launches a modern web-based control panel for your bot ๐.
- Supports Discord OAuth2 authentication ๐.
- Manage servers, levels, giveaways, and blacklists from the browser ๐๏ธ.
๐ Full Dashboard documentation available at the end of this page โ ๐ DASHBOARD
๐ก Tips
- Flexible: Delete any section you donโt need (anticrash, database, etc.) ๐๏ธ.
- Multi-Status: Add as many activities as you want and let them rotate ๐ฎ.
- Safe by Default: Anticrash system ensures your bot wonโt go down easily ๐ก๏ธ.
- Always Up-to-Date: Automatic update checker keeps your bot running on the latest version โฌ๏ธ.
- Transparent: Quickly check how many files your bot has loaded anytime ๐.
โ๏ธ functions
- Easiest โจ / Fastest โก /Clear ๐งต
Than the discord.js
๐ต 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
defaultValuesandchannelTypes.
๐ 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
},
{
style: 5,
label: "link",
emoji: "๐"
url : "https://discord.gg/z9GpYsYF" // for url button
}
],
// ๐น 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" }, // Pre-selected
],
channelTypes: [0, 2], // Only for ChannelSelectMenu (0 = Text, 2 = Voice)
},
},
]);๐ Explanation
๐น Buttons
idโ customId for the buttonstyleโ 1: Primary, 2: Secondary, 3: Success, 4: Danger, 5: Linklabelโ Button textemojiโ Displayed emojidisabledโ true = button is unclickableurlโ requiier for like button (style : 5)
๐น Select Menus
typeโ"string" | "user" | "role" | "channel"idโ customId for menuplaceholderโ Text shown before selectionmin/maxโ Min/Max selectable valuesdataโ Options array (for string select only)labelโ Visible textvalueโ Internal valuedescriptionโ Short descriptionemojiโ Option emojidefaultโ Pre-selected option
disabledโ Disable menu completelydefaultValuesโ Pre-selected user/role/channel optionschannelTypesโ Restrict selectable channel types
๐งพ 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 symbolsfillโ Symbol for filled portionemptyโ Symbol for empty portionpartialCharโ Symbol for partial fill (e.g., half-filled)showPercentโ Show percentage at the endleft/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
๐ณ CreateModal โ Easily create Discord Modals with Text Inputs, Menus, Files, and Labels โจ
CreateModal is a powerful utility to build Discord Modals. It supports:
- Text Inputs ๐
- Select Menus ๐ฏ (
string,role,user,channel) - File Uploads ๐
- Text Displays ๐ท๏ธ
๐ Example Usage:
const { CreateModal } = require("djs-builder");
const modal = CreateModal({
id: "myModal",
title: "User Information",
components: [
{
type: "textInput",
components: [
{
label: "Your Name",
id: "name",
style: 1, // 1: Short, 2: Paragraph
placeholder: "Enter your name",
required: true,
minLength: 2,
maxLength: 50,
},
],
},
{
type: "menu",
components: {
type: "string",
options: {
id: "favoriteColor",
placeholder: "Choose your favorite color",
min: 1,
max: 1,
data: [
{
label: "Red",
value: "red",
description: "A bold color",
emoji: "๐ด",
default: false,
},
{
label: "Blue",
value: "blue",
description: "A calm color",
emoji: "๐ต",
},
],
label: "label",
value: "value",
description: "description",
emoji: "emoji",
disabled: false,
},
},
},
{
type: "file",
components: {
id: "avatar",
label: "Upload Avatar",
description: "Optional avatar image",
},
},
{
type: "label",
components: {
label: "Thank you for your input!",
},
},
],
});
// Show the modal
await interaction.showModal(modal);๐ Examples for Each Component Type:
๐น Text Input Example:
{
type: "textInput",
components: [
{
label: "Your Age",
id: "age",
style: 1, // Short input
placeholder: "Enter your age",
required: true,
minLength: 1,
maxLength: 3,
value: "18", // Pre-filled
},
],
},๐น Menu Example:
{
type: "menu",
components: {
type: "string",
options: {
id: "country",
placeholder: "Select your country",
min: 1,
max: 1,
data: [
{
name: "USA",
id: "usa",
desc: "United States",
icon: "๐บ๐ธ",
default: true, // This option is pre-selected
},
{
name: "Canada",
id: "canada",
desc: "Canada",
icon: "๐จ๐ฆ",
},
],
label: "name", // Maps to 'name' field in data
value: "id", // Maps to 'id' field in data
description: "desc", // Maps to 'desc' field
emoji: "icon", // Maps to 'icon' field
disabled: false,
},
},
},๐น File Example:
{
type: "file",
components: {
id: "document",
label: "Upload Document",
description: "Upload a PDF or image",
},
},๐น Label Example:
{
type: "label",
components: {
label: "Please fill out the form above.",
},
},๏ฟฝ๐ Explanation
๐น Text Input
labelโ Label for the input fieldidโ customId for the inputstyleโ 1: Short, 2: Paragraphplaceholderโ Placeholder textrequiredโ true/falseminLength/maxLengthโ Min/Max charactersvalueโ Pre-filled value
๐น Menu
Same as CreateRow select menus.
typeโ"string" | "user" | "role" | "channel"idโ customId for menuplaceholderโ Text shown before selectionmin/maxโ Min/Max selectable valuesdataโ Options array (for string select only)labelโ Visible text (maps to the field specified inlabelkey)valueโ Internal value (maps to the field specified invaluekey)descriptionโ Short description (maps to the field specified indescriptionkey)emojiโ Option emoji (maps to the field specified inemojikey)defaultโ Pre-selected option (true/false in data array)
labelโ Key in data to use as label (e.g., "name")valueโ Key in data to use as value (e.g., "id")descriptionโ Key in data to use as description (e.g., "desc")emojiโ Key in data to use as emoji (e.g., "icon")disabledโ Disable menu completelydefaultValuesโ Pre-selected user/role/channel options (for non-string menus)channelTypesโ Restrict selectable channel types (for channel menu)
๐น File
idโ customId for the file uploadlabelโ Labeldescriptionโ Description
๐น Label
labelโ Text to display
๐น Notes
- Supports multiple components in one modal
- Fully customizable with Discord.js ModalBuilder
๐งฉ CreateComponents โ Build Advanced Discord UI Components with Containers, Sections & Media โจ
CreateComponents is a powerful utility to build Discord's new UI components. It supports:
- Text Displays ๐
- Separators โ
- Media Galleries ๐ผ๏ธ
- File Attachments ๐
- Buttons ๐
- Select Menus ๐ฏ (
string,role,user,channel) - Sections with Accessories ๐ฆ (Thumbnails & Buttons)
- Containers ๐ฆ (Group all components together)
๐ Example Usage (Array Mode):
const { CreateComponents } = require("djs-builder");
const components = await CreateComponents("array", [
{
type: "text",
content: "Welcome to our server! ๐",
},
{
type: "separator",
divider: true,
spacing: 1, // 1: Small, 2: Large
},
{
type: "media",
links: [
"https://example.com/image1.png",
{
url: "https://example.com/image2.png",
description: "A cool image",
spoiler: true,
},
],
},
{
type: "button",
components: [
{
id: "btn_1",
style: 1, // 1: Primary, 2: Secondary, 3: Success, 4: Danger, 5: Link
label: "Click Me!",
emoji: "๐",
},
{
id: "btn_2",
style: 3,
label: "Confirm",
},
],
},
]);
// Send the components
await channel.send({ components });๐ Example Usage (Container Mode):
const { CreateComponents } = require("djs-builder");
const components = await CreateComponents("container", [
{
type: "text",
content: "# ๐ข Server Announcement\nWelcome everyone!",
},
{
type: "separator",
divider: true,
},
{
type: "section",
content: "Check out our latest updates and news!",
accessory: {
type: "thumbnail",
url: "https://example.com/thumbnail.png",
description: "News Image",
},
},
{
type: "section",
content: "**Click below to get your roles!**",
accessory: {
type: "button",
id: "get_roles",
style: 1,
label: "Get Roles",
emoji: "๐ญ",
},
},
{
type: "media",
links: ["https://example.com/banner.png"],
},
{
type: "button",
components: [
{ id: "rules", style: 2, label: "๐ Rules", emoji: "๐" },
{ id: "help", style: 2, label: "โ Help", emoji: "โ" },
{ style: 5, label: "๐ Website", url: "https://example.com" },
],
},
]);
// Send with container
await channel.send({ components, flags: 32768 }); // flags for components v2๐ Examples for Each Component Type:
๐ Simple Text:
{
type: "text",
content: "Hello World! ๐",
}๐ Text with Markdown:
{
type: "text",
content: "# ๐ข Announcement\n**Important:** Server maintenance tonight!",
}๐ Text with Multiple Lines:
{
type: "text",
content: `## ๐ฎ Game Stats
**Player:** Ahmed
**Level:** 50
**XP:** 12,500 / 15,000
**Rank:** Diamond ๐`,
}๐ Text with Emojis & Formatting:
{
type: "text",
content: ">>> ๐ก **Tip:** Use `/help` to see all commands!\n\n*This message will auto-delete in 30 seconds*",
}โ Separator โ Add spacing and dividers between components
The separator component allows you to add visual breaks between other components with customizable spacing and divider lines.
๐ Separator Options
| Option | Type | Default | Description |
| --------- | --------- | ------- | -------------------------------------------------- |
| type | string | โ | Must be "separator" |
| divider | boolean | false | Show a horizontal dividing line |
| spacing | number | 1 | Spacing size: 1 (Small) or 2 (Large) |
๐ Simple Divider Line:
{
type: "separator",
divider: true,
}Result: A thin horizontal line appears between components.
๐ Separator without Line (Spacing Only):
{
type: "separator",
divider: false,
spacing: 2, // Large spacing
}Result: Empty space without any visible line - useful for visual grouping.
๐ Small Spacing with Divider:
{
type: "separator",
divider: true,
spacing: 1, // Small spacing (default)
}Result: A divider line with minimal padding above and below.
๐ Large Spacing with Divider:
{
type: "separator",
divider: true,
spacing: 2, // Large spacing
}Result: A divider line with more padding - creates stronger visual separation.
๐ก When to Use Each Option:
| Scenario | divider | spacing |
| ------------------------------------- | --------- | --------- |
| Separate major sections | true | 2 |
| Separate sub-sections | true | 1 |
| Group related items visually | false | 1 |
| Create breathing room between content | false | 2 |
| Minimal separation | false | 1 |
๐ผ๏ธ Media Gallery โ Display images in a beautiful gallery format
The media component creates an image gallery that can display one or multiple images. Each image can be a simple URL string or a detailed object with additional options.
๐ Format 1: Simple String URLs
The simplest way - just pass image URLs as strings:
{
type: "media",
links: ["https://example.com/image.png"],
}๐ Format 2: Object with Full Options
For more control, use objects with url, description, and spoiler:
{
type: "media",
links: [
{
url: "https://example.com/image.png",
description: "A beautiful sunset",
spoiler: false,
},
],
}๐ Single Image with Spoiler:
{
type: "media",
links: [
{
url: "https://example.com/spoiler.png",
description: "โ ๏ธ Spoiler Alert!",
spoiler: true,
},
],
}๐ Multiple Images (Simple Strings):
{
type: "media",
links: [
"https://example.com/image1.png",
"https://example.com/image2.png",
"https://example.com/image3.png",
"https://example.com/image4.png",
],
}Result: A 2x2 gallery grid of images.
๐ Mixed Format (Strings + Objects):
You can mix simple strings with detailed objects in the same array:
{
type: "media",
links: [
// Simple string - just the URL
"https://example.com/public-image.png",
// Object with description
{
url: "https://example.com/special-image.png",
description: "Limited Edition Art",
},
// Object with spoiler
{
url: "https://example.com/secret-image.png",
description: "Secret Content",
spoiler: true,
},
// Another simple string
"https://example.com/another-image.png",
],
}๐ Meme/Artwork Gallery with Spoilers:
{
type: "media",
links: [
{
url: "https://example.com/meme1.png",
description: "Funny meme #1",
spoiler: false,
},
{
url: "https://example.com/meme2.png",
description: "Funny meme #2",
spoiler: false,
},
{
url: "https://example.com/nsfw-meme.png",
description: "โ ๏ธ Slightly inappropriate",
spoiler: true, // Hidden behind blur
},
],
}๐ก Tips for Media Galleries:
| Images Count | Display Layout | | ------------ | ---------------------- | | 1 image | Full width single image | | 2 images | Side by side | | 3 images | 1 large + 2 small | | 4+ images | Grid layout |
- Use
descriptionfor accessibility and context - Use
spoiler: truefor sensitive/spoiler content - Mix formats freely - strings for quick images, objects for detailed ones
- Images are displayed in the order provided
๐ Simple File Attachment:
{
type: "file",
url: "attachment://document.pdf",
}๐ Full Example with File:
const { CreateComponents } = require("djs-builder");
const { AttachmentBuilder } = require("discord.js");
const file = new AttachmentBuilder("./myfile.txt", { name: "myfile.txt" });
const components = await CreateComponents("container", [
{
type: "text",
content: "๐ **Here is your requested file:**",
},
{
type: "file",
url: "attachment://myfile.txt",
},
]);
await channel.send({ components, files: [file], flags: 32768 });๐ Button with Emoji:
{
type: "button",
components: [
{
id: "like_btn",
style: 3, // Success (Green)
label: "Like",
emoji: "๐",
},
],
}๐ Multiple Buttons in Row:
{
type: "button",
components: [
{ id: "btn_yes", style: 3, label: "Yes", emoji: "โ
" },
{ id: "btn_no", style: 4, label: "No", emoji: "โ" },
{ id: "btn_maybe", style: 2, label: "Maybe", emoji: "๐ค" },
],
}๐ All Button Styles:
{
type: "button",
components: [
{ id: "primary", style: 1, label: "Primary", emoji: "๐ต" }, // Blue
{ id: "secondary", style: 2, label: "Secondary", emoji: "โช" }, // Gray
{ id: "success", style: 3, label: "Success", emoji: "๐ข" }, // Green
{ id: "danger", style: 4, label: "Danger", emoji: "๐ด" }, // Red
{ style: 5, label: "Link", emoji: "๐", url: "https://discord.com" }, // Link
],
}๐ String Select Menu (Basic):
{
type: "menu",
components: {
type: "string",
options: {
id: "color_select",
placeholder: "๐จ Choose a color",
data: [
{ name: "Red", id: "red", icon: "๐ด" },
{ name: "Blue", id: "blue", icon: "๐ต" },
{ name: "Green", id: "green", icon: "๐ข" },
],
label: "name",
value: "id",
emoji: "icon",
},
},
}๐ String Select with Description:
{
type: "menu",
components: {
type: "string",
options: {
id: "role_select",
placeholder: "๐ญ Select your role",
data: [
{ name: "Gamer", id: "gamer", desc: "For gaming enthusiasts", icon: "๐ฎ" },
{ name: "Artist", id: "artist", desc: "For creative people", icon: "๐จ" },
{ name: "Developer", id: "dev", desc: "For coders & programmers", icon: "๐ป" },
{ name: "Music Lover", id: "music", desc: "For music fans", icon: "๐ต" },
],
label: "name",
value: "id",
description: "desc",
emoji: "icon",
},
},
}๐ String Select with Min/Max:
{
type: "menu",
components: {
type: "string",
options: {
id: "games_select",
placeholder: "๐ฎ Select your favorite games (2-4)",
min: 2,
max: 4,
data: [
{ name: "Minecraft", id: "mc", icon: "โ๏ธ" },
{ name: "Fortnite", id: "fn", icon: "๐ซ" },
{ name: "Valorant", id: "val", icon: "๐ฏ" },
{ name: "League of Legends", id: "lol", icon: "โ๏ธ" },
{ name: "Rocket League", id: "rl", icon: "๐" },
],
label: "name",
value: "id",
emoji: "icon",
},
},
}๐ User Select (Multiple):
{
type: "menu",
components: {
type: "user",
options: {
id: "users_select",
placeholder: "๐ฅ Select users to invite (1-5)",
min: 1,
max: 5,
},
},
}๐ Role Select Menu:
{
type: "menu",
components: {
type: "role",
options: {
id: "role_select",
placeholder: "๐ญ Select a role",
min: 1,
max: 1,
},
},
}๐ Channel Select Menu:
{
type: "menu",
components: {
type: "channel",
options: {
id: "channel_select",
placeholder: "๐ข Select a channel",
min: 1,
max: 1,
},
},
}๐ Channel Select with Type Filter:
const { ChannelType } = require("discord.js");
{
type: "menu",
components: {
type: "channel",
options: {
id: "text_channel_select",
placeholder: "๐ฌ Select a text channel",
channelTypes: [ChannelType.GuildText, ChannelType.GuildAnnouncement],
},
},
}๐ Menu with Default Values (User/Role/Channel):
{
type: "menu",
components: {
type: "user",
options: {
id: "user_select_default",
placeholder: "๐ค Select users",
min: 1,
max: 3,
defaultValues: [
{ id: "123456789012345678", type: "user" },
{ id: "987654321098765432", type: "user" },
],
},
},
}๐ Section with Thumbnail (Product):
{
type: "section",
content: "๐ **iPhone 15 Pro**\n๐ฐ Price: $999\nโญ Rating: 4.8/5\n๐ฆ In Stock: Yes",
accessory: {
type: "thumbnail",
url: "https://example.com/iphone.png",
description: "iPhone 15 Pro Image",
},
}๐ Section with Button :
{
type: "section",
content: "๐ **Daily Reward**\nClick to claim your daily reward!\n๐ **+100 Coins**",
accessory: {
type: "button",
id: "claim_daily",
style: 3,
label: "Claim",
emoji: "๐",
},
}๐ Component Types Explanation
๐น Text
typeโ"text"contentโ The text content to display (supports Markdown)
๐น Separator
typeโ"separator"dividerโ Show a dividing line (true/false)spacingโ Spacing size (1: Small, 2: Large)
๐น Media Gallery
typeโ"media"linksโ Array of image URLs or objects with:urlโ Image URLdescriptionโ Alt text for the imagespoilerโ Hide behind spoiler (true/false)
๐น File
typeโ"file"urlโ File URL or attachment referencespoilerโ Hide behind spoiler (true/false)
๐น Button
typeโ"button"componentsโ Array of button objects:idโ customId (required for non-link buttons)styleโ 1: Primary, 2: Secondary, 3: Success, 4: Danger, 5: Linklabelโ Button textemojiโ Button emojidisabledโ Disable button (true/false)urlโ URL for link buttons (style: 5)
๐น Menu
typeโ"menu"componentsโ Object containing:typeโ"string" | "user" | "role" | "channel"optionsโ Menu configuration:idโ customIdplaceholderโ Placeholder textmin/maxโ Min/Max selectable valuesdataโ Options array (for string select)labelโ Key in data for labelvalueโ Key in data for valueemojiโ Key in data for emojidescriptionโ Key in data for descriptionchannelTypesโ Channel types filter (for channel menu)defaultValuesโ Pre-selected values
๐น Section
typeโ"section"contentโ Text content for the sectionaccessoryโ Side component:- Button Accessory:
typeโ"button"idโ customIdstyleโ Button stylelabelโ Button textemojiโ Button emojiurlโ URL (for link buttons)
- Thumbnail Accessory:
typeโ"thumbnail"urlโ Image URLdescriptionโ Image description
- Button Accessory:
๐น Mode Differences
| Feature | "array" Mode | "container" Mode |
| ---------------- | ----------------------- | ------------------------- |
| Return Type | Array of components | Single ContainerBuilder |
| Usage | Standard messages | Components V2 messages |
| Sections Support | โ
| โ
|
| Grouping | Individual components | All grouped in container |
| Flags Required | โ | โ
(flags: 32768) |
๐น Notes
- Use
"container"mode for Discord's Components V2 (newer UI) - Use
"array"mode for standard component arrays - Sections can have either a button or thumbnail as accessory, not both
- Media galleries support multiple images in a single component
- All components are fully customizable ๐จ
โฐ 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 contextuserIdโ Only collect from this user (optional)typeโ"message" | "interaction" | "both"timeโ Timeout in millisecondsmessage_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 โ Fetch a GuildMember easily from a message โจ
GetUser helps to detect a target member in multiple ways:
- Mention (
@User) - User ID (
123456789012345678) - 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
nullif user not found - Works in any text channel of the guild
๐ก๏ธ Logging System โ Track Everything in Your Server
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!
Note 1: Using
database: truerequires a MongoDB connection. | Note 2: You can import the Log model for direct database access ๐พ.
๐ฆ Module Exports
const { log, Log } = require("djs-builder");log(client, options)โ Start the logging system with your configuration ๐.Logโ The Mongoose model for direct database access and custom modifications ๐พ.
๐ Simple Example
const { log } = require("djs-builder");
module.exports = {
name: "clientReady",
async run(client) {
const logData = [
{
guildId: "999888777666555444",
channelId: "444555666777888999",
},
{
guildId: "999888777666555444",
channelId: "444555666777888999",
},
];
// Start logging with custom data
await log(client, {
Data: logData, // ๐ Your configurations
});
console.log("โ
Logging system started with custom data!");
},
};โจ 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.
- ๐ค Members โ Join, leave, kick, ban, and unban events.
- ๐จ Audit Log Integration โ Fetches the executor (who did what).
- ๐จ Beautiful Embeds โ Every log is shown in a clean, styled embed with timestamps.
- ๐๏ธ Caching System โ Fast performance with built-in data caching.
๐ Database Schema
The logging system uses the following data structure:
{
guildId: String, // ๐ Server ID (required)
channelId: String, // ๐ข Default log channel ID
channels: Object, // ๐ Custom channels per event type (optional)
colors: Object, // ๐จ Custom colors per event type (optional)
disable: Array, // ๐ซ Array of disabled event types (optional)
}๐ Supported Event Types
| Event Type | Description |
| ------------------- | ------------------------- |
| messageDelete | Message deleted ๐ |
| messageUpdate | Message edited โ๏ธ |
| channelCreate | Channel created ๐ |
| channelDelete | Channel deleted ๐๏ธ |
| channelUpdate | Channel updated โ๏ธ |
| guildMemberAdd | Member joined ๐ |
| guildMemberRemove | Member left/kicked ๐ช |
| guildBanAdd | Member banned ๐จ |
| guildBanRemove | Member unbanned ๐ค |
| roleCreate | Role created ๐
|
| roleDelete | Role deleted โ |
| roleUpdate | Role updated ๐ |
| guildMemberUpdate | Member roles changed ๐ค |
| voiceStateUpdate | Voice channel activity ๐ค |
| inviteCreate | Invite created ๐ |
| emojiCreate | Emoji added ๐ |
| emojiDelete | Emoji removed ๐ซ |
| emojiUpdate | Emoji updated ๐ |
| stickerCreate | Sticker added โจ |
| stickerDelete | Sticker removed ๐๏ธ |
| stickerUpdate | Sticker updated ๐ |
๐๏ธ Using MongoDB Database
This method stores log configuration in MongoDB, allowing dynamic management via commands.
โก Setup in clientReady Event:
const { log } = require("djs-builder");
module.exports = {
name: "clientReady",
async run(client) {
// Start logging with database mode
await log(client, {
database: true, // ๐๏ธ Uses MongoDB to store/fetch config
});
console.log("โ
Logging system started with database mode!");
},
};๐ก How It Works
- โ The system automatically fetches log configuration for each guild from MongoDB.
- ๐ ๏ธ You can manage settings via slash commands (see management command below).
- ๐จ Supports per-guild customization for channels, colors, and disabled events.
- ๐ Important: If you use database mode, see the Log Management Command below to edit data.
๐ Using Custom Data Array
This method uses a predefined array of configurations โ perfect for simple setups or testing.
โก Setup in clientReady Event:
const { log } = require("djs-builder");
module.exports = {
name: "clientReady",
async run(client) {
// Define your log configurations
const logData = [
{
guildId: "123456789012345678", // ๐ Server ID
channelId: "987654321098765432", // ๐ข Default log channel
channels: {
// ๐ Custom channels (optional)
messageDelete: "111111111111111111",
voiceStateUpdate: "222222222222222222",
},
colors: {
// ๐จ Custom colors (optional)
messageDelete: "DarkRed",
channelCreate: "DarkGreen",
},
disable: ["inviteCreate"], // ๐ซ Disabled events (optional)
},
// Add more guild configurations...
{
guildId: "999888777666555444",
channelId: "444555666777888999",
},
];
// Start logging with custom data
await log(client, {
database: false, // ๐ Uses custom array
Data: logData, // ๐ Your configurations
});
console.log("โ
Logging system started with custom data!");
},
};๐จ Supported Colors
Default, White, Aqua, Green, Blue, Yellow, Purple, LuminousVividPink, Fuchsia, Gold, Orange, Red, Grey, Navy, DarkAqua, DarkGreen, DarkBlue, DarkPurple, DarkVividPink, DarkGold, DarkOrange, DarkRed, DarkGrey, DarkerGrey, LightGrey, DarkNavy, Blurple, Greyple, DarkButNotBlack, NotQuiteBlack, Random, or any Hex Color like #FF5733.
๐ Multi-Guild Support
๐ก Tip: You can add configurations for multiple guilds in the same array. Each guild can have its own unique settings for channels, colors, and disabled events!
๐พ Using the Log Model Directly
You can import the Log Mongoose model to create, update, or delete log configurations programmatically.
๐ฅ Import the Model:
const { Log } = require("djs-builder");โ Create New Configuration:
const { Log } = require("djs-builder");
// Create a new log configuration for a guild
const newConfig = await Log.create({
guildId: "123456789012345678",
channelId: "987654321098765432",
channels: {
messageDelete: "111111111111111111",
},
colors: {
messageDelete: "Red",
},
disable: [],
});
console.log("โ
Log configuration created!", newConfig);โ๏ธ Update Existing Configuration:
const { Log } = require("djs-builder");
// Update log channel
await Log.findOneAndUpdate(
{ guildId: "123456789012345678" },
{ channelId: "NEW_CHANNEL_ID" },
{ upsert: true } // Create if doesn't exist
);
// Add event to disable list
await Log.findOneAndUpdate(
{ guildId: "123456789012345678" },
{ $push: { disable: "voiceStateUpdate" } }
);
// Remove event from disable list
await Log.findOneAndUpdate(
{ guildId: "123456789012345678" },
{ $pull: { disable: "voiceStateUpdate" } }
);
// Update specific channel for an event
await Log.findOneAndUpdate(
{ guildId: "123456789012345678" },
{ $set: { "channels.messageDelete": "NEW_CHANNEL_ID" } }
);
// Update specific color for an event
await Log.findOneAndUpdate(
{ guildId: "123456789012345678" },
{ $set: { "colors.messageDelete": "DarkRed" } }
);๐๏ธ Delete Configuration:
const { Log } = require("djs-builder");
await Log.findOneAndDelete({ guildId: "123456789012345678" });
console.log("๐๏ธ Log configuration deleted!");๐ Fetch Configuration:
const { Log } = require("djs-builder");
const config = await Log.findOne({ guildId: "123456789012345678" });
if (config) {
console.log("๐ข Log Channel:", config.channelId);
console.log("๐ Custom Channels:", config.channels);
console.log("๐จ Custom Colors:", config.colors);
console.log("๐ซ Disabled Events:", config.disable);
}๐ฅ๏ธ Web Dashboard for Log Management
When you use database mode (database: true), you can manage the logging system directly from the djs-builder Dashboard! ๐๏ธ
โจ Dashboard Features for Logs
| Feature | Description | | ---------------------- | -------------------------------------------- | | ๐ข Default Channel | Set the main channel for all logs | | ๐ Custom Channels | Assign specific channels for each event type | | ๐จ Custom Colors | Choose embed colors for each event type | | ๐ Toggle Events | Enable/Disable specific event types | | ๐ Statistics | View enabled/disabled events count | | ๐๏ธ Reset | Clear all log settings with one click |
๐ How to Access
- Navigate to your dashboard (e.g.,
http://localhost:3000) - Log in with Discord OAuth2
- Select a server
- Click on "ุณุฌูุงุช ุงูู ุฑุงูุจุฉ" (Logs) in the sidebar
โ ๏ธ Important Notes
When database: true:
- โ Full editing capabilities from dashboard
- โ Changes are saved automatically to MongoDB
- โ Real-time updates
When database: false (Custom Data Array):
- โ ๏ธ Dashboard shows read-only mode
- โ ๏ธ A warning banner appears at the top
- โ ๏ธ You must edit settings in your code
๐ ๏ธ Complete Log Management Slash Command
This command allows server administrators to manage the logging system via Discord.
โ ๏ธ Important: This command requires
database: truemode to work properly.
const { Log, getLogConfigData } = require("djs-builder");
const {
SlashCommandBuilder,
PermissionFlagsBits,
EmbedBuilder,
ChannelType,
} = require("discord.js");
// All supported event types (21 events)
const EVENT_TYPES = [
{ name: "Message Delete", value: "messageDelete" },
{ name: "Message Update", value: "messageUpdate" },
{ name: "Channel Create", value: "channelCreate" },
{ name: "Channel Delete", value: "channelDelete" },
{ name: "Channel Update", value: "channelUpdate" },
{ name: "Member Join", value: "guildMemberAdd" },
{ name: "Member Leave", value: "guildMemberRemove" },
{ name: "Member Ban", value: "guildBanAdd" },
{ name: "Member Unban", value: "guildBanRemove" },
{ name: "Role Create", value: "roleCreate" },
{ name: "Role Delete", value: "roleDelete" },
{ name: "Role Update", value: "roleUpdate" },
{ name: "Member Role Update", value: "guildMemberUpdate" },
{ name: "Voice State", value: "voiceStateUpdate" },
{ name: "Invite Create", value: "inviteCreate" },
{ name: "Emoji Create", value: "emojiCreate" },
{ name: "Emoji Delete", value: "emojiDelete" },
{ name: "Emoji Update", value: "emojiUpdate" },
{ name: "Sticker Create", value: "stickerCreate" },
{ name: "Sticker Delete", value: "stickerDelete" },
{ name: "Sticker Update", value: "stickerUpdate" },
];
// Helper function to clear cache after updates
function clearLogCache(guildId) {
const logData = getLogConfigData();
if (logData.clearCache) logData.clearCache(guildId);
}
module.exports = {
data: new SlashCommandBuilder()
.setName("logs")
.setDescription("๐ก๏ธ Manage the server logging system")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand((sub) =>
sub
.setName("setup")
.setDescription("๐ข Set up the default log channel")
.addChannelOption((opt) =>
opt
.setName("channel")
.setDescription("The channel to send logs to")
.addChannelTypes(ChannelType.GuildText)
.setRequired(true)
)
)
.addSubcommand((sub) =>
sub
.setName("channel")
.setDescription("๐ Set a specific channel for an event type")
.addStringOption((opt) =>
opt
.setName("event")
.setDescription("The event type")
.setRequired(true)
.addChoices(...EVENT_TYPES)
)
.addChannelOption((opt) =>
opt
.setName("channel")
.setDescription("The channel for this event")
.addChannelTypes(ChannelType.GuildText)
.setRequired(true)
)
)
.addSubcommand((sub) =>
sub
.setName("color")
.setDescription("๐จ Set a custom color for an event type")
.addStringOption((opt) =>
opt
.setName("event")
.setDescription("The event type")
.setRequired(true)
.addChoices(...EVENT_TYPES)
)
.addStringOption((opt) =>
opt
.setName("color")
.setDescription("Color name or hex code (e.g., Red, #FF5733)")
.setRequired(true)
)
)
.addSubcommand((sub) =>
sub
.setName("toggle")
.setDescription("๐ Enable or disable an event type")
.addStringOption((opt) =>
opt
.setName("event")
.setDescription("The event type")
.setRequired(true)
.addChoices(...EVENT_TYPES)
)
.addStringOption((opt) =>
opt
.setName("action")
.setDescription("Enable or disable")
.setRequired(true)
.addChoices(
{ name: "Enable", value: "enable" },
{ name: "Disable", value: "disable" }
)
)
)
.addSubcommand((sub) =>
sub.setName("view").setDescription("๐ View current log configuration")
)
.addSubcommand((sub) =>
sub
.setName("reset")
.setDescription("๐๏ธ Reset all log settings for this server")
),
async run(client, interaction) {
await interaction.deferReply({ ephemeral: true });
const subcommand = interaction.options.getSubcommand();
const guildId = interaction.guild.id;
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// ๐ข SETUP - Set default log channel
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if (subcommand === "setup") {
const channel = interaction.options.getChannel("channel");
await Log.findOneAndUpdate(
{ guildId },
{ guildId, channelId: channel.id },
{ upsert: true, new: true }
);
clearLogCache(guildId); // Clear cache to apply changes immediately
const embed = new EmbedBuilder()
.setTitle("โ
Logging System Setup")
.setDescription(`Logs will now be sent to ${channel}`)
.setColor("Green")
.setTimestamp();
return interaction.editReply({ embeds: [embed] });
}
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// ๐ CHANNEL - Set specific channel for event
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if (subcommand === "channel") {
const event = interaction.options.getString("event");
const channel = interaction.options.getChannel("channel");
await Log.findOneAndUpdate(
{ guildId },
{ $set: { [`channels.${event}`]: channel.id } },
{ upsert: true }
);
clearLogCache(guildId);
const eventName =
EVENT_TYPES.find((e) => e.value === event)?.name || event;
const embed = new EmbedBuilder()
.setTitle("๐ Event Channel Updated")
.setDescription(`**${eventName}** logs will now be sent to ${channel}`)
.setColor("Blue")
.setTimestamp();
return interaction.editReply({ embeds: [embed] });
}
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// ๐จ COLOR - Set custom color for event
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if (subcommand === "color") {
const event = interaction.options.getString("event");
const color = interaction.options.getString("color");
await Log.findOneAndUpdate(
{ guildId },
{ $set: { [`colors.${event}`]: color } },
{ upsert: true }
);
clearLogCache(guildId);
const eventName =
EVENT_TYPES.find((e) => e.value === event)?.name || event;
// Try to use the color, fallback to Blue if invalid
let embedColor;
try {
embedColor = color;
} catch {
embedColor = "Blue";
}
const embed = new EmbedBuilder()
.setTitle("๐จ Event Color Updated")
.setDescription(
`**${eventName}** embeds will now use color: \`${color}\``
)
.setColor(embedColor)
.setTimestamp();
return interaction.editReply({ embeds: [embed] });
}
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// ๐ TOGGLE - Enable/Disable event
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if (subcommand === "toggle") {
const event = interaction.options.getString("event");
const action = interaction.options.getString("action");
if (action === "disable") {
await Log.findOneAndUpdate(
{ guildId },
{ $addToSet: { disable: event } },
{ upsert: true }
);
} else {
await Log.findOneAndUpdate(
{ guildId },
{ $pull: { disable: event } },
{ upsert: true }
);
}
clearLogCache(guildId);
const eventName =
EVENT_TYPES.find((e) => e.value === event)?.name || event;
const embed = new EmbedBuilder()
.setTitle(
action === "disable" ? "๐ซ Event Disabled" : "โ
Event Enabled"
)
.setDescription(`**${eventName}** logging has been ${action}d`)
.setColor(action === "disable" ? "Red" : "Green")
.setTimestamp();
return interaction.editReply({ embeds: [embed] });
}
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// ๐ VIEW - Show current configuration
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if (subcommand === "view") {
const config = await Log.findOne({ guildId });
if (!config) {
return interaction.editReply({
content:
"โ No logging configuration found for this server. Use `/logs setup` first!",
});
}
const channelsList = config.channels
? Object.entries(config.channels)
.map(([k, v]) => {
const eventName = EVENT_TYPES.find((e) => e.value === k)?.name || k;
return `โข **${eventName}**: <#${v}>`;
})
.join("\n") || "None"
: "None";
const colorsList = config.colors
? Object.entries(config.colors)
.map(([k, v]) => {
const eventName = EVENT_TYPES.find((e) => e.value === k)?.name || k;
return `โข **${eventName}**: \`${v}\``;
})
.join("\n") || "None"
: "None";
const disabledList =
config.disable?.length > 0
? config.disable.map((e) => {
const eventName = EVENT_TYPES.find((ev) => ev.value === e)?.name || e;
return `โข ${eventName}`;
}).join("\n")
: "None";
const enabledCount = EVENT_TYPES.length - (config.disable?.length || 0);
const embed = new EmbedBuilder()
.setTitle("๐ Log Configuration")
.setDescription(`**${enabledCount}/${EVENT_TYPES.length}** events are enabled`)
.setColor("Blue")
.addFields(
{
name: "๐ข Default Channel",
value: config.channelId ? `<#${config.channelId}>` : "Not set",
inline: true,
},
{
name: "๐ Custom Channels",
value: channelsList.slice(0, 1024) || "None",
inline: false,
},
{
name: "๐จ Custom Colors",
value: colorsList.slice(0, 1024) || "None",
inline: false,
},
{
name: "๐ซ Disabled Events",
value: disabledList.slice(0, 1024) || "None",
inline: false,
}
)
.setFooter({ text: `Guild ID: ${guildId}` })
.setTimestamp();
return interaction.editReply({ embeds: [embed] });
}
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// ๐๏ธ RESET - Delete all configuration
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if (subcommand === "reset") {
await Log.findOneAndDelete({ guildId });
clearLogCache(guildId);
const embed = new EmbedBuilder()
.setTitle("๐๏ธ Configuration Reset")
.setDescription(
"All logging settings have been deleted for this server."
)
.setColor("Red")
.setTimestamp();
return interaction.editReply({ embeds: [embed] });
}
},
};๐ก Tips & Notes
- ๐ Caching: The system caches guild configurations for better performance.
- ๐ Permissions: Make sure your bot has
View Audit Logpermission for full functionality. - ๐ข Invite Tracking: Uses
discord-inviterpackage for accurate invite tracking. - ๐จ Default Colors: Each event type has sensible default colors if not customized.
- ๐ซ Disabled Events: Events in the
disablearray will be completely ignored. - ๐ Channel Fallback: If no specific channel is set for an event, it uses
channelId. - ๐พ Database Mode: Recommended for multi-server bots with dynamic configuration needs.
- ๐ Dashboard Integration: When using database mode, you can manage logs via the web dashboard!
๐ Level System โ XP, Levels & Leaderboard
The Level System module lets you track user experience points (XP) in text ๐ฌ and voice ๐๏ธ, handle level-ups โฌ๏ธ, and display leaderboards ๐ . Perfect for gamifying your Discord server! ๐ฎโจ
Note: To use this module, you MUST have DATABASE conection. | Note 2: You can get all data by requiring the Level module.
๐ฆ Module Exports
const { addXP, UserLevel, leaderboard } = require("djs-builder");addXP(userId, guildId, options)โ Adds XP for a user and handles level-ups ๐ฒ.UserLevel(userId, guildId)โ Fetch a user's XP and level ๐ค.leaderboard(guildId, type, limit)โ Get top users ๐ .
๐ฒ addXP โ Add Experience Points
Adds XP to a user and automatically handles level-ups.
const result = await addXP("USER_ID", "GUILD_ID", {
type: "text", // "text" ๐ฌ | "voice" ๐๏ธ
minXP: 5, // Minimum random XP ๐ข
maxXP: 15, // Maximum random XP ๐ต
amount_add: 10, // Optional: fixed XP ๐
level_add: 1, // Optional: direct level boost โฌ๏ธ
});
console.log(result);
/* Example output:
{
newLevel: 3,
oldLevel: 2,
totalXP: 250,
leveledUp: true
}
*/๐งโ๐คโ๐ง UserLevel โ Fetch User Data
Fetch a user's text XP, voice XP, total XP, and current level.
const data = await UserLevel("USER_ID", "GUILD_ID");
console.log(data);
/* Example output:
{
text: 120 ๐ฌ,
voice: 50 ๐๏ธ,
totalXP: 170 โญ,
level: 2 โฌ๏ธ
}
*/Returns default values if the user is not found.
๐ Leaderboard โ Top Users
Get a sorted list of users based on XP or level.
const topUsers = await leaderboard("GUILD_ID", "totalXP", 5);
console.log(topUsers);
/* Example output:
[
{ userId: "123", totalXP: 500, level: 5 },
{ userId: "456", totalXP: 400, level: 4 },
...
]
*/Parameters:
guildIdโ Server ID ๐typeโ"totalXP","text"๐ฌ,"voice"๐๏ธ, or"level"โฌ๏ธ. Default ="totalXP"limitโ Number of top users to return ๐ข. Default = 10
โก Practical Example: messageCreate Event
const { addXP, UserLevel, leaderboard } = require("djs-builder");
module.exports = {
name: "messageCreate",
run: async (msg, client) => {
if (msg.author.bot) return;
// ๐ฒ Add XP on every message
const result = await addXP(msg.author.id, msg.guild.id, {
type: "text",
minXP: 5,
maxXP: 15,
});
// ๐ Level-up notification
if (result.leveledUp) {
msg.channel.send(`๐ ${msg.author} new level **${result.newLevel}** โฌ๏ธ`);
}
// ๐ Check your rank
if (msg.content === "!rank") {
const data = await UserLevel(msg.author.id, msg.guild.id);
msg.reply(`๐ **level ** ${data.level} โฌ๏ธ โ **XP:** ${data.totalXP} โญ`);
}
// ๐
Display top users
if (msg.content === "!top") {
const lb = await leaderboard(msg.guild.id, "totalXP", 5);
msg.reply(
lb
.map(
(u, i) =>
`#${i + 1} <@${u.userId}> โ Lv.${u.level} โฌ๏ธ (${u.totalXP} โญ)`
)
.join("\n")
);
}
},
};๐ก Notes & Tips
- ๐ฌ Text XP โ Add XP for messages automatically.
- ๐๏ธ Voice XP โ Add XP for voice activity.
- โฌ๏ธ Level Up โ Trigger notifications when leveling up.
- ๐ Leaderboard โ Display the top users in server using embeds for better look.
- ๐ฎ Gamify your server easily with XP rewards, mini-games, and custom commands.
๐ Giveaway System โ All-in-One Contest Management ๐โจ
This module provides a robust and feature-rich suite of functions to effortlessly launch, monitor, manage, and conclude Giveaways on your Discord server. It fully supports both Reactions and Buttons for entry, featuring advanced controls like pausing, resuming, and rerolling winners. It is highly recommended to read the Important Notes section below. ๐จ
Note: To use this module, you MUST have DATABASE conection. | Note 2: You can get all data by requiring the giveaway module.
๐ฆ Module Exports
const {
Gstart,
Gcheck,
Greroll,
Glist,
Gpause,
Gresume,
Gdelete,
GaddUser,
GremoveUser,
GaddTime,
GremoveTime,
Gdata,
} = require("djs-builder");๐ฌ Gstart โ Launch a Brand New Giveaway! ๐
This is the primary function to kick off a new giveaway. It handles creating the Discord message and persists all necessary data in the database (MongoDB). This function offers deep customization for embeds and entry methods. ๐จ
โ๏ธ Essential Options:
context: The Message or Interaction object that triggered the command.endTime: The duration until the giveaway ends (in milliseconds โฑ๏ธ).winers: The number of winners for the contest. ๐channelId: The ID of the channel where the giveaway message will be posted. ๐ขembed/endEmbed: Options to fully customize the starting message and the final end message.reaction: To specify the entry method (buttonorreaction). ๐ฑ๏ธ
โก Simple Usage Example (Basic Requirements Only):
This example provides a fast and minimalist way to start a giveaway with default embed colors, a simple title, and the default reaction entry type (if the reaction object is omitted or set to reaction).
const { Gstart } = require("djs-builder");
module.exports = {
name: "gstart",
description: "Starts a new simple giveaway.",
run: async (client, message, args) => {
// โฐ Giveaway ends in 1 hour
const oneHour = 60 * 60 * 1000;
const channelId = message.channel.id;
await Gstart({
context: message,
endTime: oneHour,
winers: 1,
channelId: channelId,
embed: {
title: "๐ Simple Test Giveaway",
description: "React to enter! Prize: Discord Nitro.",
},
});
message.reply("๐ Simple Giveaway starte