update auditGuilds to sort guilds by largest to smallest

This commit is contained in:
Ean Milligan 2025-04-28 23:26:14 -04:00
parent 8cf55aacf5
commit ba51bd471c
1 changed files with 28 additions and 15 deletions

View File

@ -3,6 +3,7 @@ import {
// Discordeno deps // Discordeno deps
cache, cache,
cacheHandlers, cacheHandlers,
DiscordenoGuild,
DiscordenoMessage, DiscordenoMessage,
} from '../../../deps.ts'; } from '../../../deps.ts';
import { infoColor2 } from '../../commandUtils.ts'; import { infoColor2 } from '../../commandUtils.ts';
@ -16,26 +17,38 @@ export const auditGuilds = async (message: DiscordenoMessage) => {
let auditText = ''; let auditText = '';
cache.guilds.forEach((guild) => { const sortGuildByMemberCount = (a: DiscordenoGuild, b: DiscordenoGuild) => {
totalCount += guild.memberCount; if (a.memberCount < b.memberCount) {
let localBotCount = 0; return 1;
let localRealCount = 0; }
guild.members.forEach((member) => { if (a.memberCount > b.memberCount) {
if (member.bot) { return -1;
botsCount++; }
localBotCount++; return 0;
} else { };
realCount++; cache.guilds
localRealCount++; .array()
} .sort(sortGuildByMemberCount)
}); .forEach((guild) => {
totalCount += guild.memberCount;
let localBotCount = 0;
let localRealCount = 0;
guild.members.forEach((member) => {
if (member.bot) {
botsCount++;
localBotCount++;
} else {
realCount++;
localRealCount++;
}
});
auditText += `Guild: ${guild.name} (${guild.id}) auditText += `Guild: ${guild.name} (${guild.id})
Owner: ${guild.owner?.username}#${guild.owner?.discriminator} (${guild.ownerId}) Owner: ${guild.owner?.username}#${guild.owner?.discriminator} (${guild.ownerId})
Tot mem: ${guild.memberCount} | Real: ${localRealCount} | Bot: ${localBotCount} Tot mem: ${guild.memberCount} | Real: ${localRealCount} | Bot: ${localBotCount}
`; `;
}); });
const b = await new Blob([auditText as BlobPart], { type: 'text' }); const b = await new Blob([auditText as BlobPart], { type: 'text' });
const tooBig = await new Blob(['tooBig' as BlobPart], { type: 'text' }); const tooBig = await new Blob(['tooBig' as BlobPart], { type: 'text' });