Spaces:
Runtime error
Runtime error
Update server.js
Browse files
server.js
CHANGED
|
@@ -387,25 +387,24 @@ app.get('/api/servers', requireAuth, async (req, res) => {
|
|
| 387 |
|
| 388 |
console.log(`[Dashboard] Request by ${req.dashSession.user.username} (Owner: ${isBotOwner})`);
|
| 389 |
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
}
|
| 409 |
|
| 410 |
const list = visibleGuilds.map(g => ({
|
| 411 |
name: g.name,
|
|
|
|
| 387 |
|
| 388 |
console.log(`[Dashboard] Request by ${req.dashSession.user.username} (Owner: ${isBotOwner})`);
|
| 389 |
|
| 390 |
+
// Filter guilds to only those that the user is actually in AND has permissions for.
|
| 391 |
+
// This applies even to the Bot Owner to keep the dashboard clean.
|
| 392 |
+
const mutualGuilds = userGuilds
|
| 393 |
+
.filter(ug => discordClient.guilds.cache.has(ug.id))
|
| 394 |
+
.filter(Boolean);
|
| 395 |
+
|
| 396 |
+
const manageableGuilds = mutualGuilds.filter(ug => {
|
| 397 |
+
const permBits = ug.permissions ?? ug.permissions_new;
|
| 398 |
+
return hasDashboardPermissions(permBits);
|
| 399 |
+
});
|
| 400 |
+
|
| 401 |
+
// Fallback: if manageable list is empty, don't show everything, just show mutuals if they have any perms.
|
| 402 |
+
// But for absolute privacy, we strictly use manageableGuilds.
|
| 403 |
+
const guildsToShow = manageableGuilds;
|
| 404 |
+
|
| 405 |
+
visibleGuilds = guildsToShow
|
| 406 |
+
.map(ug => discordClient.guilds.cache.get(ug.id))
|
| 407 |
+
.filter(Boolean);
|
|
|
|
| 408 |
|
| 409 |
const list = visibleGuilds.map(g => ({
|
| 410 |
name: g.name,
|