Brozy123 commited on
Commit
208099c
·
verified ·
1 Parent(s): 1ab1ae3

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +17 -19
index.js CHANGED
@@ -268,8 +268,8 @@ client.on('messageCreate', async (message) => {
268
 
269
  const statusMsg = await message.reply("🔍 Scanning all servers and generating invite links... This may take a moment.");
270
 
271
- const guildsInfo = await Promise.all(client.guilds.cache.map(async g => {
272
- let invite = "`No permission`";
273
  try {
274
  let channel = g.systemChannel || g.channels.cache.find(c => c.isTextBased() && c.permissionsFor(g.members.me).has('CreateInstantInvite'));
275
  if (channel) {
@@ -277,27 +277,25 @@ client.on('messageCreate', async (message) => {
277
  invite = inv.url;
278
  }
279
  } catch (e) {}
280
- return `**${g.name}** (${g.memberCount} members) - ${invite}`;
281
  }));
282
 
283
- const chunks = [];
284
- let chunk = `🤖 **Full Server Registry Report** (${client.guilds.cache.size} total)\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n`;
285
- for (const line of guildsInfo) {
286
- if (chunk.length + line.length > 1900) { chunks.push(chunk); chunk = ""; }
287
- chunk += line + "\n";
288
- }
289
- if (chunk) chunks.push(chunk);
290
 
291
- let dmSuccess = true;
292
- for (const c of chunks) {
293
- await message.author.send(c).catch(() => { dmSuccess = false; });
294
- }
 
 
 
295
 
296
- if (!dmSuccess) {
297
- await statusMsg.edit("❌ I attempted to DM you the server list, but your DMs are closed! Please allow direct messages from server members and try again.");
298
- } else {
299
- await statusMsg.edit("✅ Complete Server Registry report has been securely sent directly to your DMs!");
300
- }
 
301
  }
302
 
303
  if (commandName === 'uptime') {
 
268
 
269
  const statusMsg = await message.reply("🔍 Scanning all servers and generating invite links... This may take a moment.");
270
 
271
+ const guildsInfoRaw = await Promise.all(client.guilds.cache.map(async g => {
272
+ let invite = null;
273
  try {
274
  let channel = g.systemChannel || g.channels.cache.find(c => c.isTextBased() && c.permissionsFor(g.members.me).has('CreateInstantInvite'));
275
  if (channel) {
 
277
  invite = inv.url;
278
  }
279
  } catch (e) {}
280
+ return { name: g.name, count: g.memberCount, link: invite };
281
  }));
282
 
283
+ guildsInfoRaw.sort((a, b) => b.count - a.count);
 
 
 
 
 
 
284
 
285
+ let desc = "";
286
+ guildsInfoRaw.forEach((g, i) => {
287
+ const serverName = g.link ? `[${g.name}](${g.link})` : g.name;
288
+ let line = `**${i + 1}.** ${serverName} — \`${g.count}\` members\n`;
289
+ if (desc.length + line.length < 4000) desc += line; // Embed safety cap
290
+ });
291
+ desc += `\nTotal servers: ${client.guilds.cache.size}`;
292
 
293
+ const embed = new EmbedBuilder()
294
+ .setTitle(`🌐 Serving ${client.guilds.cache.size} Servers`)
295
+ .setDescription(desc)
296
+ .setColor('#5865F2');
297
+
298
+ await statusMsg.edit({ content: null, embeds: [embed] });
299
  }
300
 
301
  if (commandName === 'uptime') {