Brozy123 commited on
Commit
d10e08b
·
verified ·
1 Parent(s): 1916bfe

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +38 -10
index.js CHANGED
@@ -1231,20 +1231,48 @@ client.on('messageCreate', async (message) => {
1231
 
1232
  guildsInfoRaw.sort((a, b) => b.count - a.count);
1233
 
1234
- let desc = "";
1235
- guildsInfoRaw.forEach((g, i) => {
1236
  const serverName = g.link ? `[${g.name}](${g.link})` : g.name;
1237
- let line = `**${i + 1}.** ${serverName} — \`${g.count}\` members\n`;
1238
- if (desc.length + line.length < 4000) desc += line; // Embed safety cap
1239
  });
1240
- desc += `\nTotal servers: ${client.guilds.cache.size}`;
1241
 
1242
- const embed = new EmbedBuilder()
1243
- .setTitle(`🌐 Serving ${client.guilds.cache.size} Servers`)
1244
- .setDescription(desc)
1245
- .setColor('#5865F2');
 
 
 
 
 
 
 
 
 
1246
 
1247
- await statusMsg.edit({ content: null, embeds: [embed] });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1248
  return;
1249
  }
1250
 
 
1231
 
1232
  guildsInfoRaw.sort((a, b) => b.count - a.count);
1233
 
1234
+ const lines = guildsInfoRaw.map((g, i) => {
 
1235
  const serverName = g.link ? `[${g.name}](${g.link})` : g.name;
1236
+ return `**${i + 1}.** ${serverName} — \`${g.count}\` members`;
 
1237
  });
 
1238
 
1239
+ const chunks = [];
1240
+ let currentChunk = "";
1241
+ for (const line of lines) {
1242
+ if (currentChunk.length + line.length + 1 > 3800) {
1243
+ chunks.push(currentChunk);
1244
+ currentChunk = line + "\n";
1245
+ } else {
1246
+ currentChunk += line + "\n";
1247
+ }
1248
+ }
1249
+ if (currentChunk) chunks.push(currentChunk);
1250
+
1251
+ const totalText = `\nTotal servers: ${client.guilds.cache.size}`;
1252
 
1253
+ if (chunks.length === 0) {
1254
+ const embed = new EmbedBuilder()
1255
+ .setTitle(`🌐 Serving ${client.guilds.cache.size} Servers`)
1256
+ .setDescription(`No servers found.${totalText}`)
1257
+ .setColor('#5865F2');
1258
+ await statusMsg.edit({ content: null, embeds: [embed] });
1259
+ } else {
1260
+ // Edit statusMsg with the first chunk
1261
+ const firstEmbed = new EmbedBuilder()
1262
+ .setTitle(`🌐 Serving ${client.guilds.cache.size} Servers${chunks.length > 1 ? ` (Part 1/${chunks.length})` : ''}`)
1263
+ .setDescription(chunks[0] + (chunks.length === 1 ? totalText : ""))
1264
+ .setColor('#5865F2');
1265
+ await statusMsg.edit({ content: null, embeds: [firstEmbed] });
1266
+
1267
+ // Send subsequent chunks
1268
+ for (let i = 1; i < chunks.length; i++) {
1269
+ const nextEmbed = new EmbedBuilder()
1270
+ .setTitle(`🌐 Serving ${client.guilds.cache.size} Servers (Part ${i + 1}/${chunks.length})`)
1271
+ .setDescription(chunks[i] + (i === chunks.length - 1 ? totalText : ""))
1272
+ .setColor('#5865F2');
1273
+ await message.channel.send({ embeds: [nextEmbed] });
1274
+ }
1275
+ }
1276
  return;
1277
  }
1278