(guild)
| 43 | } |
| 44 | |
| 45 | export 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 | |
| 67 | export async function getCounterCount(guild, type) { |
| 68 | const stats = await getGuildCounterStats(guild); |
no outgoing calls
no test coverage detected