This commit is contained in:
NoLogicAlan committed 2026-05-25 16:51:22 +03:00
1 parent fe123731d1
commit 65e58414dc
3 files changed
+70 -3

No files matched your search

+19 -1
View File
@@ -190,7 +190,25 @@ export async function run(message, data) {
const cid = this.players.checkVoiceChannels(message); const cid = this.players.checkVoiceChannels(message);
if (!cid) { if (!cid) {
const prefix = this._commands?.getPrefix?.(getGuildId(message)) ?? "%"; const userId = message?.author?.id ?? message?.message?.author?.id;
const guildId = getGuildId(message);
let isHidden = false;
try {
const cleanGuild = String(guildId ?? "").replace(/\D/g, "");
const guild = this.players?.commands?.client?.guilds?.get?.(cleanGuild);
const member = guild?.members?.get?.(userId);
if (member) {
const memberVoiceCh = member.voice?.channelId ?? member.voice_channel_id ?? member.voiceChannelId ?? null;
if (memberVoiceCh) isHidden = true;
}
} catch (_) {}
if (isHidden) {
const prefix = this._commands?.getPrefix?.(guildId) ?? "%";
const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription(this.t(message, "responses.join.hiddenVoiceChannel", { prefix }));
return message.reply({ embeds: [embed] });
}
const prefix = this._commands?.getPrefix?.(guildId) ?? "%";
const embed = new EmbedBuilder().setColor(getGlobalColor()) const embed = new EmbedBuilder().setColor(getGlobalColor())
.setDescription(this.t(message, "responses.join.noVoiceChannel", { prefix })); .setDescription(this.t(message, "responses.join.noVoiceChannel", { prefix }));
return message.reply({ embeds: [embed] }); return message.reply({ embeds: [embed] });
+47
View File
@@ -90,6 +90,43 @@ function botHasVoicePermissions(client, channelId) {
* botHasVoicePermissions(). If the bot HAS Connect but got 401, it's a * botHasVoicePermissions(). If the bot HAS Connect but got 401, it's a
* stale session ("SESSION_RACE"), not a real permission error ("PERMISSION"). * stale session ("SESSION_RACE"), not a real permission error ("PERMISSION").
*/ */
/**
* Check if a user might be in a voice channel that the bot cannot see
* (e.g. private channel where the bot lacks View Channel permission).
*
* On Fluxer, if the guild has voice states but none match the user,
* AND the user is a known member, they are likely in a hidden channel.
* The gateway may still send partial voice state data through the member
* object even when the bot can't see the channel itself.
*
* @param {Object} client - Fluxer client
* @param {string} userId - User ID to check
* @param {string} guildId - Guild ID
* @returns {boolean} true if the user appears to be in an invisible voice channel
*/
function userMightBeInHiddenVoice(client, userId, guildId) {
if (!client || !userId || !guildId) return false;
const cleanGuild = cleanId(guildId);
try {
const guild = client.guilds?.get?.(cleanGuild) ?? client.guilds?.get?.(guildId);
if (!guild) return false;
const member = guild.members?.get?.(userId);
if (!member) return false;
const memberVoiceChannelId =
member.voice?.channelId ??
member.voice_channel_id ??
member.voiceChannelId ??
null;
if (memberVoiceChannelId) return true;
} catch (_) {}
return false;
}
function sanitizeJoinError(err, client = null, channelId = null) { function sanitizeJoinError(err, client = null, channelId = null) {
const msg = String(err?.message ?? err ?? ""); const msg = String(err?.message ?? err ?? "");
if (msg.includes("401") || msg.includes("Unauthorized")) { if (msg.includes("401") || msg.includes("Unauthorized")) {
@@ -603,7 +640,12 @@ export class PlayerManager {
first[1].textChannel = message.channel; first[1].textChannel = message.channel;
return first[1]; return first[1];
} }
const msgUserId = message?.author?.id ?? message?.message?.author?.id;
if (msgUserId && userMightBeInHiddenVoice(this.commands?.client, msgUserId, guildId)) {
message.reply(mkEmbed(this._t(message, "responses._common.hiddenVoiceChannel")));
} else {
message.reply(mkEmbed(this._t(message, "responses._common.noVoiceStrict"))); message.reply(mkEmbed(this._t(message, "responses._common.noVoiceStrict")));
}
return null; return null;
} }
@@ -640,7 +682,12 @@ export class PlayerManager {
if (shouldJoin) { if (shouldJoin) {
return this.promptVC(message); return this.promptVC(message);
} }
const msgUserId = message?.author?.id ?? message?.message?.author?.id;
if (msgUserId && userMightBeInHiddenVoice(this.commands?.client, msgUserId, guildId)) {
message.reply(mkEmbed(this._t(message, "responses._common.hiddenVoiceChannel")));
} else {
message.reply(mkEmbed(this._t(message, "responses._common.noVoiceChannel"))); message.reply(mkEmbed(this._t(message, "responses._common.noVoiceChannel")));
}
return null; return null;
} }
+4 -2
View File
@@ -215,7 +215,8 @@
"joinPermissionError": "❌ I don't have permission to join <#{{channel}}>. Please give me the **Connect** permission in that channel.", "joinPermissionError": "❌ I don't have permission to join <#{{channel}}>. Please give me the **Connect** permission in that channel.",
"joinFailedPermissions": "❌ Failed to join voice channel — missing permissions. Please make sure I have **Connect** and **Speak** permissions.", "joinFailedPermissions": "❌ Failed to join voice channel — missing permissions. Please make sure I have **Connect** and **Speak** permissions.",
"joinFailedGeneric": "❌ Failed to join voice channel. Please try again.", "joinFailedGeneric": "❌ Failed to join voice channel. Please try again.",
"joinFailedNotFound": "❌ Could not find that voice channel." "joinFailedNotFound": "❌ Could not find that voice channel.",
"hiddenVoiceChannel": "⚠️ I can't see your voice channel. Please make sure I have **View Channel** and **Connect** permissions in that channel, or move to a channel I can access."
}, },
"clear": { "clear": {
"cleared": "🗑️ Queue cleared." "cleared": "🗑️ Queue cleared."
@@ -276,7 +277,8 @@
"autoLeaveInactive": "Left channel <#{{channel}}> because of inactivity.", "autoLeaveInactive": "Left channel <#{{channel}}> because of inactivity.",
"autoLeaveInactive247": "Left channel <#{{channel}}> because of inactivity.\nIf you want me to stay in voice, use `{{prefix}}247 on` or `{{prefix}}247 auto`\nUse `{{prefix}}247` to view and manage all saved channels.", "autoLeaveInactive247": "Left channel <#{{channel}}> because of inactivity.\nIf you want me to stay in voice, use `{{prefix}}247 on` or `{{prefix}}247 auto`\nUse `{{prefix}}247` to view and manage all saved channels.",
"joinFailedPerms": "❌ I don't have permission to join <#{{channel}}>. Please check that I have the **Connect** permission.", "joinFailedPerms": "❌ I don't have permission to join <#{{channel}}>. Please check that I have the **Connect** permission.",
"voiceChannelUnknown": "unknown voice channel" "voiceChannelUnknown": "unknown voice channel",
"hiddenVoiceChannel": "⚠️ I can't see your voice channel. Please make sure I have **View Channel** and **Connect** permissions in that channel, or specify a channel: `{{prefix}}join <#channel>`"
}, },
"leave": { "leave": {
"noVoiceChannel": "⚠️ Please join a voice channel first, or specify one: `{{prefix}}leave <#channel>`", "noVoiceChannel": "⚠️ Please join a voice channel first, or specify one: `{{prefix}}leave <#channel>`",