djs-builder 0.7.0 → 0.7.1-8.1

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/handler/helper.js CHANGED
@@ -4,6 +4,7 @@ const chalk = require("chalk");
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
6
  const axios = require("axios");
7
+ const { dashboard } = require("../function/dash");
7
8
 
8
9
  async function cooldowns(client, name, time, user) {
9
10
  const cooldownKey = `${name}_${user.id}`;
@@ -90,7 +91,7 @@ async function terminalInfo(client, options, data) {
90
91
  [rowColors[5]("Slash Commands"), rowColors[5](data.slash)],
91
92
  [rowColors[6]("Total Commands"), rowColors[6](data.slash + data.prefix)],
92
93
  [rowColors[7]("Events"), rowColors[7](data.events)],
93
- [rowColors[8]("Started At"), rowColors[8](new Date().toLocaleString())]
94
+ [rowColors[8]("Started At"), rowColors[8](new Date().toLocaleString())],
94
95
  );
95
96
 
96
97
  secondTable.push(
@@ -98,7 +99,7 @@ async function terminalInfo(client, options, data) {
98
99
  [
99
100
  rowColors[1]("Bot Invite"),
100
101
  rowColors[1](
101
- `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`,
102
103
  ),
103
104
  ],
104
105
  [
@@ -112,29 +113,55 @@ async function terminalInfo(client, options, data) {
112
113
  ? Array.isArray(options.Status.activities)
113
114
  ? options.Status.activities[0]
114
115
  : options.Status.activities
115
- : "Not Defined"
116
+ : "Not Defined",
116
117
  ),
117
- ]
118
+ ],
118
119
  );
119
120
 
120
121
  if (options.database?.url) {
121
- const result = await data_conecter(options.database.url);
122
+ const result = await data_conecter(options.database);
122
123
  if (result) {
123
124
  secondTable.push([chalk.cyan("Database"), rowColors[9]("Connected")]);
124
125
  }
125
126
  }
126
127
 
128
+ let dashTable;
129
+ if (options.dashboard) {
130
+ await dashboard(client, options.dashboard);
131
+ const port = options.dashboard?.port || 3000;
132
+ dashTable = new Table({
133
+ head: [chalk.bold.cyan("🌐 Dashboard"), chalk.bold.green("📌 Value")],
134
+ colWidths: [25, 45],
135
+ });
136
+
137
+ dashTable.push(
138
+ [rowColors[0]("Status"), rowColors[0]("✅ Online")],
139
+ [rowColors[1]("URL"), rowColors[1](`http://localhost:${port}`)],
140
+ [rowColors[2]("Port"), rowColors[2](port)],
141
+ [rowColors[3]("Version"), rowColors[3]("v2.0.0")],
142
+ );
143
+ }
144
+
127
145
  console.log(chalk.bold.green("\n✅ Bot Information:\n"));
128
146
  console.log(firstTable.toString());
129
147
 
130
148
  console.log(chalk.bold.blue("\n⚙️ Developer Settings:\n"));
131
149
  console.log(secondTable.toString());
150
+
151
+ if (options.dashboard) {
152
+ console.log(chalk.bold.cyan("\n🌐 Dashboard Information:\n"));
153
+ console.log(dashTable.toString());
154
+ }
132
155
  }
133
156
 
