Skip to content

Commit e19dd03

Browse files
committed
Added ui improvements
1 parent faff9b7 commit e19dd03

52 files changed

Lines changed: 3628 additions & 6080 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/PluginManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ class PluginManager {
492492
version: plugin.manifest?.version,
493493
description: plugin.manifest?.description,
494494
requiresRestart: !!plugin.manifest?.requiresRestart,
495+
category: plugin.manifest?.category || null,
496+
npmPackage: plugin.manifest?.npmPackage || null,
495497
enabled: plugin.enabled,
496498
hotReloadEligible: plugin.hotReloadEligible,
497499
lastError: plugin.lastError,

core/adminPlugin.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
async function register(fastify, { client, db }) {
5+
const webDir = path.join(__dirname, '..', 'plugins', 'administration', 'web', 'build');
6+
7+
if (fs.existsSync(webDir)) {
8+
fastify.register(require('@fastify/static'), {
9+
root: webDir,
10+
prefix: '/dashboard/',
11+
decorateReply: false,
12+
});
13+
}
14+
15+
const requireGuildAccess = (request, reply) => {
16+
const guildId = request.params.guildId;
17+
const ownerIds = request.session.ownerIds || [];
18+
if (ownerIds.includes(request.session.user?.id)) return true;
19+
const allowed = request.session.adminGuildIds || [];
20+
if (!allowed.includes(guildId)) {
21+
reply.code(403).send({ error: 'forbidden' });
22+
return false;
23+
}
24+
return true;
25+
};
26+
27+
fastify.get('/api/guilds', async (request) => {
28+
const guildIds = request.session.adminGuildIds || [];
29+
const botGuilds = client.guilds.cache;
30+
const guilds = guildIds
31+
.filter((id) => botGuilds.has(id))
32+
.map((id) => {
33+
const g = botGuilds.get(id);
34+
return {
35+
id: g.id,
36+
name: g.name,
37+
icon: g.icon,
38+
memberCount: g.memberCount,
39+
};
40+
});
41+
return { guilds };
42+
});
43+
44+
fastify.get('/api/guild/:guildId', async (request, reply) => {
45+
if (!requireGuildAccess(request, reply)) return;
46+
const guild = client.guilds.cache.get(request.params.guildId);
47+
if (!guild) return reply.code(404).send({ error: 'Guild not found' });
48+
await db.ensureConnection();
49+
const serverConfig = await db.getServerConfig(request.params.guildId);
50+
const channels = guild.channels.cache
51+
.filter((c) => c.type === 0)
52+
.map((c) => ({ id: c.id, name: c.name }));
53+
const roles = guild.roles.cache
54+
.filter((r) => !r.managed && r.name !== '@everyone')
55+
.map((r) => ({ id: r.id, name: r.name, color: r.color }))
56+
.sort((a, b) => b.position - a.position);
57+
return {
58+
guild: {
59+
id: guild.id,
60+
name: guild.name,
61+
icon: guild.iconURL(),
62+
memberCount: guild.memberCount,
63+
},
64+
config: serverConfig.toObject(),
65+
channels,
66+
roles,
67+
};
68+
});
69+
70+
fastify.get('/api/guild/:guildId/leaderboard', async (request, reply) => {
71+
if (!requireGuildAccess(request, reply)) return;
72+
await db.ensureConnection();
73+
const limit = Number(request.query.limit) || 10;
74+
const users = await db.getTopUsers(request.params.guildId, limit);
75+
return { users };
76+
});
77+
78+
fastify.setNotFoundHandler(async (request, reply) => {
79+
if (request.url.startsWith('/api/')) {
80+
return reply.code(404).send({ error: 'Not found' });
81+
}
82+
const indexPath = path.join(webDir, 'index.html');
83+
if (fs.existsSync(indexPath)) {
84+
return reply.code(200).type('text/html').send(fs.readFileSync(indexPath));
85+
}
86+
return reply.code(404).send({ error: 'Not found' });
87+
});
88+
}
89+
90+
module.exports = { register };

core/api/server.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { WebSocketServer } = require("ws");
99
const { spawn, fork } = require("child_process");
1010
const { createLogger } = require("../logger");
1111
const { registry } = require("../pluginRegistry");
12+
const adminPlugin = require("../adminPlugin");
1213

1314
const ADMIN_PERMISSION = 0x8;
1415
const MANAGE_GUILD_PERMISSION = 0x20;
@@ -401,6 +402,8 @@ async function startApiServer({ client, db, pluginManager, hooks, startListening
401402
};
402403
});
403404

