repositories / Unfugwart
Unfugwart
Discord caretaker for Abteilung Unfug
owned by admin
occupancy.js
Rawexport function occupancy(guild, voiceChannelId) {
if (!guild?.available) return { known: false, humans: 0 };
const channel = guild.channels.cache.get(voiceChannelId);
if (!channel?.isVoiceBased?.()) return { known: false, humans: 0 };
let humans = 0;
for (const state of guild.voiceStates.cache.values()) {
if (state.channelId !== voiceChannelId) continue;
const user = state.member?.user;
if (!user) return { known: false, humans: 0 };
if (!user.bot) humans += 1;
}
return { known: true, humans };
}