Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -946,76 +946,7 @@ if (commandName === 'servers') {
|
|
| 946 |
return;
|
| 947 |
}
|
| 948 |
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
const totalGuilds = client.guilds.cache.size;
|
| 952 |
-
let outputParts = [];
|
| 953 |
-
let currentPart = "";
|
| 954 |
-
let count = 0;
|
| 955 |
-
|
| 956 |
-
// Sort guilds by member count (largest first)
|
| 957 |
-
const sortedGuilds = Array.from(client.guilds.cache.values()).sort((a, b) => b.memberCount - a.memberCount);
|
| 958 |
-
|
| 959 |
-
for (const g of sortedGuilds) {
|
| 960 |
-
count++;
|
| 961 |
-
let inviteLink = "";
|
| 962 |
-
try {
|
| 963 |
-
// Try to get system channel first, then any text channel
|
| 964 |
-
let channel = g.systemChannel;
|
| 965 |
-
if (!channel) {
|
| 966 |
-
channel = g.channels.cache.find(c => c.isTextBased() && c.permissionsFor(g.members.me)?.has('CreateInstantInvite'));
|
| 967 |
-
}
|
| 968 |
-
|
| 969 |
-
if (channel) {
|
| 970 |
-
const inv = await channel.createInvite({ maxAge: 0, maxUses: 0, unique: false });
|
| 971 |
-
inviteLink = inv ? inv.url : "";
|
| 972 |
-
}
|
| 973 |
-
} catch (e) {
|
| 974 |
-
// Ignore errors for private/restricted servers
|
| 975 |
-
}
|
| 976 |
-
|
| 977 |
-
const serverName = inviteLink ? `[${g.name}](${inviteLink})` : g.name;
|
| 978 |
-
const line = `**${count}.** ${serverName} — \`${g.memberCount.toLocaleString()}\` members\n`;
|
| 979 |
-
|
| 980 |
-
// If adding this line exceeds Discord's limit (2000 chars for message content, 4096 for embed description)
|
| 981 |
-
// We split into a new message. Using 1900 to be safe.
|
| 982 |
-
if (currentPart.length + line.length > 1900) {
|
| 983 |
-
outputParts.push(currentPart);
|
| 984 |
-
currentPart = "";
|
| 985 |
-
}
|
| 986 |
-
currentPart += line;
|
| 987 |
-
}
|
| 988 |
-
|
| 989 |
-
if (currentPart) {
|
| 990 |
-
outputParts.push(currentPart);
|
| 991 |
-
}
|
| 992 |
-
|
| 993 |
-
// Send the first part as an edit to the status message
|
| 994 |
-
const part1 = outputParts.shift();
|
| 995 |
-
const embed1 = new EmbedBuilder()
|
| 996 |
-
.setTitle(`🌐 Server List (Part 1 of ${outputParts.length + 1})`)
|
| 997 |
-
.setDescription(part1 + `\n**Total:** ${totalGuilds} servers`)
|
| 998 |
-
.setColor('#5865F2')
|
| 999 |
-
.setFooter({ text: `Showing ${count} servers` });
|
| 1000 |
-
|
| 1001 |
-
await statusMsg.edit({ content: null, embeds: [embed1] });
|
| 1002 |
-
|
| 1003 |
-
// Send remaining parts as follow-up messages
|
| 1004 |
-
for (let i = 0; i < outputParts.length; i++) {
|
| 1005 |
-
const embed = new EmbedBuilder()
|
| 1006 |
-
.setTitle(`🌐 Server List (Part ${i + 2} of ${outputParts.length + 1})`)
|
| 1007 |
-
.setDescription(outputParts[i])
|
| 1008 |
-
.setColor('#5865F2');
|
| 1009 |
-
|
| 1010 |
-
await message.channel.send({ embeds: [embed] });
|
| 1011 |
-
// Small delay to avoid rate limits
|
| 1012 |
-
await new Promise(r => setTimeout(r, 500));
|
| 1013 |
-
}
|
| 1014 |
-
|
| 1015 |
-
return;
|
| 1016 |
-
}
|
| 1017 |
-
|
| 1018 |
-
if (commandName === 'uptime') {
|
| 1019 |
const up = process.uptime();
|
| 1020 |
const d = Math.floor(up / 86400);
|
| 1021 |
const h = Math.floor(up / 3600) % 24;
|
|
|
|
| 946 |
return;
|
| 947 |
}
|
| 948 |
|
| 949 |
+
if (commandName === 'uptime') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 950 |
const up = process.uptime();
|
| 951 |
const d = Math.floor(up / 86400);
|
| 952 |
const h = Math.floor(up / 3600) % 24;
|