fix(voice): don't count bots toward vote-skip human threshold

This commit is contained in:
NoLogicAlan committed 2026-09-29 03:05:28 +03:00
1 parent 5b19ee2a72
commit 87aba7434e
2 files changed
+41

No files matched your search

+13
View File
@@ -63,6 +63,19 @@ export class VoiceStateCache {
const maxEntries = isBot ? this._maxBots : this._maxUsers;
const uKey = VoiceStateCache.userKey(cleanGuild, cleanUser);
const otherLocations = isBot ? this.userLocations : this.botLocations;
const otherChannelIdx = isBot ? this.channelMembers : this.botChannelMembers;
const otherPrev = otherLocations.get(uKey);
if (otherPrev) {
const otherPrevCKey = VoiceStateCache.channelKey(otherPrev.guildId, otherPrev.channelId);
const otherPrevSet = otherChannelIdx.get(otherPrevCKey);
if (otherPrevSet) {
otherPrevSet.delete(cleanUser);
if (otherPrevSet.size === 0) otherChannelIdx.delete(otherPrevCKey);
}
otherLocations.delete(uKey);
}
const prev = locations.get(uKey);
if (prev) {
const prevCKey = VoiceStateCache.channelKey(prev.guildId, prev.channelId);
+28
View File
@@ -168,6 +168,34 @@ export function hasHumansInChannel({ guildId, channelId, client, voiceCache, obs
export function countHumansInChannel({ guildId, channelId, client, voiceCache, observedVoiceUsers, botId }) {
if (!channelId || !guildId) return 0;
if (voiceCache && typeof voiceCache.getHumansInChannel === "function") {
const cachedHumans = voiceCache.getHumansInChannel(guildId, channelId);
if (client) {
let guild = null;
try { guild = client.guilds?.get?.(guildId); } catch (_) { guild = null; }
let humanCount = 0;
for (const userId of cachedHumans) {
const isBot = resolveIsBotUser({
userId,
member: guild?.members?.get?.(userId) ?? null,
guild,
client,
botId,
});
if (isBot) {
try { voiceCache.updateUser({ guildId, userId, channelId, isBot: true }); } catch (_) {}
} else {
humanCount++;
}
}
return humanCount;
}
return cachedHumans.length;
}
if (voiceCache && typeof voiceCache.getHumanCount === "function") {
return voiceCache.getHumanCount(guildId, channelId);
}