134
- async function data_conecter(url) {
157
+ async function data_conecter(options) {
135
158
  try {
136
159
  const mongoose = require("mongoose");
137
- await mongoose.connect(url);
160
+ const connectOptions = {};
161
+ if (options.dbName) {
162
+ connectOptions.dbName = options.dbName;
163
+ }
164
+ await mongoose.connect(options.url, connectOptions);
138
165
  return true;
139
166
  } catch (error) {
140
167
  console.error("❌ Failed to connect to the database:", error);
@@ -191,8 +218,6 @@ async function set_anticrash(data) {
191
218
  process.on("warning", (error) => send(error, "warn"));
192
219
  }
193
220
 
194
-
195
-
196
221
  async function cmd_log(client, data, commandName, channelId) {
197
222
  const isSlash = !!data.user;
198
223
  const user = isSlash ? data.user : data.author;
@@ -200,12 +225,10 @@ async function cmd_log(client, data, commandName, channelId) {
200
225
  const logChannel = client.channels.cache.get(channelId);
201
226
  if (!logChannel) return;
202
227
 
203
-
204
228
  let messageLink = "Unknown";
205
229
  try {
206
230
  if (isSlash) {
207
-
208
- const reply = await data.fetchReply()
231
+ const reply = await data.fetchReply();
209
232
  if (reply) {
210
233
  messageLink = `https://discord.com/channels/${data.guild.id}/${data.channel.id}/${reply.id}`;
211
234
  }
@@ -245,9 +268,10 @@ async function cmd_log(client, data, commandName, channelId) {
245
268
  { name: "\u200B", value: "\u200B", inline: true },
246
269
  {
247
270
  name: "🔗 Message:",
248
- value: messageLink !== "Unknown" ? `- [Link](${messageLink})` : "Not found",
271
+ value:
272
+ messageLink !== "Unknown" ? `- [Link](${messageLink})` : "Not found",
249
273
  inline: true,
250
- }
274
+ },
251
275
  );
252
276
  } else {
253
277
  fields.push({
@@ -257,7 +281,6 @@ async function cmd_log(client, data, commandName, channelId) {
257
281
  });
258
282
  }
259
283
 
260
-
261
284
  if (!isSlash && data.content) {
262
285
  fields.push({
263
286
  name: "📝 Content:",
@@ -270,7 +293,6 @@ async function cmd_log(client, data, commandName, channelId) {
270
293
  value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
271
294
  });
272
295
 
273
-
274
296
  const embed = new EmbedBuilder()
275
297
  .setTitle(isSlash ? "📘 Slash Command Log" : "📗 Prefix Command Log")
276
298
  .setColor(isSlash ? "Blue" : "Green")
@@ -280,7 +302,10 @@ async function cmd_log(client, data, commandName, channelId) {
280
302
  name: `${user?.tag ?? "Unknown user"} || ${user?.username ?? "Unknown"}`,
281
303
  iconURL: user?.displayAvatarURL({ dynamic: true }),
282
304
  })
283
- .setFooter({ text: "Command Logger", iconURL: client.user.displayAvatarURL() })
305
+ .setFooter({
306
+ text: "Command Logger",
307
+ iconURL: client.user.displayAvatarURL(),
308
+ })
284
309
  .setTimestamp();
285
310
 
286
311
  try {
@@ -290,21 +315,17 @@ async function cmd_log(client, data, commandName, channelId) {
290
315
  }
291
316
  }
292
317
 
293
-
294
-
295
-
296
318
  //////////////////////////////////* Check update 🔼
297
319
 
298
320
  async function update(client, id, webhookURL) {
299
321
  const { version, note: localNote } = require("../package.json");
300
322
 
301
323
  const { data } = await axios.get(
302
- `https://registry.npmjs.org/djs-builder/latest`
324
+ `https://registry.npmjs.org/djs-builder/latest`,
303
325
  );
304
326
  const new_version = data.version;
305
327
  const note = data.note || "";
306
328
 
307
-
308
329
  if (
309
330
  client.djs_builder_version &&
310
331
  client.djs_builder_version === new_version
@@ -315,8 +336,8 @@ async function update(client, id, webhookURL) {
315
336
  if (new_version !== version) {
316
337
  console.log(
317
338
  chalk.yellow(
318
- `⚠️ New version available: ${new_version} (Your version: ${version})`
319
- )
339
+ `⚠️ New version available: ${new_version} (Your version: ${version})`,
340
+ ),
320
341
  );
321
342
 
322
343
  const crash = new WebhookClient({ url: webhookURL });
@@ -324,7 +345,7 @@ async function update(client, id, webhookURL) {
324
345
  const embed = new EmbedBuilder()
325
346
  .setTitle("🎉 New version available")
326
347
  .setDescription(
327
- `${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. ❤`,
328
349
  )
329
350
  .setColor("Yellow")
330
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) {
@@ -150,17 +150,17 @@ async function starter(client, options) {
150
150
  const events = options.events || null;
151
151
  const anticrash = options.anticrash || null;
152
152
  const terminal = options.terminal || null;
153
- const dashboard = options.dashboard || null;
153
+
154
+
154
155
 
155
- //////////////////////////////////////////? Dashboard Loader ////////////////////////////////////////////////////////
156
- if (dashboard) {
157
- await dashboard(client, dashboard);
158
- }
159
156
  //////////////////////////////////////////! terminal info !////////////////////////////////////////////////////////
160
157
  if (terminal) {
161
158
  console.log("🚀 Bot is starting...");
162
159
  }
163
160
 
161
+
162
+
163
+
164
164
  //////////////////////////////////////////* status set !////////////////////////////////////////////////////////
165
165
  client.login(token);
166
166
  client.once("clientReady", () => {
@@ -513,10 +513,28 @@ async function starter(client, options) {
513
513
  }, 1000 * 60 * 60);
514
514
  }
515
515
 
516
- const { Wait, CreateBar, CreateRow, GetUser } = require("../function/function");
517
- const { Level, addXP, UserLevel, leaderboard } = require("../function/level");
518
- const { log } = require("../function/log");
516
+ const { Wait, CreateBar, CreateRow, GetUser , CreateModal, CreateComponents } = require("../function/function");
517
+ const {
518
+ Level,
519
+ levelGuild,
520
+ addXP,
521
+ UserLevel,
522
+ leaderboard,
523
+ getUserRank,
524
+ resetUser,
525
+ resetGuild,
526
+ xpNeeded,
527
+ calculateLevel,
528
+ getLevelInfo,
529
+ getGuildConfig,
530
+ updateGuildConfig,
531
+ deleteGuildConfig,
532
+ clearConfigCache,
533
+ setLevel
534
+ } = require("../function/level");
535
+ const { log , Log , getLogConfigData} = require("../function/log");
519
536
  const { dashboard } = require("../function/dash");
537
+
520
538
  const {
521
539
  Blacklist,
522
540
  isBlacklisted,
@@ -541,19 +559,35 @@ const {
541
559
  } = require("../function/giveaway");
542
560
 
543
561
  module.exports = {
544
- Level,
562
+ Level,
563
+ levelGuild,
564
+ addXP,
565
+ UserLevel,
566
+ leaderboard,
567
+ getUserRank,
568
+ resetUser,
569
+ resetGuild,
570
+ xpNeeded,
571
+ calculateLevel,
572
+ getLevelInfo,
573
+ getGuildConfig,
574
+ updateGuildConfig,
575
+ deleteGuildConfig,
576
+ clearConfigCache,
577
+ setLevel,
545
578
  giveaway,
546
579
  starter,
547
580
  dashboard,
548
581
  reload,
549
582
  log,
583
+ Log,
584
+ getLogConfigData,
550
585
  Wait,
551
586
  CreateBar,
552
587
  CreateRow,
588
+ CreateModal,
589
+ CreateComponents,
553
590
  GetUser,
554
- addXP,
555
- UserLevel,
556
- leaderboard,
557
591
  Gstart,
558
592
  Gcheck,
559
593
  Greroll,
package/package.json CHANGED
@@ -1,20 +1,34 @@
1
1
  {
2
2
  "name": "djs-builder",
3
- "version": "0.7.0",
4
- "note": "🎉 Package Update! 🥏\n\n- 🌐 NEW: Dashboard System - Modern web-based control panel!\n • Discord OAuth2 Login\n • Server Management\n • Level System Control\n • Giveaway Management\n • Blacklist Management\n- Documentation: Full Dashboard guide added to README.\n- Standalone Usage: Use Dashboard with or without Starter!\n\n🔗 Learn more on [NPM](https://www.npmjs.com/package/djs-builder)",
5
- "description": "🎉 NEW: Dashboard System - Web Control Panel! 🌐",
3
+ "version": "0.7.18.1",
4
+ "note": "🎉 Package Update v0.7.18.1! \n\n- 🎮 NEW: setLevel Function!\n • All-in-one level system setup\n • Automatic message listener\n • Callbacks: onLevelUp, onRoleReward, onXP\n • Dashboard Mode & Code Mode support\n • Auto role rewards on level up\n • Voice XP support via addVoiceXP\n\n- 📊 Level System Improvements!\n • getGuildConfig with full output example\n • updateGuildConfig for programmatic changes\n XP Calculation Types: line, exponential, balanced, custom\n • Cooldown & Blacklist support\n\n- 🌐 Dashboard System!\n • Discord OAuth2 Login\n • Server, Level, Giveaway & Blacklist Management\n • Logs Management Page\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
+ "description": "🎉 Full-featured Discord.js utilities: CreateComponents, CreateModal, Dashboard, Logging & more! 🥏",
6
6
  "main": "handler/starter.js",
7
+ "author": "Abdullah",
8
+ "keywords": [
9
+ "discord.js",
10
+ "discord-bot",
11
+ "dashboard",
12
+ "utility",
13
+ "handler",
14
+ "djs-builder"
15
+ ],
7
16
  "dependencies": {
8
- "axios": "^1.11.0",
17
+ "axios": "^1.14.0",
9
18
  "chalk": "^4.1.2",
10
19
  "cli-table3": "^0.6.5",
11
20
  "discord-inviter": "^0.9.3",
12
- "discord.js": "^14.21.0",
21
+ "ejs": "^3.1.9",
22
+ "lodash": "^4.17.23"
23
+ },
24
+ "peerDependencies": {
25
+ "discord.js": "^14.0.0"
26
+ },
27
+ "optionalDependencies": {
28
+ "express": "^4.19.2",
29
+ "express-session": "^1.18.0",
13
30
  "mongoose": "^8.18.0",
14
- "express": "^4.18.2",
15
- "express-session": "^1.17.3",
16
31
  "passport": "^0.7.0",
17
- "passport-discord": "^0.1.4",
18
- "ejs": "^3.1.9"
32
+ "passport-discord": "^0.1.4"
19
33
  }
20
34
  }
@@ -725,6 +725,23 @@
725
725
  </div>
726
726
  </div>
727
727
 
728
+ <!-- Confirm Modal -->
729
+ <div class="modal" id="confirmModal">
730
+ <div class="modal-content" style="max-width: 400px;">
731
+ <div class="modal-header">
732
+ <h3 id="confirmTitle"><i class="ri-question-line" style="color: var(--warning);"></i> تأكيد</h3>
733
+ <button class="modal-close" onclick="closeConfirmModal()">&times;</button>
734
+ </div>
735
+ <div class="modal-body">
736
+ <p id="confirmMessage" style="font-size: 15px; text-align: center; padding: 10px 0;"></p>
737
+ </div>
738
+ <div class="modal-footer" style="justify-content: center;">
739
+ <button class="btn btn-secondary" onclick="closeConfirmModal()">إلغاء</button>
740
+ <button class="btn btn-primary" id="confirmBtn" style="background: var(--danger);"><i class="ri-check-line"></i> تأكيد</button>
741
+ </div>
742
+ </div>
743
+ </div>
744
+
728
745
  <div class="toast" id="toast"><i class="ri-checkbox-circle-fill"></i><span id="toastText"></span></div>
729
746
 
730
747
  <script>
@@ -766,6 +783,23 @@
766
783
  setTimeout(() => toast.classList.remove('show'), 3000);
767
784
  }
768
785
 
786
+ // Confirm Modal Functions
787
+ let confirmCallback = null;
788
+ function showConfirm(message, callback, title = 'تأكيد') {
789
+ document.getElementById('confirmMessage').textContent = message;
790
+ document.getElementById('confirmTitle').innerHTML = '<i class="ri-question-line" style="color: var(--warning);"></i> ' + title;
791
+ confirmCallback = callback;
792
+ document.getElementById('confirmModal').classList.add('show');
793
+ }
794
+ function closeConfirmModal() {
795
+ document.getElementById('confirmModal').classList.remove('show');
796
+ confirmCallback = null;
797
+ }
798
+ document.getElementById('confirmBtn').addEventListener('click', function() {
799
+ if (confirmCallback) confirmCallback();
800
+ closeConfirmModal();
801
+ });
802
+
769
803
  // Modal functions
770
804
  function selectBlType(type) {
771
805
  document.querySelectorAll('.type-btn').forEach(btn => {
@@ -867,24 +901,24 @@
867
901
  } catch (e) { showToast('حدث خطأ', 'error'); }
868
902
  }
869
903
 
870
- async function removeFromGlobalBlacklist(type, id) {
871
- if (!confirm('هل أنت متأكد من الإزالة؟')) return;
872
-
873
- try {
874
- const res = await fetch('/api/blacklist', {
875
- method: 'DELETE',
876
- headers: { 'Content-Type': 'application/json' },
877
- body: JSON.stringify({ type, id })
878
- });
879
- const data = await res.json();
880
-
881
- if (data.success) {
882
- showToast('تمت الإزالة بنجاح');
883
- document.querySelector(`.bl-item[data-id="${id}"]`).remove();
884
- } else {
885
- showToast(data.error || 'خطأ', 'error');
886
- }
887
- } catch (e) { showToast('خطأ', 'error'); }
904
+ function removeFromGlobalBlacklist(type, id) {
905
+ showConfirm('هل أنت متأكد من الإزالة؟', async () => {
906
+ try {
907
+ const res = await fetch('/api/blacklist', {
908
+ method: 'DELETE',
909
+ headers: { 'Content-Type': 'application/json' },
910
+ body: JSON.stringify({ type, id })
911
+ });
912
+ const data = await res.json();
913
+
914
+ if (data.success) {
915
+ showToast('تمت الإزالة بنجاح');
916
+ document.querySelector(`.bl-item[data-id="${id}"]`).remove();
917
+ } else {
918
+ showToast(data.error || 'خطأ', 'error');
919
+ }
920
+ } catch (e) { showToast('خطأ', 'error'); }
921
+ }, 'إزالة');
888
922
  }
889
923
 
890
924
  // Load blacklist on init
@@ -189,6 +189,7 @@
189
189
  <div class="nav-section"><div class="nav-section-title">الميزات</div>
190
190
  <a href="/dashboard/<%= guild.id %>/levels" class="nav-link"><i class="ri-bar-chart-grouped-line"></i><span>نظام المستويات</span></a>
191
191
  <a href="/dashboard/<%= guild.id %>/giveaways" class="nav-link active"><i class="ri-gift-2-line"></i><span>الهدايا</span></a>
192
+ <a href="/dashboard/<%= guild.id %>/logs" class="nav-link"><i class="ri-shield-check-line"></i><span>سجلات المراقبة</span></a>
192
193
  </div>
193
194
  </nav>
194
195
  <div class="sidebar-footer"><a href="/dashboard" class="back-btn"><i class="ri-arrow-right-line"></i><span>العودة للوحة التحكم</span></a></div>
package/views/guild.ejs CHANGED
@@ -495,6 +495,10 @@
495
495
  <i class="ri-gift-2-line"></i>
496
496
  <span>الهدايا</span>
497
497
  </a>
498
+ <a href="/dashboard/<%= guild.id %>/logs" class="nav-link">
499
+ <i class="ri-shield-check-line"></i>
500
+ <span>سجلات المراقبة</span>
501
+ </a>
498
502
  </div>
499
503
  </nav>
500
504