Spaces:
Runtime error
Runtime error
Update server.js
Browse files
server.js
CHANGED
|
@@ -257,10 +257,18 @@ app.get('/api/servers', requireAuth, (req, res) => {
|
|
| 257 |
if (!discordClient || !discordClient.isReady()) return res.json([]);
|
| 258 |
|
| 259 |
const userGuilds = req.dashSession.guilds || [];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
const sharedGuilds = userGuilds.filter(ug => {
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
const hasPerms = (BigInt(ug.permissions) & BigInt(0x20)) || (BigInt(ug.permissions) & BigInt(0x8));
|
| 263 |
-
return hasPerms
|
| 264 |
});
|
| 265 |
|
| 266 |
const list = sharedGuilds.map(ug => {
|
|
|
|
| 257 |
if (!discordClient || !discordClient.isReady()) return res.json([]);
|
| 258 |
|
| 259 |
const userGuilds = req.dashSession.guilds || [];
|
| 260 |
+
const app = await discordClient.application.fetch().catch(() => null);
|
| 261 |
+
const ownerId = app?.owner?.ownerId || app?.owner?.id;
|
| 262 |
+
const isBotOwner = req.dashSession.user.id === ownerId;
|
| 263 |
+
|
| 264 |
const sharedGuilds = userGuilds.filter(ug => {
|
| 265 |
+
const g = discordClient.guilds.cache.get(ug.id);
|
| 266 |
+
if (!g) return false;
|
| 267 |
+
|
| 268 |
+
if (isBotOwner) return true; // Owner sees all bot servers
|
| 269 |
+
|
| 270 |
const hasPerms = (BigInt(ug.permissions) & BigInt(0x20)) || (BigInt(ug.permissions) & BigInt(0x8));
|
| 271 |
+
return hasPerms;
|
| 272 |
});
|
| 273 |
|
| 274 |
const list = sharedGuilds.map(ug => {
|