djs-builder 0.7.5 → 0.7.6
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/function/dash.js +218 -146
- package/function/function.js +2 -2
- package/handler/helper.js +15 -30
- package/package.json +2 -2
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 =
|
|
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:
|
|
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)
|
|
201
|
-
|
|
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(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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(
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
{
|
|
379
|
+
{
|
|
380
|
+
name: "مغادرة عضو",
|
|
381
|
+
value: "guildMemberRemove",
|
|
382
|
+
icon: "ri-user-unfollow-line",
|
|
383
|
+
},
|
|
369
384
|
{ name: "حظر عضو", value: "guildBanAdd", icon: "ri-forbid-line" },
|
|
370
|
-
{
|
|
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
|
-
{
|
|
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
|
-
{
|
|
378
|
-
|
|
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
|
-
{
|
|
381
|
-
|
|
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
|
|
428
|
-
|
|
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)
|
|
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)
|
|
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)
|
|
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)
|
|
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(
|
|
569
|
-
|
|
570
|
-
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
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(
|
|
591
|
-
|
|
592
|
-
|
|
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
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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 ||
|
|
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(
|
|
709
|
-
m
|
|
710
|
-
|
|
711
|
-
|
|
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({
|
|
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)
|
|
805
|
-
|
|
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(
|
|
899
|
+
app.listen(port, () => {});
|
|
828
900
|
|
|
829
901
|
return app;
|
|
830
902
|
}
|
package/function/function.js
CHANGED
|
@@ -490,7 +490,7 @@ async function CreateComponents(type, components) {
|
|
|
490
490
|
selectMenu.addOptions(selectOptions);
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
if (
|
|
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(
|
|
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();
|
|
@@ -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
|
-
|
|
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
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,12 +149,9 @@ async function terminalInfo(client, options, data) {
|
|
|
154
149
|
console.log(secondTable.toString());
|
|
155
150
|
|
|
156
151
|
if (options.dashboard) {
|
|
157
|
-
|
|
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
157
|
async function data_conecter(url) {
|
|
@@ -222,8 +214,6 @@ async function set_anticrash(data) {
|
|
|
222
214
|
process.on("warning", (error) => send(error, "warn"));
|
|
223
215
|
}
|
|
224
216
|
|
|
225
|
-
|
|
226
|
-
|
|
227
217
|
async function cmd_log(client, data, commandName, channelId) {
|
|
228
218
|
const isSlash = !!data.user;
|
|
229
219
|
const user = isSlash ? data.user : data.author;
|
|
@@ -231,12 +221,10 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
231
221
|
const logChannel = client.channels.cache.get(channelId);
|
|
232
222
|
if (!logChannel) return;
|
|
233
223
|
|
|
234
|
-
|
|
235
224
|
let messageLink = "Unknown";
|
|
236
225
|
try {
|
|
237
226
|
if (isSlash) {
|
|
238
|
-
|
|
239
|
-
const reply = await data.fetchReply()
|
|
227
|
+
const reply = await data.fetchReply();
|
|
240
228
|
if (reply) {
|
|
241
229
|
messageLink = `https://discord.com/channels/${data.guild.id}/${data.channel.id}/${reply.id}`;
|
|
242
230
|
}
|
|
@@ -255,7 +243,9 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
255
243
|
},
|
|
256
244
|
{
|
|
257
245
|
name: "👤 User:",
|
|
258
|
-
value: `- ${user?.tag ?? "Unknown user"} \n- (\`${
|
|
246
|
+
value: `- ${user?.tag ?? "Unknown user"} \n- (\`${
|
|
247
|
+
user?.id ?? "Unknown ID"
|
|
248
|
+
}\`)`,
|
|
259
249
|
inline: true,
|
|
260
250
|
},
|
|
261
251
|
{ name: "\u200B", value: "\u200B", inline: true },
|
|
@@ -276,7 +266,8 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
276
266
|
{ name: "\u200B", value: "\u200B", inline: true },
|
|
277
267
|
{
|
|
278
268
|
name: "🔗 Message:",
|
|
279
|
-
value:
|
|
269
|
+
value:
|
|
270
|
+
messageLink !== "Unknown" ? `- [Link](${messageLink})` : "Not found",
|
|
280
271
|
inline: true,
|
|
281
272
|
}
|
|
282
273
|
);
|
|
@@ -288,7 +279,6 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
288
279
|
});
|
|
289
280
|
}
|
|
290
281
|
|
|
291
|
-
|
|
292
282
|
if (!isSlash && data.content) {
|
|
293
283
|
fields.push({
|
|
294
284
|
name: "📝 Content:",
|
|
@@ -301,7 +291,6 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
301
291
|
value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
|
|
302
292
|
});
|
|
303
293
|
|
|
304
|
-
|
|
305
294
|
const embed = new EmbedBuilder()
|
|
306
295
|
.setTitle(isSlash ? "📘 Slash Command Log" : "📗 Prefix Command Log")
|
|
307
296
|
.setColor(isSlash ? "Blue" : "Green")
|
|
@@ -311,7 +300,10 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
311
300
|
name: `${user?.tag ?? "Unknown user"} || ${user?.username ?? "Unknown"}`,
|
|
312
301
|
iconURL: user?.displayAvatarURL({ dynamic: true }),
|
|
313
302
|
})
|
|
314
|
-
.setFooter({
|
|
303
|
+
.setFooter({
|
|
304
|
+
text: "Command Logger",
|
|
305
|
+
iconURL: client.user.displayAvatarURL(),
|
|
306
|
+
})
|
|
315
307
|
.setTimestamp();
|
|
316
308
|
|
|
317
309
|
try {
|
|
@@ -321,9 +313,6 @@ async function cmd_log(client, data, commandName, channelId) {
|
|
|
321
313
|
}
|
|
322
314
|
}
|
|
323
315
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
316
|
//////////////////////////////////* Check update 🔼
|
|
328
317
|
|
|
329
318
|
async function update(client, id, webhookURL) {
|
|
@@ -335,7 +324,6 @@ async function update(client, id, webhookURL) {
|
|
|
335
324
|
const new_version = data.version;
|
|
336
325
|
const note = data.note || "";
|
|
337
326
|
|
|
338
|
-
|
|
339
327
|
if (
|
|
340
328
|
client.djs_builder_version &&
|
|
341
329
|
client.djs_builder_version === new_version
|
|
@@ -361,9 +349,6 @@ async function update(client, id, webhookURL) {
|
|
|
361
349
|
.setTimestamp();
|
|
362
350
|
|
|
363
351
|
await crash.send({ content: `<@${id}>`, embeds: [embed] }).catch((e) => {});
|
|
364
|
-
} else if (note && note !== localNote) {
|
|
365
|
-
console.log(chalk.cyan("📝 New note available without version change:"));
|
|
366
|
-
console.log(note);
|
|
367
352
|
}
|
|
368
353
|
|
|
369
354
|
client.djs_builder_version = new_version;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "djs-builder",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"note": "🎉 Package Update v0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
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)",
|
|
5
5
|
"description": "🎉 Full-featured Discord.js utilities: CreateComponents, CreateModal, Dashboard, Logging & more! 🥏",
|
|
6
6
|
"main": "handler/starter.js",
|
|
7
7
|
"dependencies": {
|