djs-builder 0.7.5 → 0.7.7

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
@@ -5,6 +5,8 @@
5
5
  **Welcome to the ultimate Discord Bot Utilities package! šŸ„**
6
6
  Boost your Discord bot development with ease, speed, and all-in-one features.
7
7
 
8
+ [![Discord Banner](https://api.weblutions.com/discord/invite/uYcKCZk3/)](https://discord.gg/uYcKCZk3)
9
+
8
10
  ---
9
11
 
10
12
  ## šŸ“‘ Table of Contents
@@ -64,6 +66,7 @@ const starterOptions = {
64
66
 
65
67
  database: {
66
68
  url: "mongodb://localhost:27017", // šŸ’¾ MongoDB connection
69
+ dbName: "yourDatabaseName", // šŸ“ Optional: Specify database name (default: "test")
67
70
  },
68
71
 
69
72
  anticrash: {
@@ -99,6 +102,7 @@ await starter(client, starterOptions);
99
102
 
100
103
  - Connects automatically to MongoDB šŸ’¾.
101
104
  - Useful for bots with persistent data storage.
105
+ - Specify the database name using the `dbName` option. If not specified, MongoDB uses "test" as the default database name.
102
106
 
103
107
  #### 3ļøāƒ£ Anticrash System
104
108
 
@@ -1579,6 +1583,38 @@ const { log, Log } = require("djs-builder");
1579
1583
 
1580
1584
  ---
1581
1585
 
1586
+ ### šŸ“‹ Simple Example
1587
+
1588
+ ```js
1589
+ const { log } = require("djs-builder");
1590
+
1591
+ module.exports = {
1592
+ name: "clientReady",
1593
+ async run(client) {
1594
+ const logData = [
1595
+ {
1596
+ guildId: "999888777666555444",
1597
+ channelId: "444555666777888999",
1598
+ },
1599
+
1600
+ {
1601
+ guildId: "999888777666555444",
1602
+ channelId: "444555666777888999",
1603
+ },
1604
+ ];
1605
+
1606
+ // Start logging with custom data
1607
+ await log(client, {
1608
+ Data: logData, // šŸ“Š Your configurations
1609
+ });
1610
+
1611
+ console.log("āœ… Logging system started with custom data!");
1612
+ },
1613
+ };
1614
+ ```
1615
+
1616
+ ---
1617
+
1582
1618
  ### ✨ Features
1583
1619
 
1584
1620
  - šŸ“ **Messages** – Deleted & edited messages are logged with details.
@@ -1690,6 +1726,9 @@ This method uses a predefined array of configurations – perfect for simple set
1690
1726
 
1691
1727
  **⚔ Setup in `clientReady` Event:**
1692
1728
 
1729
+
1730
+
1731
+
1693
1732
  ```js
1694
1733
  const { log } = require("djs-builder");
1695
1734
 
@@ -4180,4 +4219,4 @@ We welcome contributions! If you have any suggestions, bug reports, or feature r
4180
4219
 
4181
4220
  🌐 **Join our Discord:**
4182
4221
 
4183
- [![Discord Banner](https://api.weblutions.com/discord/invite/CS2NRSPyze/)](https://discord.gg/CS2NRSPyze)
4222
+ [![Discord Banner](https://api.weblutions.com/discord/invite/uYcKCZk3/)](https://discord.gg/uYcKCZk3)
package/function/dash.js CHANGED
@@ -13,10 +13,6 @@ const path = require("path");
13
13
  const Table = require("cli-table3");
14
14
  const chalk = require("chalk");
15
15
 
16
-
17
-
18
-
19
-
20
16
  const { Level } = require("./level");
21
17
  const {
22
18
  Blacklist,
@@ -29,7 +25,7 @@ const {
29
25
  Greroll,
30
26
  Gpause,
31
27
  Gresume,
32
- Gdelete
28
+ Gdelete,
33
29
  } = require("./giveaway");
34
30
  const { Log, getLogConfigData } = require("./log");
35
31
 
@@ -42,15 +38,15 @@ function dashboard(client, options) {
42
38
  const app = express();
43
39
  const {
44
40
  clientSecret,
45
- callbackURL = "http://localhost:3000/auth/discord/callback",
46
- sessionSecret ,
41
+ callbackURL = "http://localhost:3000/auth/discord/callback",
42
+ sessionSecret,
47
43
  port = 3000,
48
44
  } = options;
49
45
 
50
46
  clientID = client.user.id;
51
47
  // Ų„Ų¹ŲÆŲ§ŲÆ المسارات
52
48
  app.set("view engine", "ejs");
53
- app.set("views", path.join(__dirname, "..", "views"));
49
+ app.set("views", path.join(__dirname, "..", "views"));
54
50
  app.use(express.json());
55
51
  app.use(express.urlencoded({ extended: true }));
56
52
 
@@ -111,11 +107,12 @@ function dashboard(client, options) {
111
107
  }
112
108
 
113
109
  // Ł…Ų­Ų§ŁˆŁ„Ų© Ų§Ł„Ų­ŲµŁˆŁ„ على البادئة من client
114
- const prefix = client.prefix || options.prefix || '-';
110
+ const prefix = client.prefix || options.prefix || "-";
115
111
 
116
112
  return {
117
113
  guilds: client.guilds?.cache?.size || 0,
118
- users: client.guilds?.cache?.reduce((acc, g) => acc + g.memberCount, 0) || 0,
114
+ users:
115
+ client.guilds?.cache?.reduce((acc, g) => acc + g.memberCount, 0) || 0,
119
116
  channels: client.channels?.cache?.size || 0,
120
117
  slashCommands: client.slashCommands?.size || 0,
121
118
  prefixCommands: uniquePrefixCommands.size,
@@ -171,12 +168,11 @@ function dashboard(client, options) {
171
168
  // Ł„ŁˆŲ­Ų© Ų§Ł„ŲŖŲ­ŁƒŁ… Ų§Ł„Ų±Ų¦ŁŠŲ³ŁŠŲ©
172
169
  app.get("/dashboard", isAuthenticated, (req, res) => {
173
170
  const userGuilds = req.user.guilds.filter(
174
- (g) =>
175
- (g.permissions & 0x20) === 0x20 && client.guilds.cache.has(g.id)
171
+ (g) => (g.permissions & 0x20) === 0x20 && client.guilds.cache.has(g.id)
176
172
  );
177
- res.render("dashboard", {
173
+ res.render("dashboard", {
178
174
  guilds: userGuilds,
179
- botStats: getBotStats()
175
+ botStats: getBotStats(),
180
176
  });
181
177
  });
182
178
 
@@ -197,8 +193,13 @@ function dashboard(client, options) {
197
193
 
198
194
  try {
199
195
  if (Level) levelCount = await Level.countDocuments({ guildId: guild.id });
200
- if (giveaway) giveawayCount = await giveaway.countDocuments({ guildId: guild.id, ended: false });
201
- if (Blacklist) blacklistCount = await Blacklist.countDocuments({ guild: guild.id });
196
+ if (giveaway)
197
+ giveawayCount = await giveaway.countDocuments({
198
+ guildId: guild.id,
199
+ ended: false,
200
+ });
201
+ if (Blacklist)
202
+ blacklistCount = await Blacklist.countDocuments({ guild: guild.id });
202
203
  } catch (e) {
203
204
  console.error("Stats error:", e);
204
205
  }
@@ -215,7 +216,7 @@ function dashboard(client, options) {
215
216
  activeGiveaways: giveawayCount,
216
217
  blacklisted: blacklistCount,
217
218
  },
218
- botStats: getBotStats()
219
+ botStats: getBotStats(),
219
220
  });
220
221
  });
221
222
 
@@ -227,7 +228,7 @@ function dashboard(client, options) {
227
228
  const slashCommands = client.slashCommands
228
229
  ? Array.from(client.slashCommands.values())
229
230
  : [];
230
-
231
+
231
232
  // ؄زالة Ų§Ł„ŲŖŁƒŲ±Ų§Ų±Ų§ŲŖ من prefix commands
232
233
  const uniquePrefixCommands = [];
233
234
  const seen = new Set();
@@ -245,7 +246,7 @@ function dashboard(client, options) {
245
246
  slashCommands,
246
247
  prefixCommands: uniquePrefixCommands,
247
248
  page: "commands",
248
- botStats: getBotStats()
249
+ botStats: getBotStats(),
249
250
  });
250
251
  });
251
252
 
@@ -269,7 +270,7 @@ function dashboard(client, options) {
269
270
  guild,
270
271
  leaderboard: leaderboardData,
271
272
  page: "levels",
272
- botStats: getBotStats()
273
+ botStats: getBotStats(),
273
274
  });
274
275
  });
275
276
 
@@ -289,72 +290,82 @@ function dashboard(client, options) {
289
290
  });
290
291
 
291
292
  // ==================== نظام Ų§Ł„Ų¬ŁŠŁ اوي ====================
292
- app.get("/dashboard/:guildId/giveaways", isAuthenticated, async (req, res) => {
293
- const guild = client.guilds.cache.get(req.params.guildId);
294
- if (!guild) return res.redirect("/dashboard");
295
-
296
- let giveaways = [];
297
- if (giveaway) {
298
- try {
299
- giveaways = await giveaway.find({ guildId: guild.id }).sort({ endTime: -1 });
300
- } catch (e) {
301
- console.error("Error fetching giveaways:", e);
293
+ app.get(
294
+ "/dashboard/:guildId/giveaways",
295
+ isAuthenticated,
296
+ async (req, res) => {
297
+ const guild = client.guilds.cache.get(req.params.guildId);
298
+ if (!guild) return res.redirect("/dashboard");
299
+
300
+ let giveaways = [];
301
+ if (giveaway) {
302
+ try {
303
+ giveaways = await giveaway
304
+ .find({ guildId: guild.id })
305
+ .sort({ endTime: -1 });
306
+ } catch (e) {
307
+ console.error("Error fetching giveaways:", e);
308
+ }
302
309
  }
303
- }
304
310
 
305
- res.render("giveaways", {
306
- guild,
307
- giveaways,
308
- page: "giveaways",
309
- botStats: getBotStats()
310
- });
311
- });
311
+ res.render("giveaways", {
312
+ guild,
313
+ giveaways,
314
+ page: "giveaways",
315
+ botStats: getBotStats(),
316
+ });
317
+ }
318
+ );
312
319
 
313
320
  // API Ł„Ł„Ų¬ŁŠŁ اوي
314
- app.post("/api/:guildId/giveaway/:action", isAuthenticated, async (req, res) => {
315
- const { guildId, action } = req.params;
316
- const { messageId } = req.body;
321
+ app.post(
322
+ "/api/:guildId/giveaway/:action",
323
+ isAuthenticated,
324
+ async (req, res) => {
325
+ const { guildId, action } = req.params;
326
+ const { messageId } = req.body;
317
327
 
318
- try {
319
- let result = { success: true };
320
- switch (action) {
321
- case "pause":
322
- if (Gpause) await Gpause(client, messageId);
323
- break;
324
- case "resume":
325
- // ŲŖŁ†ŁŁŠŲ° يدوي للاستئناف لأن Gresume في djs-builder يحتوي على Ų®Ų·Ų£
326
- if (Gresume) await Gresume(client, messageId);
327
- break;
328
- case "end":
329
- // ؄نهاؔ Ų§Ł„Ų¬ŁŠŁ اوي ŁŁˆŲ±Ų§Ł‹ ŲØŲŖŲ¹ŲÆŁŠŁ„ ŁˆŁ‚ŲŖ الانتهاؔ Ł„Ł„ŁˆŁ‚ŲŖ Ų§Ł„Ų­Ų§Ł„ŁŠ
330
- if (giveaway) {
331
- const g = await giveaway.findOne({ messageId });
332
- if (g && !g.ended) {
333
- // Ų„Ų°Ų§ ŁƒŲ§Ł† Ł…ŲŖŁˆŁ‚ŁŲ§Ł‹ Ł…Ų¤Ł‚ŲŖŲ§Ł‹ŲŒ Ł†Ł„ŲŗŁŠ Ų§Ł„Ų„ŁŠŁ‚Ų§Ł Ų£ŁˆŁ„Ų§Ł‹
334
- await giveaway.findOneAndUpdate(
335
- { messageId },
336
- { paused: false, endTime: Date.now().toString() }
337
- );
338
- // Ų„Ų¹Ų·Ų§Ų” Gcheck فرصة Ł„Ł„ŲŖŲ“ŲŗŁŠŁ„
339
- setTimeout(() => Gcheck && Gcheck(client), 1000);
328
+ try {
329
+ let result = { success: true };
330
+ switch (action) {
331
+ case "pause":
332
+ if (Gpause) await Gpause(client, messageId);
333
+ break;
334
+ case "resume":
335
+ // ŲŖŁ†ŁŁŠŲ° يدوي للاستئناف لأن Gresume في djs-builder يحتوي على Ų®Ų·Ų£
336
+ if (Gresume) await Gresume(client, messageId);
337
+ break;
338
+ case "end":
339
+ // ؄نهاؔ Ų§Ł„Ų¬ŁŠŁ اوي ŁŁˆŲ±Ų§Ł‹ ŲØŲŖŲ¹ŲÆŁŠŁ„ ŁˆŁ‚ŲŖ الانتهاؔ Ł„Ł„ŁˆŁ‚ŲŖ Ų§Ł„Ų­Ų§Ł„ŁŠ
340
+ if (giveaway) {
341
+ const g = await giveaway.findOne({ messageId });
342
+ if (g && !g.ended) {
343
+ // Ų„Ų°Ų§ ŁƒŲ§Ł† Ł…ŲŖŁˆŁ‚ŁŲ§Ł‹ Ł…Ų¤Ł‚ŲŖŲ§Ł‹ŲŒ Ł†Ł„ŲŗŁŠ Ų§Ł„Ų„ŁŠŁ‚Ų§Ł Ų£ŁˆŁ„Ų§Ł‹
344
+ await giveaway.findOneAndUpdate(
345
+ { messageId },
346
+ { paused: false, endTime: Date.now().toString() }
347
+ );
348
+ // Ų„Ų¹Ų·Ų§Ų” Gcheck فرصة Ł„Ł„ŲŖŲ“ŲŗŁŠŁ„
349
+ setTimeout(() => Gcheck && Gcheck(client), 1000);
350
+ }
340
351
  }
341
- }
342
- break;
343
- case "reroll":
344
- if (Greroll) await Greroll(client, messageId);
345
- break;
346
- case "delete":
347
- if (Gdelete) await Gdelete(messageId);
348
- break;
349
- default:
350
- return res.json({ success: false, error: "Invalid action" });
352
+ break;
353
+ case "reroll":
354
+ if (Greroll) await Greroll(client, messageId);
355
+ break;
356
+ case "delete":
357
+ if (Gdelete) await Gdelete(messageId);
358
+ break;
359
+ default:
360
+ return res.json({ success: false, error: "Invalid action" });
361
+ }
362
+ res.json({ success: true, message: `ŲŖŁ… ŲŖŁ†ŁŁŠŲ° ${action} بنجاح` });
363
+ } catch (e) {
364
+ console.error("Giveaway action error:", e);
365
+ res.json({ success: false, error: e.message });
351
366
  }
352
- res.json({ success: true, message: `ŲŖŁ… ŲŖŁ†ŁŁŠŲ° ${action} بنجاح` });
353
- } catch (e) {
354
- console.error("Giveaway action error:", e);
355
- res.json({ success: false, error: e.message });
356
367
  }
357
- });
368
+ );
358
369
 
359
370
  // ==================== نظام السجلات (Logs) ====================
360
371
  // قائمة Ų£Ł†ŁˆŲ§Ų¹ الأحداث Ų§Ł„Ł…ŲÆŲ¹ŁˆŁ…Ų©
@@ -365,20 +376,48 @@ function dashboard(client, options) {
365
376
  { name: "حذف قناة", value: "channelDelete", icon: "ri-close-circle-line" },
366
377
  { name: "ŲŖŲ¹ŲÆŁŠŁ„ قناة", value: "channelUpdate", icon: "ri-settings-3-line" },
367
378
  { name: "انضمام عضو", value: "guildMemberAdd", icon: "ri-user-add-line" },
368
- { name: "Ł…ŲŗŲ§ŲÆŲ±Ų© عضو", value: "guildMemberRemove", icon: "ri-user-unfollow-line" },
379
+ {
380
+ name: "Ł…ŲŗŲ§ŲÆŲ±Ų© عضو",
381
+ value: "guildMemberRemove",
382
+ icon: "ri-user-unfollow-line",
383
+ },
369
384
  { name: "Ų­ŲøŲ± عضو", value: "guildBanAdd", icon: "ri-forbid-line" },
370
- { name: "رفع الحظر", value: "guildBanRemove", icon: "ri-checkbox-circle-line" },
385
+ {
386
+ name: "رفع الحظر",
387
+ value: "guildBanRemove",
388
+ icon: "ri-checkbox-circle-line",
389
+ },
371
390
  { name: "؄نؓاؔ Ų±ŲŖŲØŲ©", value: "roleCreate", icon: "ri-shield-star-line" },
372
391
  { name: "حذف Ų±ŲŖŲØŲ©", value: "roleDelete", icon: "ri-shield-cross-line" },
373
392
  { name: "ŲŖŲ¹ŲÆŁŠŁ„ Ų±ŲŖŲØŲ©", value: "roleUpdate", icon: "ri-shield-line" },
374
- { name: "تغيير Ų±ŲŖŲØ Ų§Ł„Ų¹Ų¶Łˆ", value: "guildMemberUpdate", icon: "ri-user-settings-line" },
393
+ {
394
+ name: "تغيير Ų±ŲŖŲØ Ų§Ł„Ų¹Ų¶Łˆ",
395
+ value: "guildMemberUpdate",
396
+ icon: "ri-user-settings-line",
397
+ },
375
398
  { name: "نؓاط صوتي", value: "voiceStateUpdate", icon: "ri-mic-line" },
376
399
  { name: "؄نؓاؔ دعوة", value: "inviteCreate", icon: "ri-links-line" },
377
- { name: "؄ضافة Ų„ŁŠŁ…ŁˆŲ¬ŁŠ", value: "emojiCreate", icon: "ri-emotion-happy-line" },
378
- { name: "حذف Ų„ŁŠŁ…ŁˆŲ¬ŁŠ", value: "emojiDelete", icon: "ri-emotion-unhappy-line" },
400
+ {
401
+ name: "؄ضافة Ų„ŁŠŁ…ŁˆŲ¬ŁŠ",
402
+ value: "emojiCreate",
403
+ icon: "ri-emotion-happy-line",
404
+ },
405
+ {
406
+ name: "حذف Ų„ŁŠŁ…ŁˆŲ¬ŁŠ",
407
+ value: "emojiDelete",
408
+ icon: "ri-emotion-unhappy-line",
409
+ },
379
410
  { name: "ŲŖŲ¹ŲÆŁŠŁ„ Ų„ŁŠŁ…ŁˆŲ¬ŁŠ", value: "emojiUpdate", icon: "ri-emotion-line" },
380
- { name: "؄ضافة ستيكر", value: "stickerCreate", icon: "ri-sticky-note-line" },
381
- { name: "حذف ستيكر", value: "stickerDelete", icon: "ri-sticky-note-2-line" },
411
+ {
412
+ name: "؄ضافة ستيكر",
413
+ value: "stickerCreate",
414
+ icon: "ri-sticky-note-line",
415
+ },
416
+ {
417
+ name: "حذف ستيكر",
418
+ value: "stickerDelete",
419
+ icon: "ri-sticky-note-2-line",
420
+ },
382
421
  { name: "ŲŖŲ¹ŲÆŁŠŁ„ ستيكر", value: "stickerUpdate", icon: "ri-file-edit-line" },
383
422
  ];
384
423
 
@@ -408,7 +447,7 @@ function dashboard(client, options) {
408
447
  }
409
448
  } else {
410
449
  // وضع Code - قراؔة من Ų§Ł„ŁƒŁˆŲÆ Ų§Ł„Ł…ŁƒŲŖŁˆŲØ
411
- const codeConfig = logData.configs.find(c => c.guildId === guild.id);
450
+ const codeConfig = logData.configs.find((c) => c.guildId === guild.id);
412
451
  if (codeConfig) {
413
452
  logConfig = codeConfig;
414
453
  configSource = "code";
@@ -417,15 +456,19 @@ function dashboard(client, options) {
417
456
 
418
457
  // Ų§Ł„Ų­ŲµŁˆŁ„ على Ł‚Ł†ŁˆŲ§ŲŖ Ų§Ł„Ų³ŁŠŲ±ŁŲ± Ų§Ł„Ł†ŲµŁŠŲ©
419
458
  const channels = guild.channels.cache
420
- .filter(c => c.type === 0) // GuildText
421
- .map(c => ({ id: c.id, name: c.name }))
459
+ .filter((c) => c.type === 0) // GuildText
460
+ .map((c) => ({ id: c.id, name: c.name }))
422
461
  .sort((a, b) => a.name.localeCompare(b.name));
423
462
 
424
463
  // Ų­Ų³Ų§ŲØ Ų§Ł„Ų„Ų­ŲµŲ§Ų¦ŁŠŲ§ŲŖ
425
464
  const disabledEvents = logConfig?.disable?.length || 0;
426
465
  const enabledEvents = LOG_EVENT_TYPES.length - disabledEvents;
427
- const customColors = logConfig?.colors ? Object.keys(logConfig.colors).length : 0;
428
- const customChannels = logConfig?.channels ? Object.keys(logConfig.channels).length : 0;
466
+ const customColors = logConfig?.colors
467
+ ? Object.keys(logConfig.colors).length
468
+ : 0;
469
+ const customChannels = logConfig?.channels
470
+ ? Object.keys(logConfig.channels).length
471
+ : 0;
429
472
 
430
473
  res.render("logs", {
431
474
  guild,
@@ -439,14 +482,15 @@ function dashboard(client, options) {
439
482
  enabledEvents,
440
483
  disabledEvents,
441
484
  customColors,
442
- customChannels
485
+ customChannels,
443
486
  });
444
487
  });
445
488
 
446
489
  // API - تحديث القناة Ų§Ł„Ų§ŁŲŖŲ±Ų§Ų¶ŁŠŲ©
447
490
  app.post("/api/:guildId/logs/channel", isAuthenticated, async (req, res) => {
448
491
  const logData = getLogConfigData();
449
- if (!logData.databaseEnabled) return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
492
+ if (!logData.databaseEnabled)
493
+ return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
450
494
 
451
495
  const { channelId } = req.body;
452
496
  const guildId = req.params.guildId;
@@ -468,7 +512,8 @@ function dashboard(client, options) {
468
512
  // API - ŲŖŁŲ¹ŁŠŁ„/ŲŖŲ¹Ų·ŁŠŁ„ Ų­ŲÆŲ«
469
513
  app.post("/api/:guildId/logs/toggle", isAuthenticated, async (req, res) => {
470
514
  const logData = getLogConfigData();
471
- if (!logData.databaseEnabled) return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
515
+ if (!logData.databaseEnabled)
516
+ return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
472
517
 
473
518
  const { eventType, enable } = req.body;
474
519
  const guildId = req.params.guildId;
@@ -501,14 +546,15 @@ function dashboard(client, options) {
501
546
  // API - تحديث Ų„Ų¹ŲÆŲ§ŲÆŲ§ŲŖ Ų­ŲÆŲ« Ł…Ų¹ŁŠŁ†
502
547
  app.post("/api/:guildId/logs/event", isAuthenticated, async (req, res) => {
503
548
  const logData = getLogConfigData();
504
- if (!logData.databaseEnabled) return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
549
+ if (!logData.databaseEnabled)
550
+ return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
505
551
 
506
552
  const { eventType, channel, color } = req.body;
507
553
  const guildId = req.params.guildId;
508
554
 
509
555
  try {
510
556
  const updateObj = {};
511
-
557
+
512
558
  if (channel) {
513
559
  updateObj[`channels.${eventType}`] = channel;
514
560
  } else {
@@ -518,7 +564,7 @@ function dashboard(client, options) {
518
564
  { $unset: { [`channels.${eventType}`]: "" } }
519
565
  );
520
566
  }
521
-
567
+
522
568
  if (color) {
523
569
  updateObj[`colors.${eventType}`] = color;
524
570
  } else {
@@ -549,7 +595,8 @@ function dashboard(client, options) {
549
595
  // API - Ų„Ų¹Ų§ŲÆŲ© ŲŖŲ¹ŁŠŁŠŁ† Ų„Ų¹ŲÆŲ§ŲÆŲ§ŲŖ السجلات
550
596
  app.post("/api/:guildId/logs/reset", isAuthenticated, async (req, res) => {
551
597
  const logData = getLogConfigData();
552
- if (!logData.databaseEnabled) return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
598
+ if (!logData.databaseEnabled)
599
+ return res.json({ error: "يجب ŲŖŁŲ¹ŁŠŁ„ وضع Database Ł„ŲŖŲ¹ŲÆŁŠŁ„ ال؄عدادات" });
553
600
 
554
601
  const guildId = req.params.guildId;
555
602
 
@@ -565,52 +612,60 @@ function dashboard(client, options) {
565
612
 
566
613
  // ==================== نظام Ų§Ł„ŲØŁ„Ų§Łƒ Ł„ŁŠŲ³ŲŖ ====================
567
614
  // API ل؄ضافة Ł„Ł„ŲØŁ„Ų§Łƒ Ł„ŁŠŲ³ŲŖ
568
- app.post("/api/guild/:guildId/blacklist", isAuthenticated, async (req, res) => {
569
- const { type, id } = req.body;
570
- const guildId = req.params.guildId;
615
+ app.post(
616
+ "/api/guild/:guildId/blacklist",
617
+ isAuthenticated,
618
+ async (req, res) => {
619
+ const { type, id } = req.body;
620
+ const guildId = req.params.guildId;
571
621
 
572
- try {
573
- if (addToBlacklist) {
574
- const result = await addToBlacklist(guildId, type, id);
575
- return res.json({ success: result });
576
- } else if (Blacklist) {
577
- const exists = await Blacklist.findOne({ guild: guildId, type, id });
578
- if (!exists) {
579
- await Blacklist.create({ guild: guildId, type, id });
622
+ try {
623
+ if (addToBlacklist) {
624
+ const result = await addToBlacklist(guildId, type, id);
625
+ return res.json({ success: result });
626
+ } else if (Blacklist) {
627
+ const exists = await Blacklist.findOne({ guild: guildId, type, id });
628
+ if (!exists) {
629
+ await Blacklist.create({ guild: guildId, type, id });
630
+ }
631
+ return res.json({ success: true });
580
632
  }
581
- return res.json({ success: true });
633
+ res.json({ error: "Blacklist system not available" });
634
+ } catch (e) {
635
+ res.json({ success: false, error: e.message });
582
636
  }
583
- res.json({ error: "Blacklist system not available" });
584
- } catch (e) {
585
- res.json({ success: false, error: e.message });
586
637
  }
587
- });
638
+ );
588
639
 
589
640
  // API لحذف من Ų§Ł„ŲØŁ„Ų§Łƒ Ł„ŁŠŲ³ŲŖ
590
- app.delete("/api/guild/:guildId/blacklist", isAuthenticated, async (req, res) => {
591
- const { type, id } = req.body;
592
- const guildId = req.params.guildId;
641
+ app.delete(
642
+ "/api/guild/:guildId/blacklist",
643
+ isAuthenticated,
644
+ async (req, res) => {
645
+ const { type, id } = req.body;
646
+ const guildId = req.params.guildId;
593
647
 
594
- try {
595
- if (removeFromBlacklist) {
596
- const result = await removeFromBlacklist(guildId, type, id);
597
- return res.json({ success: result });
598
- } else if (Blacklist) {
599
- await Blacklist.deleteOne({ guild: guildId, type, id });
600
- return res.json({ success: true });
648
+ try {
649
+ if (removeFromBlacklist) {
650
+ const result = await removeFromBlacklist(guildId, type, id);
651
+ return res.json({ success: result });
652
+ } else if (Blacklist) {
653
+ await Blacklist.deleteOne({ guild: guildId, type, id });
654
+ return res.json({ success: true });
655
+ }
656
+ res.json({ error: "Blacklist system not available" });
657
+ } catch (e) {
658
+ res.json({ success: false, error: e.message });
601
659
  }
602
- res.json({ error: "Blacklist system not available" });
603
- } catch (e) {
604
- res.json({ success: false, error: e.message });
605
660
  }
606
- });
661
+ );
607
662
 
608
663
  // ==================== API القائمة Ų§Ł„Ų³ŁˆŲÆŲ§Ų” العامة ====================
609
664
  app.get("/api/blacklist/:type", isAuthenticated, async (req, res) => {
610
665
  const { type } = req.params;
611
666
  try {
612
667
  if (Blacklist) {
613
- const typeMap = { users: 'user', roles: 'role', channels: 'channel' };
668
+ const typeMap = { users: "user", roles: "role", channels: "channel" };
614
669
  const items = await Blacklist.find({ type: typeMap[type] || type });
615
670
  return res.json({ items });
616
671
  }
@@ -626,7 +681,7 @@ function dashboard(client, options) {
626
681
  if (Blacklist) {
627
682
  const exists = await Blacklist.findOne({ type, id });
628
683
  if (!exists) {
629
- await Blacklist.create({ type, id, guild: 'global' });
684
+ await Blacklist.create({ type, id, guild: "global" });
630
685
  }
631
686
  return res.json({ success: true });
632
687
  }
@@ -652,14 +707,16 @@ function dashboard(client, options) {
652
707
  // API لجلب ŲØŁŠŲ§Ł†Ų§ŲŖ Ł…Ų³ŲŖŲ®ŲÆŁ… (Ų¹Ų§Ł…)
653
708
  app.get("/api/user/:userId", isAuthenticated, async (req, res) => {
654
709
  try {
655
- const user = await client.users.fetch(req.params.userId).catch(() => null);
710
+ const user = await client.users
711
+ .fetch(req.params.userId)
712
+ .catch(() => null);
656
713
  if (user) {
657
714
  return res.json({
658
715
  id: user.id,
659
716
  username: user.username,
660
717
  global_name: user.globalName,
661
718
  avatar: user.avatar,
662
- discriminator: user.discriminator
719
+ discriminator: user.discriminator,
663
720
  });
664
721
  }
665
722
  res.json({ error: "User not found" });
@@ -675,7 +732,9 @@ function dashboard(client, options) {
675
732
  if (!guild) return res.json({ error: "Guild not found" });
676
733
 
677
734
  try {
678
- const member = await guild.members.fetch(req.params.userId).catch(() => null);
735
+ const member = await guild.members
736
+ .fetch(req.params.userId)
737
+ .catch(() => null);
679
738
  if (member) {
680
739
  return res.json({
681
740
  user: {
@@ -683,9 +742,9 @@ function dashboard(client, options) {
683
742
  username: member.user.username,
684
743
  global_name: member.user.globalName,
685
744
  avatar: member.user.avatar,
686
- discriminator: member.user.discriminator
745
+ discriminator: member.user.discriminator,
687
746
  },
688
- displayName: member.displayName
747
+ displayName: member.displayName,
689
748
  });
690
749
  }
691
750
  res.json({ error: "Member not found" });
@@ -699,26 +758,27 @@ function dashboard(client, options) {
699
758
  const guild = client.guilds.cache.get(req.params.guildId);
700
759
  if (!guild) return res.json({ members: [] });
701
760
 
702
- const query = (req.query.q || '').toLowerCase();
761
+ const query = (req.query.q || "").toLowerCase();
703
762
  if (query.length < 2) return res.json({ members: [] });
704
763
 
705
764
  try {
706
765
  // جلب الأعضاؔ من Ų§Ł„ŁƒŲ§Ų“
707
766
  const members = guild.members.cache
708
- .filter(m =>
709
- m.user.username.toLowerCase().includes(query) ||
710
- m.displayName.toLowerCase().includes(query) ||
711
- m.user.id.includes(query)
767
+ .filter(
768
+ (m) =>
769
+ m.user.username.toLowerCase().includes(query) ||
770
+ m.displayName.toLowerCase().includes(query) ||
771
+ m.user.id.includes(query)
712
772
  )
713
773
  .first(20)
714
- .map(m => ({
774
+ .map((m) => ({
715
775
  id: m.user.id,
716
776
  username: m.user.username,
717
777
  displayName: m.displayName,
718
778
  avatar: m.user.avatar,
719
- discriminator: m.user.discriminator
779
+ discriminator: m.user.discriminator,
720
780
  }));
721
-
781
+
722
782
  res.json({ members });
723
783
  } catch (e) {
724
784
  res.json({ members: [], error: e.message });
@@ -759,7 +819,14 @@ function dashboard(client, options) {
759
819
  if (level > 0) existing.level = level;
760
820
  await existing.save();
761
821
  } else {
762
- await Level.create({ guildId, userId, totalXP: xp, level: level || 0, text: 0, voice: 0 });
822
+ await Level.create({
823
+ guildId,
824
+ userId,
825
+ totalXP: xp,
826
+ level: level || 0,
827
+ text: 0,
828
+ voice: 0,
829
+ });
763
830
  }
764
831
  return res.json({ success: true });
765
832
  }
@@ -801,8 +868,13 @@ function dashboard(client, options) {
801
868
 
802
869
  try {
803
870
  if (Level) levelCount = await Level.countDocuments({ guildId: guild.id });
804
- if (giveaway) giveawayCount = await giveaway.countDocuments({ guildId: guild.id, ended: false });
805
- if (Blacklist) blacklistCount = await Blacklist.countDocuments({ guild: guild.id });
871
+ if (giveaway)
872
+ giveawayCount = await giveaway.countDocuments({
873
+ guildId: guild.id,
874
+ ended: false,
875
+ });
876
+ if (Blacklist)
877
+ blacklistCount = await Blacklist.countDocuments({ guild: guild.id });
806
878
  } catch (e) {
807
879
  console.error("Stats error:", e);
808
880
  }
@@ -824,7 +896,7 @@ function dashboard(client, options) {
824
896
  });
825
897
 
826
898
  // ŲŖŲ“ŲŗŁŠŁ„ الخادم
827
- app.listen( port, () => {});
899
+ app.listen(port, () => {});
828
900
 
829
901
  return app;
830
902
  }
@@ -490,7 +490,7 @@ async function CreateComponents(type, components) {
490
490
  selectMenu.addOptions(selectOptions);
491
491
  }
492
492
 
493
- if (type === "channel" && Array.isArray(channelTypes)) {
493
+ if (menu_type === "channel" && Array.isArray(channelTypes)) {
494
494
  selectMenu.setChannelTypes(channelTypes);
495
495
  }
496
496
 
@@ -503,7 +503,7 @@ async function CreateComponents(type, components) {
503
503
  if (type === "container") {
504
504
  result.addActionRowComponents(menu);
505
505
  } else {
506
- result.push(selectMenu);
506
+ result.push(menu);
507
507
  }
508
508
  } else if (item.type === "section") {
509
509
  const section = new SectionBuilder();
package/handler/helper.js CHANGED
@@ -6,7 +6,6 @@ const fs = require("fs");
6
6
  const axios = require("axios");
7
7
  const { dashboard } = require("../function/dash");
8
8
 
9
-
10
9
  async function cooldowns(client, name, time, user) {
11
10
  const cooldownKey = `${name}_${user.id}`;
12
11
  const now = Date.now();
@@ -92,7 +91,7 @@ async function terminalInfo(client, options, data) {
92
91
  [rowColors[5]("Slash Commands"), rowColors[5](data.slash)],
93
92
  [rowColors[6]("Total Commands"), rowColors[6](data.slash + data.prefix)],
94
93
  [rowColors[7]("Events"), rowColors[7](data.events)],
95
- [rowColors[8]("Started At"), rowColors[8](new Date().toLocaleString())]
94
+ [rowColors[8]("Started At"), rowColors[8](new Date().toLocaleString())],
96
95
  );
97
96
 
98
97
  secondTable.push(
@@ -100,7 +99,7 @@ async function terminalInfo(client, options, data) {
100
99
  [
101
100
  rowColors[1]("Bot Invite"),
102
101
  rowColors[1](
103
- `https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=8&integration_type=0&scope=bot`
102
+ `https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=8&integration_type=0&scope=bot`,
104
103
  ),
105
104
  ],
106
105
  [
@@ -114,9 +113,9 @@ async function terminalInfo(client, options, data) {
114
113
  ? Array.isArray(options.Status.activities)
115
114
  ? options.Status.activities[0]
116
115
  : options.Status.activities
117
- : "Not Defined"
116
+ : "Not Defined",
118
117
  ),
119
- ]
118
+ ],
120
119
  );
121
120
 
122
121
  if (options.database?.url) {
@@ -126,26 +125,22 @@ async function terminalInfo(client, options, data) {
126
125
  }
127
126
  }
128
127
 
129
- let dashTable
128
+ let dashTable;
130
129
  if (options.dashboard) {
131
-
132
- await dashboard(client, options.dashboard);
130
+ await dashboard(client, options.dashboard);
133
131
  const port = options.dashboard?.port || 3000;
134
- dashTable = new Table({
132
+ dashTable = new Table({
135
133
  head: [chalk.bold.cyan("🌐 Dashboard"), chalk.bold.green("šŸ“Œ Value")],
136
134
  colWidths: [25, 45],
137
135
  });
138
136
 
139
-
140
137
  dashTable.push(
141
138
  [rowColors[0]("Status"), rowColors[0]("āœ… Online")],
142
139
  [rowColors[1]("URL"), rowColors[1](`http://localhost:${port}`)],
143
140
  [rowColors[2]("Port"), rowColors[2](port)],
144
- [rowColors[3]("Version"), rowColors[3]("v2.0.0")]
141
+ [rowColors[3]("Version"), rowColors[3]("v2.0.0")],
145
142
  );
146
-
147
- }
148
-
143
+ }
149
144
 
150
145
  console.log(chalk.bold.green("\nāœ… Bot Information:\n"));
151
146
  console.log(firstTable.toString());
@@ -154,18 +149,19 @@ async function terminalInfo(client, options, data) {
154
149
  console.log(secondTable.toString());
155
150
 
156
151
  if (options.dashboard) {
157
- console.log(chalk.bold.cyan("\n🌐 Dashboard Information:\n"));
152
+ console.log(chalk.bold.cyan("\n🌐 Dashboard Information:\n"));
158
153
  console.log(dashTable.toString());
159
154
  }
160
-
161
-
162
-
163
155
  }
164
156
 
165
- async function data_conecter(url) {
157
+ async function data_conecter(options) {
166
158
  try {
167
159
  const mongoose = require("mongoose");
168
- await mongoose.connect(url);
160
+ const connectOptions = {};
161
+ if (options.dbName) {
162
+ connectOptions.dbName = options.dbName;
163
+ }
164
+ await mongoose.connect(options.url, connectOptions);
169
165
  return true;
170
166
  } catch (error) {
171
167
  console.error("āŒ Failed to connect to the database:", error);
@@ -222,8 +218,6 @@ async function set_anticrash(data) {
222
218
  process.on("warning", (error) => send(error, "warn"));
223
219
  }
224
220
 
225
-
226
-
227
221
  async function cmd_log(client, data, commandName, channelId) {
228
222
  const isSlash = !!data.user;
229
223
  const user = isSlash ? data.user : data.author;
@@ -231,12 +225,10 @@ async function cmd_log(client, data, commandName, channelId) {
231
225
  const logChannel = client.channels.cache.get(channelId);
232
226
  if (!logChannel) return;
233
227
 
234
-
235
228
  let messageLink = "Unknown";
236
229
  try {
237
230
  if (isSlash) {
238
-
239
- const reply = await data.fetchReply()
231
+ const reply = await data.fetchReply();
240
232
  if (reply) {
241
233
  messageLink = `https://discord.com/channels/${data.guild.id}/${data.channel.id}/${reply.id}`;
242
234
  }
@@ -276,9 +268,10 @@ async function cmd_log(client, data, commandName, channelId) {
276
268
  { name: "\u200B", value: "\u200B", inline: true },
277
269
  {
278
270
  name: "šŸ”— Message:",
279
- value: messageLink !== "Unknown" ? `- [Link](${messageLink})` : "Not found",
271
+ value:
272
+ messageLink !== "Unknown" ? `- [Link](${messageLink})` : "Not found",
280
273
  inline: true,
281
- }
274
+ },
282
275
  );
283
276
  } else {
284
277
  fields.push({
@@ -288,7 +281,6 @@ async function cmd_log(client, data, commandName, channelId) {
288
281
  });
289
282
  }
290
283
 
291
-
292
284
  if (!isSlash && data.content) {
293
285
  fields.push({
294
286
  name: "šŸ“ Content:",
@@ -301,7 +293,6 @@ async function cmd_log(client, data, commandName, channelId) {
301
293
  value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
302
294
  });
303
295
 
304
-
305
296
  const embed = new EmbedBuilder()
306
297
  .setTitle(isSlash ? "šŸ“˜ Slash Command Log" : "šŸ“— Prefix Command Log")
307
298
  .setColor(isSlash ? "Blue" : "Green")
@@ -311,7 +302,10 @@ async function cmd_log(client, data, commandName, channelId) {
311
302
  name: `${user?.tag ?? "Unknown user"} || ${user?.username ?? "Unknown"}`,
312
303
  iconURL: user?.displayAvatarURL({ dynamic: true }),
313
304
  })
314
- .setFooter({ text: "Command Logger", iconURL: client.user.displayAvatarURL() })
305
+ .setFooter({
306
+ text: "Command Logger",
307
+ iconURL: client.user.displayAvatarURL(),
308
+ })
315
309
  .setTimestamp();
316
310
 
317
311
  try {
@@ -321,21 +315,17 @@ async function cmd_log(client, data, commandName, channelId) {
321
315
  }
322
316
  }
323
317
 
324
-
325
-
326
-
327
318
  //////////////////////////////////* Check update šŸ”¼
328
319
 
329
320
  async function update(client, id, webhookURL) {
330
321
  const { version, note: localNote } = require("../package.json");
331
322
 
332
323
  const { data } = await axios.get(
333
- `https://registry.npmjs.org/djs-builder/latest`
324
+ `https://registry.npmjs.org/djs-builder/latest`,
334
325
  );
335
326
  const new_version = data.version;
336
327
  const note = data.note || "";
337
328
 
338
-
339
329
  if (
340
330
  client.djs_builder_version &&
341
331
  client.djs_builder_version === new_version
@@ -346,8 +336,8 @@ async function update(client, id, webhookURL) {
346
336
  if (new_version !== version) {
347
337
  console.log(
348
338
  chalk.yellow(
349
- `āš ļø New version available: ${new_version} (Your version: ${version})`
350
- )
339
+ `āš ļø New version available: ${new_version} (Your version: ${version})`,
340
+ ),
351
341
  );
352
342
 
353
343
  const crash = new WebhookClient({ url: webhookURL });
@@ -355,7 +345,7 @@ async function update(client, id, webhookURL) {
355
345
  const embed = new EmbedBuilder()
356
346
  .setTitle("šŸŽ‰ New version available")
357
347
  .setDescription(
358
- `${note}\n\n**Your version:** ${version} ā°\n**New version:** ${new_version} šŸš€\n- Try running \`npm i djs-builder@latest\` to update. ā¤`
348
+ `${note}\n\n**Your version:** ${version} ā°\n**New version:** ${new_version} šŸš€\n- Try running \`npm i djs-builder@latest\` to update. ā¤`,
359
349
  )
360
350
  .setColor("Yellow")
361
351
  .setTimestamp();
@@ -86,7 +86,7 @@ async function loadEvents(client, path) {
86
86
  for (const file of event_files) {
87
87
  const event = require(file.path);
88
88
 
89
- if (!event.name || typeof event.run !== "function") continue;
89
+ if (!event.name || (typeof event.run !== "function" && typeof event.execute !== "function")) continue;
90
90
 
91
91
  let listener;
92
92
  if (event.once) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "djs-builder",
3
- "version": "0.7.5",
4
- "note": "šŸŽ‰ Package Update v0.7.5! \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)",
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)",
5
5
  "description": "šŸŽ‰ Full-featured Discord.js utilities: CreateComponents, CreateModal, Dashboard, Logging & more! šŸ„",
6
6
  "main": "handler/starter.js",
7
7
  "dependencies": {