mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
TEST
This commit is contained in:
1 parent
f402237ad3
commit
ebca4adcdb
2 files changed
+52
-16
No files matched your search
@@ -852,25 +852,36 @@ class Remix {
|
|||||||
const self = this;
|
const self = this;
|
||||||
this.players.checkVoiceChannels = function (message) {
|
this.players.checkVoiceChannels = function (message) {
|
||||||
const userId = message?.author?.id ?? message?.message?.author?.id;
|
const userId = message?.author?.id ?? message?.message?.author?.id;
|
||||||
const guildId = message?.channel?.server_id ??
|
const guildId =
|
||||||
|
message?.channel?.server_id ??
|
||||||
message?.channel?.serverId ??
|
message?.channel?.serverId ??
|
||||||
message?.channel?.guild?.id ??
|
message?.channel?.guild?.id ??
|
||||||
|
message?.channel?.guildId ??
|
||||||
message?.message?.server_id ??
|
message?.message?.server_id ??
|
||||||
message?.message?.serverId ??
|
message?.message?.serverId ??
|
||||||
message?.message?.guildId;
|
message?.message?.guildId ??
|
||||||
|
message?.message?.channel?.server_id ??
|
||||||
|
message?.message?.channel?.serverId ??
|
||||||
|
message?.message?.channel?.guildId;
|
||||||
if (!userId || !guildId) return null;
|
if (!userId || !guildId) return null;
|
||||||
|
|
||||||
|
// Normalise to digits-only for all comparisons so "123" === "123" regardless
|
||||||
|
// of how the platform formatted the snowflake.
|
||||||
|
const cleanGuild = String(guildId).replace(/\D/g, "");
|
||||||
|
|
||||||
const seed = (channelId) => {
|
const seed = (channelId) => {
|
||||||
// Only seed if no entry exists — never overwrite fresh gateway voice state
|
// Only seed if no entry exists — never overwrite fresh gateway voice state
|
||||||
// with potentially stale member-cache data.
|
// with potentially stale member-cache data.
|
||||||
if (!self.observedVoiceUsers.has(userId)) {
|
if (!self.observedVoiceUsers.has(userId)) {
|
||||||
self.observedVoiceUsers.set(userId, { channelId, guildId });
|
self.observedVoiceUsers.set(userId, { channelId, guildId: cleanGuild });
|
||||||
}
|
}
|
||||||
return self.observedVoiceUsers.get(userId)?.channelId ?? channelId;
|
return self.observedVoiceUsers.get(userId)?.channelId ?? channelId;
|
||||||
};
|
};
|
||||||
|
|
||||||
const observed = self.observedVoiceUsers.get(userId);
|
const observed = self.observedVoiceUsers.get(userId);
|
||||||
if (observed && observed.guildId === guildId) return observed.channelId;
|
// Use normalised comparison — the stored guildId and message guildId may come
|
||||||
|
// from different gateway fields with different formatting.
|
||||||
|
if (observed && String(observed.guildId).replace(/\D/g, "") === cleanGuild) return observed.channelId;
|
||||||
|
|
||||||
// vm.getVoiceChannelId() is an unverified @fluxerjs/voice method — optional-chained
|
// vm.getVoiceChannelId() is an unverified @fluxerjs/voice method — optional-chained
|
||||||
// so it fails silently and falls through to the next strategy if absent.
|
// so it fails silently and falls through to the next strategy if absent.
|
||||||
@@ -892,7 +903,9 @@ class Remix {
|
|||||||
// on the guild object from the gateway payload, which is handled in GuildCreate).
|
// on the guild object from the gateway payload, which is handled in GuildCreate).
|
||||||
// The dual snake_case/camelCase probe covers both shapes.
|
// The dual snake_case/camelCase probe covers both shapes.
|
||||||
try {
|
try {
|
||||||
const guild = client.guilds.cache.get(guildId);
|
// Try both the raw guildId and the normalized cleanGuild — the guilds cache
|
||||||
|
// key may be stored as the raw string the gateway sent.
|
||||||
|
const guild = client.guilds.cache.get(guildId) ?? client.guilds.cache.get(cleanGuild);
|
||||||
// guild.voice_states = raw array from gateway (Fluxer-native)
|
// guild.voice_states = raw array from gateway (Fluxer-native)
|
||||||
// guild.voiceStates?.cache = VoiceStateManager (fallback)
|
// guild.voiceStates?.cache = VoiceStateManager (fallback)
|
||||||
const voiceStates = guild?.voice_states ?? guild?.voiceStates?.cache ?? guild?.voiceStates ?? null;
|
const voiceStates = guild?.voice_states ?? guild?.voiceStates?.cache ?? guild?.voiceStates ?? null;
|
||||||
@@ -905,12 +918,22 @@ class Remix {
|
|||||||
for (const state of entries) {
|
for (const state of entries) {
|
||||||
const sid = state.userId ?? state.user_id ?? state.id;
|
const sid = state.userId ?? state.user_id ?? state.id;
|
||||||
const sch = state.channelId ?? state.channel_id;
|
const sch = state.channelId ?? state.channel_id;
|
||||||
const sgid = state.guildId ?? state.guild_id ?? guildId;
|
const sgid = String(state.guildId ?? state.guild_id ?? guildId).replace(/\D/g, "");
|
||||||
if (sid === userId && sgid === guildId && sch) return seed(sch);
|
if (sid === userId && sgid === cleanGuild && sch) return seed(sch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
|
// Last resort: scan ALL entries in observedVoiceUsers for this userId regardless
|
||||||
|
// of guildId format, then verify the channel belongs to the right guild.
|
||||||
|
// This catches cases where the guildId was stored with a different string format.
|
||||||
|
try {
|
||||||
|
for (const [uid, info] of self.observedVoiceUsers) {
|
||||||
|
if (uid !== userId) continue;
|
||||||
|
if (String(info.guildId).replace(/\D/g, "") === cleanGuild) return info.channelId;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+22
-9
@@ -62,24 +62,30 @@ export class PlayerManager {
|
|||||||
if (!message) return null;
|
if (!message) return null;
|
||||||
|
|
||||||
const userId = message.author?.id;
|
const userId = message.author?.id;
|
||||||
const serverId = message.channel?.server_id ??
|
const serverId =
|
||||||
|
message.channel?.server_id ??
|
||||||
message.channel?.serverId ??
|
message.channel?.serverId ??
|
||||||
|
message.channel?.guild?.id ??
|
||||||
|
message.channel?.guildId ??
|
||||||
message.message?.server_id ??
|
message.message?.server_id ??
|
||||||
message.message?.serverId;
|
message.message?.serverId ??
|
||||||
|
message.message?.guildId;
|
||||||
|
|
||||||
if (!userId) return null;
|
if (!userId) return null;
|
||||||
|
|
||||||
|
const cleanServer = serverId ? String(serverId).replace(/\D/g, "") : null;
|
||||||
|
|
||||||
// Fallback: find any existing player in this server
|
// Fallback: find any existing player in this server
|
||||||
if (serverId) {
|
if (cleanServer) {
|
||||||
for (const [channelId] of this.playerMap) {
|
for (const [channelId] of this.playerMap) {
|
||||||
const channel = this.commands.client?.channels?.get(channelId) ??
|
const channel = this.commands.client?.channels?.get(channelId) ??
|
||||||
this.commands.client?.channels?.cache?.get(channelId);
|
this.commands.client?.channels?.cache?.get(channelId);
|
||||||
if (channel?.guildId === serverId || channel?.server_id === serverId || channel?.serverId === serverId) {
|
const chGuild = String(channel?.guildId ?? channel?.server_id ?? channel?.serverId ?? "").replace(/\D/g, "");
|
||||||
|
if (chGuild === cleanServer) {
|
||||||
return channelId;
|
return channelId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,10 +102,16 @@ export class PlayerManager {
|
|||||||
* @returns {Promise<Player|null>}
|
* @returns {Promise<Player|null>}
|
||||||
*/
|
*/
|
||||||
async getPlayer(message, promptJoin = true, verifyUser = true, shouldJoin = false) {
|
async getPlayer(message, promptJoin = true, verifyUser = true, shouldJoin = false) {
|
||||||
const serverId = message.channel?.server_id ??
|
const serverId =
|
||||||
|
message.channel?.server_id ??
|
||||||
message.channel?.serverId ??
|
message.channel?.serverId ??
|
||||||
|
message.channel?.guild?.id ??
|
||||||
|
message.channel?.guildId ??
|
||||||
message.message?.server_id ??
|
message.message?.server_id ??
|
||||||
message.message?.serverId;
|
message.message?.serverId ??
|
||||||
|
message.message?.guildId;
|
||||||
|
|
||||||
|
const cleanServerId = serverId ? String(serverId).replace(/\D/g, "") : null;
|
||||||
|
|
||||||
const userChannelId = this.checkVoiceChannels(message);
|
const userChannelId = this.checkVoiceChannels(message);
|
||||||
|
|
||||||
@@ -111,11 +123,12 @@ export class PlayerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverPlayers = serverId
|
const serverPlayers = cleanServerId
|
||||||
? [...this.playerMap.entries()].filter(([chId]) => {
|
? [...this.playerMap.entries()].filter(([chId]) => {
|
||||||
const ch = this.commands.client?.channels?.get(chId) ??
|
const ch = this.commands.client?.channels?.get(chId) ??
|
||||||
this.commands.client?.channels?.cache?.get(chId);
|
this.commands.client?.channels?.cache?.get(chId);
|
||||||
return ch?.guildId === serverId || ch?.server_id === serverId || ch?.serverId === serverId;
|
const chGuild = String(ch?.guildId ?? ch?.server_id ?? ch?.serverId ?? "").replace(/\D/g, "");
|
||||||
|
return chGuild === cleanServerId;
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user