djs-builder 0.7.7 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -211,6 +211,12 @@ const actionRow = new CreateRow([
211
211
  emoji: "🚀",
212
212
  disabled: true, // Button is disabled
213
213
  },
214
+ {
215
+ style: 5,
216
+ label: "link",
217
+ emoji: "🔗"
218
+ url : "https://discord.gg/z9GpYsYF" // for url button
219
+ }
214
220
  ],
215
221
 
216
222
  // 🔹 Row #2: Select Menu
@@ -245,7 +251,7 @@ const actionRow = new CreateRow([
245
251
  disabled: false, // Disable the entire menu
246
252
  defaultValues: [
247
253
  // For role/user/channel menus
248
- { id: "123456789012345678", type: "user" }, // Pre-selected
254
+ { id: "123456789012345678" }, // Pre-selected
249
255
  ],
250
256
  channelTypes: [0, 2], // Only for ChannelSelectMenu (0 = Text, 2 = Voice)
251
257
  },
@@ -264,6 +270,7 @@ const actionRow = new CreateRow([
264
270
  - `label` → Button text
265
271
  - `emoji` → Displayed emoji
266
272
  - `disabled` → true = button is unclickable
273
+ - `url` → requiier for like button (style : 5)
267
274
 
268
275
  #### 🔹 Select Menus
269
276
 
@@ -4,6 +4,7 @@ const {
4
4
  RoleSelectMenuBuilder,
5
5
  UserSelectMenuBuilder,
6
6
  ActionRowBuilder,
7
+ SelectMenuDefaultValueTypes,
7
8
  ButtonBuilder,
8
9
  } = require("discord.js");
9
10
 
@@ -152,7 +153,7 @@ async function Wait({
152
153
 
153
154
  //////////////////////////////////* Row creat 🔩
154
155
 
155
- function CreateRow(components) {
156
+ function CreateRow(components, rowOnly = false) {
156
157
  if (!Array.isArray(components)) {
157
158
  throw new Error("Components should be an array.");
158
159
  }
@@ -234,13 +235,23 @@ function CreateRow(components) {
234
235
  }
235
236
 
236
237
  if (defaultValues && Array.isArray(defaultValues)) {
237
- selectMenu.setDefaultValues(defaultValues);
238
+ let ty , all = [];
239
+ if (type === "user") ty = selectMenu.setDefaultUsers(...defaultValues);
240
+ else if (type === "role") ty = selectMenu.setDefaultRoles(...defaultValues);
241
+ else if (type === "channel") ty = selectMenu.setDefaultChannels(...defaultValues);
242
+ for (const val of defaultValues) {
243
+ all.push({ type: ty, id: val });
244
+ }
238
245
  }
239
246
 
240
247
  if (options.hasOwnProperty("disabled")) {
241
248
  selectMenu.setDisabled(options.disabled);
242
249
  }
243
250
 
251
+
252
+ if (rowOnly) {
253
+ return selectMenu;
254
+ }
244
255
  actionRows.push(new ActionRowBuilder().addComponents(selectMenu));
245
256
  } else {
246
257
  throw new Error("Invalid component format");
@@ -256,7 +267,7 @@ async function CreateModal(options) {
256
267
  const { id, title, components } = options;
257
268
  const modal = new ModalBuilder().setCustomId(id).setTitle(title);
258
269
 
259
- components.forEach((com) => {
270
+ components.forEach(async (com) => {
260
271
  if (com.type === "textInput") {
261
272
  com.components.forEach((component) => {
262
273
  const {
@@ -287,60 +298,17 @@ async function CreateModal(options) {
287
298
  });
288
299
  } else if (com.type === "menu") {
289
300
  const { type, options } = com.components;
290
- const {
291
- mine_label = false,
292
- placeholder = "Choose an option",
293
- description = false,
294
- data = [],
295
- label = false,
296
- emoji = false,
297
- value = false,
298
- id = "selectMenu",
299
- max = false,
300
- min = false,
301
- channelTypes = false,
302
- defaultValues = false,
303
- } = options;
304
-
305
- let selectMenu;
306
- if (type === "string") selectMenu = new StringSelectMenuBuilder();
307
- else if (type === "user") selectMenu = new UserSelectMenuBuilder();
308
- else if (type === "role") selectMenu = new RoleSelectMenuBuilder();
309
- else if (type === "channel") selectMenu = new ChannelSelectMenuBuilder();
310
301
 
311
- selectMenu.setCustomId(id);
312
- selectMenu.setPlaceholder(placeholder);
313
302
 
314
- if (min) {
315
- selectMenu.setMinValues(Math.min(min, data.length));
316
- }
317
- if (max) {
318
- selectMenu.setMaxValues(max);
319
- } else if (min) {
320
- selectMenu.setMaxValues(data.length);
321
- }
322
-
323
- if (type === "string" && Array.isArray(data)) {
324
- const selectOptions = data.map((item, index) => ({
325
- label: item[label] || `Option ${index + 1}`,
326
- description: item[description]?.slice(0, 100) || undefined,
327
- emoji: item[emoji] || undefined,
328
- value: item[value] || `${index}`,
329
- default: item.default || false,
330
- }));
331
- selectMenu.addOptions(selectOptions);
332
- }
333
-
334
- if (type === "channel" && Array.isArray(channelTypes)) {
335
- selectMenu.setChannelTypes(channelTypes);
336
- }
337
-
338
- if (defaultValues && Array.isArray(defaultValues)) {
339
- selectMenu.setDefaultValues(defaultValues);
340
- }
303
+ const selectMenu = await CreateRow([
304
+ {
305
+ type: type,
306
+ options: options
307
+ }
308
+ ], true)
341
309
 
342
310
  const menu = new LabelBuilder()
343
- .setLabel(mine_label || "Select an option")
311
+ .setLabel( options.mine_label || "Select an option")
344
312
  .setStringSelectMenuComponent(selectMenu);
345
313
 
346
314
  modal.addLabelComponents(menu);
@@ -374,7 +342,7 @@ async function CreateComponents(type, components) {
374
342
  result = [];
375
343
  }
376
344
 
377
- components.forEach((item) => {
345
+ components.forEach(async (item) => {
378
346
  if (item.type === "text") {
379
347
  const text = new TextDisplayBuilder().setContent(item.content);
380
348
 
@@ -421,23 +389,10 @@ async function CreateComponents(type, components) {
421
389
  result.push(file);
422
390
  }
423
391
  } else if (item.type === "button") {
424
- const buttons = [];
425
-
426
- item.components.forEach((item) => {
427
- const button = new ButtonBuilder().setStyle(item.style || 2);
428
- if (item.label) button.setLabel(item.label);
429
- if (item.emoji) button.setEmoji(item.emoji);
430
- if (item.style !== 5) {
431
- if (!item.id)
432
- throw new Error("Button id is required for non-link buttons.");
433
- button.setCustomId(item.id);
434
- }
435
- if (item.hasOwnProperty("disabled")) button.setDisabled(item.disabled);
436
- if (item.style === 5 && item.url) button.setURL(item.url);
437
- buttons.push(button);
438
- });
439
- const but = new ActionRowBuilder().addComponents(...buttons);
440
392
 
393
+ const but = await CreateRow([
394
+ item.components
395
+ ])
441
396
  if (type === "container") {
442
397
  result.addActionRowComponents(but);
443
398
  } else {
@@ -445,61 +400,14 @@ async function CreateComponents(type, components) {
445
400
  }
446
401
  } else if (item.type === "menu") {
447
402
  const menu_type = item.components.type;
448
- const {
449
- placeholder = "Choose an option",
450
- description = false,
451
- data = [],
452
- label = false,
453
- emoji = false,
454
- value = false,
455
- id = "selectMenu",
456
- max = false,
457
- min = false,
458
- channelTypes = false,
459
- defaultValues = false,
460
- } = item.components.options;
461
-
462
- let selectMenu;
463
- if (menu_type === "string") selectMenu = new StringSelectMenuBuilder();
464
- else if (menu_type === "user") selectMenu = new UserSelectMenuBuilder();
465
- else if (menu_type === "role") selectMenu = new RoleSelectMenuBuilder();
466
- else if (menu_type === "channel")
467
- selectMenu = new ChannelSelectMenuBuilder();
468
-
469
- console.log(menu_type, selectMenu, id);
470
- selectMenu.setCustomId(id);
471
- selectMenu.setPlaceholder(placeholder);
472
-
473
- if (min) {
474
- selectMenu.setMinValues(Math.min(min, data.length));
475
- }
476
- if (max) {
477
- selectMenu.setMaxValues(max);
478
- } else if (min) {
479
- selectMenu.setMaxValues(data.length);
480
- }
481
-
482
- if (menu_type === "string" && Array.isArray(data)) {
483
- const selectOptions = data.map((item, index) => ({
484
- label: item[label] || `Option ${index + 1}`,
485
- description: item[description]?.slice(0, 100) || undefined,
486
- emoji: item[emoji] || undefined,
487
- value: item[value] || `${index}`,
488
- default: item.default || false,
489
- }));
490
- selectMenu.addOptions(selectOptions);
491
- }
492
-
493
- if (menu_type === "channel" && Array.isArray(channelTypes)) {
494
- selectMenu.setChannelTypes(channelTypes);
495
- }
496
-
497
- if (defaultValues && Array.isArray(defaultValues)) {
498
- selectMenu.setDefaultValues(defaultValues);
499
- }
500
-
501
- const menu = new ActionRowBuilder().addComponents(selectMenu);
502
-
403
+ const options = item.components.options;
404
+
405
+ const menu = await CreateRow([
406
+ {
407
+ type: menu_type,
408
+ options: options
409
+ }
410
+ ])
503
411
  if (type === "container") {
504
412
  result.addActionRowComponents(menu);
505
413
  } else {
package/handler/helper.js CHANGED
@@ -119,7 +119,7 @@ async function terminalInfo(client, options, data) {
119
119
  );
120
120
 
121
121
  if (options.database?.url) {
122
- const result = await data_conecter(options.database.url);
122
+ const result = await data_conecter(options.database);
123
123
  if (result) {
124
124
  secondTable.push([chalk.cyan("Database"), rowColors[9]("Connected")]);
125
125
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "djs-builder",
3
- "version": "0.7.7",
4
- "note": "🎉 Package Update v0.7.6! \n\n- 🧩 NEW: CreateComponents Function!\n • Build advanced Discord UI (Text, Separator, Media, File, Button, Menu, Section)\n • Container mode for Components V2 | Array mode for standard messages\n • Full documentation with examples\n\n- 🔳 NEW: CreateModal Function!\n • Create Discord Modals with Text Inputs, Menus, Files, and Labels\n\n- 🌐 NEW: Dashboard System!\n • Discord OAuth2 Login\n • Server, Level, Giveaway & Blacklist Management\n • Logs Management Page (Enable/Disable events, custom channels & colors)\n • Standalone usage - works with or without Starter\n\n- 🛡️ Logging System Enhancements!\n • Dashboard Integration with Smart Cache System\n • Read-only Mode for code-based configs\n • Channel Fallback & Better Slash Command support\n\n- 🔧 Bug Fixes: Schema validation, cache updates, sidebar navigation\n\n🔗 Learn more on [NPM](https://www.npmjs.com/package/djs-builder)\n DISCORD SERVER : [LINK](https://discord.gg/uYcKCZk3)",
3
+ "version": "0.7.9",
4
+ "note": "🎉 Package Update v0.7.9! \n\n- 🧩 NEW: CreateComponents Function!\n • Build advanced Discord UI (Text, Separator, Media, File, Button, Menu, Section)\n • Container mode for Components V2 | Array mode for standard messages\n • Full documentation with examples\n\n- 🔳 NEW: CreateModal Function!\n • Create Discord Modals with Text Inputs, Menus, Files, and Labels\n\n- 🌐 NEW: Dashboard System!\n • Discord OAuth2 Login\n • Server, Level, Giveaway & Blacklist Management\n • Logs Management Page (Enable/Disable events, custom channels & colors)\n • Standalone usage - works with or without Starter\n\n- 🛡️ Logging System Enhancements!\n • Dashboard Integration with Smart Cache System\n • Read-only Mode for code-based configs\n • Channel Fallback & Better Slash Command support\n\n- 🔧 Bug Fixes: Schema validation, cache updates, sidebar navigation\n\n- <:npm:1107014411375353968> Learn more on [NPM](https://www.npmjs.com/package/djs-builder)\n- <:Discord:906936109114753024> DISCORD SERVER : [LINK](https://discord.gg/uYcKCZk3)",
5
5
  "description": "🎉 Full-featured Discord.js utilities: CreateComponents, CreateModal, Dashboard, Logging & more! 🥏",
6
6
  "main": "handler/starter.js",
7
7
  "dependencies": {