MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / getGuildCounterStats

Function getGuildCounterStats

src/services/serverstatsService.js:45–65  ·  view source on GitHub ↗
(guild)

Source from the content-addressed store, hash-verified

43}
44
45export async function getGuildCounterStats(guild) {
46 let memberCollection = guild.members.cache;
47
48 try {
49 memberCollection = await guild.members.fetch();
50 } catch (error) {
51 if (process.env.NODE_ENV !== 'production') {
52 logger.debug(`Failed to fetch all guild members for ${guild.id}, using cache only`, error);
53 }
54 }
55
56 const botCount = memberCollection.filter((member) => member.user.bot).size;
57 const totalCount = typeof guild.memberCount === 'number' ? guild.memberCount : memberCollection.size;
58 const humanCount = Math.max(totalCount - botCount, 0);
59
60 return {
61 totalCount,
62 botCount,
63 humanCount
64 };
65}
66
67export async function getCounterCount(guild, type) {
68 const stats = await getGuildCounterStats(guild);

Callers 2

handleListFunction · 0.90
getCounterCountFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected