update auditGuilds to sort guilds by largest to smallest
This commit is contained in:
parent
8cf55aacf5
commit
ba51bd471c
|
@ -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' });
|
||||||
|
|
Loading…
Reference in New Issue