mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(voice): don't count bots toward vote-skip human threshold
This commit is contained in:
1 parent
5b19ee2a72
commit
87aba7434e
2 files changed
+41
No files matched your search
@@ -63,6 +63,19 @@ export class VoiceStateCache {
|
|||||||
const maxEntries = isBot ? this._maxBots : this._maxUsers;
|
const maxEntries = isBot ? this._maxBots : this._maxUsers;
|
||||||
const uKey = VoiceStateCache.userKey(cleanGuild, cleanUser);
|
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);
|
const prev = locations.get(uKey);
|
||||||
if (prev) {
|
if (prev) {
|
||||||
const prevCKey = VoiceStateCache.channelKey(prev.guildId, prev.channelId);
|
const prevCKey = VoiceStateCache.channelKey(prev.guildId, prev.channelId);
|
||||||
|
|||||||
@@ -168,6 +168,34 @@ export function hasHumansInChannel({ guildId, channelId, client, voiceCache, obs
|
|||||||
export function countHumansInChannel({ guildId, channelId, client, voiceCache, observedVoiceUsers, botId }) {
|
export function countHumansInChannel({ guildId, channelId, client, voiceCache, observedVoiceUsers, botId }) {
|
||||||
if (!channelId || !guildId) return 0;
|
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") {
|
if (voiceCache && typeof voiceCache.getHumanCount === "function") {
|
||||||
return voiceCache.getHumanCount(guildId, channelId);
|
return voiceCache.getHumanCount(guildId, channelId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user