405+
await adminPlugin.register(fastify, { client, db });
406+
404407
fastify.addHook("preHandler", async (request, reply) => {
405408
if (!request.url.startsWith("/api")) return;
406409
if (request.url === "/api/public-stats") return; // Allow public landing page stats
@@ -705,6 +708,19 @@ async function startApiServer({ client, db, pluginManager, hooks, startListening
705708
};
706709
});
707710

711+
fastify.get("/api/guild/:guildId/server-stats", async (request, reply) => {
712+
if (!requireGuildAccess(request, reply)) return;
713+
const guild = client.guilds.cache.get(request.params.guildId);
714+
if (!guild) return reply.code(404).send({ error: "Guild not found" });
715+
return {
716+
members: guild.memberCount || 0,
717+
botPing: client.ws.ping || 0,
718+
pluginCount: pluginManager.getPluginList().filter((p) => p.enabled).length,
719+
commandCount: client.commands.size || 0,
720+
uptime: process.uptime(),
721+
};
722+
});
723+
708724
const wss = new WebSocketServer({ server: fastify.server, path: "/ws" });
709725
const wsClients = new Set();
710726

data/plugin-registry.json

Lines changed: 145 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,165 @@
11
{
22
"plugins": [
33
{
4-
"name": "vaish-plugin-economy",
5-
"displayName": "Economy System",
6-
"description": "Complete economy system with coins, work commands, shop, and leaderboards",
7-
"author": "VAISH",
4+
"name": "adb-plugin-aegis",
5+
"displayName": "Aegis",
86
"version": "1.0.0",
9-
"category": "features",
7+
"description": "Automated threat detection: anti-raid, anti-spam, anti-link, anti-alt. Each module independently toggleable.",
8+
"author": "dead",
9+
"main": "index.js",
10+
"requiresRestart": false,
1011
"permissions": [
1112
"db.read",
1213
"db.write",
1314
"commands.register"
1415
],
16+
"configSchema": {
17+
"type": "object",
18+
"properties": {
19+
"log_channel_id": {
20+
"type": "string",
21+
"default": null
22+
},
23+
"raid_joins": {
24+
"type": "number",
25+
"default": 10
26+
},
27+
"raid_seconds": {
28+
"type": "number",
29+
"default": 10
30+
},
31+
"spam_messages": {
32+
"type": "number",
33+
"default": 5
34+
},
35+
"spam_seconds": {
36+
"type": "number",
37+
"default": 3
38+
},
39+
"spam_action": {
40+
"type": "string",
41+
"enum": [
42+
"warn",
43+
"mute",
44+
"kick",
45+
"ban"
46+
],
47+
"default": "mute"
48+
},
49+
"alt_min_age_days": {
50+
"type": "number",
51+
"default": 7
52+
},
53+
"alt_action": {
54+
"type": "string",
55+
"enum": [
56+
"flag",
57+
"kick"
58+
],
59+
"default": "flag"
60+
}
61+
}
62+
}
63+
},
64+
{
65+
"name": "adb-plugin-levels",
66+
"displayName": "Levels & XP System",
67+
"version": "1.0.0",
68+
"description": "Track user activity with XP, levels, and role rewards",
69+
"author": "dead",
70+
"main": "index.js",
1571
"requiresRestart": false,
16-
"verified": true,
17-
"npmPackage": "vaish-plugin-economy"
72+
"permissions": [
73+
"db.read",
74+
"db.write",
75+
"commands.register",
76+
"events.register"
77+
],
78+
"configSchema": {
79+
"type": "object",
80+
"properties": {
81+
"xpPerMessage": {
82+
"type": "number",
83+
"default": 5,
84+
"minimum": 1,
85+
"maximum": 50
86+
},
87+
"xpCooldown": {
88+
"type": "number",
89+
"default": 60,
90+
"minimum": 10,
91+
"maximum": 300
92+
},
93+
"xpPerMinuteLimit": {
94+
"type": "number",
95+
"default": 100,
96+
"minimum": 10,
97+
"maximum": 1000
98+
},
99+
"levelUpChannelId": {
100+
"type": "string",
101+
"default": null
102+
}
103+
}
104+
}
18105
},
19106
{
20-
"name": "vaish-plugin-moderation",
21-
"displayName": "Advanced Moderation",
22-
"description": "Auto-mod, logs, slowmode, and advanced moderation tools",
23-
"author": "VAISH",
107+
"name": "adb-plugin-moderation",
108+
"displayName": "Basic Moderation",
24109
"version": "1.0.0",
25-
"category": "moderation",
110+
"description": "Core moderation commands: ban, kick, timeout, warn, purge, tickets, and case logging.",
111+
"author": "dead",
112+
"main": "index.js",
113+
"requiresRestart": true,
26114
"permissions": [
27115
"db.read",
28116
"db.write",
29117
"commands.register"
30118
],
31-
"requiresRestart": false,
32-
"verified": true,
33-
"npmPackage": "vaish-plugin-moderation"
119+
"configSchema": {
120+
"type": "object",
121+
"properties": {
122+
"log_channel_id": {
123+
"type": "string",
124+
"default": null
125+
},
126+
"ticket_category_id": {
127+
"type": "string",
128+
"default": null
129+
},
130+
"ticket_support_role_id": {
131+
"type": "string",
132+
"default": null
133+
},
134+
"ticket_log_channel_id": {
135+
"type": "string",
136+
"default": null
137+
},
138+
"warn_thresholds": {
139+
"type": "object",
140+
"default": {
141+
"3": {
142+
"action": "timeout",
143+
"duration": "1h"
144+
},
145+
"5": {
146+
"action": "timeout",
147+
"duration": "24h"
148+
},
149+
"7": {
150+
"action": "kick"
151+
},
152+
"10": {
153+
"action": "ban"
154+
}
155+
}
156+
},
157+
"dm_on_action": {
158+
"type": "boolean",
159+
"default": true
160+
}
161+
}
162+
}
34163
},
35164
{
36165
"name": "adb-plugin-reminders",
@@ -59,5 +188,5 @@
59188
}
60189
}
61190
],
62-
"lastFetch": 1783396510311
191+
"lastFetch": 1783586511123
63192
}

0 commit comments

Comments
 (0)