reworking

This commit is contained in:
NoLogicAlan committed 2026-05-09 16:12:15 +03:00
1 parent 8f23e519f5
commit 67db7e73a8
2 files changed
+22 -5

No files matched your search

+16
View File
@@ -524,15 +524,31 @@ async function handle247(ctx, message, value) {
save247Channels(set, channels);
// Check if the bot already has a player in this guild.
// Fluxer only supports one voice connection per guild — spawning a new player
// would disconnect the existing one. If the bot is already in a different
// channel in this guild, just save the 24/7 setting without spawning.
const playerExists = ctx.players.playerMap.has(id) ||
[...ctx.players.playerMap.values()].some(p =>
cleanId(p?._channelId ?? "") === id && cleanId(p?._guildId ?? "") === cleanId(guildId)
);
const guildHasPlayer = [...ctx.players.playerMap.values()].some(p =>
cleanId(p?._guildId ?? "") === cleanId(guildId) && !p._destroyed
);
if (playerExists) {
return message.reply(build247EnabledPanel(set, id, resolved, false, ctx, guildId));
}
// If the bot is already in a different channel in this guild, save the
// channel for 24/7 but don't try to spawn a new player (which would
// disconnect the existing one). The bot will auto-rejoin when it
// eventually disconnects from the current channel.
if (guildHasPlayer) {
return message.reply(build247EnabledPanel(set, id, resolved, false, ctx, guildId));
}
try {
await ctx._spawnPlayer(guildId, id);
return message.reply(build247EnabledPanel(set, id, resolved, true, ctx, guildId));
+6 -5
View File
@@ -796,19 +796,20 @@ export class GatewayHandler {
? new Set(raw.map(id => String(id).replace(/\D/g, "")).filter(id => id.length >= 15))
: new Set();
if (channels.has(cleanOld) && cleanOld !== cleanId && cleanId.length >= 15) {
channels.delete(cleanOld);
// Keep the old channel saved AND add the new one.
// The bot moved from one 24/7 channel to another — both should
// remain in the saved list so the bot can auto-rejoin either one.
channels.add(cleanId);
set.set("stay_247", [...channels]);
// Also migrate the per-channel mode from old → new channel
// Copy the per-channel mode from old → new channel (keep old too)
const modes = set.get("stay_247_modes");
if (modes && typeof modes === "object" && !Array.isArray(modes) && modes[cleanOld]) {
modes[cleanId] = modes[cleanOld];
delete modes[cleanOld];
if (!modes[cleanId]) modes[cleanId] = modes[cleanOld];
set.set("stay_247_modes", modes);
}
logger.voice247(`[247] Updated stay_247: ${cleanOld} → ${cleanId}`);
logger.voice247(`[247] Added to stay_247: ${cleanId} (kept ${cleanOld})`);
}
}
} catch (e) {