mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
reworking
This commit is contained in:
1 parent
8f23e519f5
commit
67db7e73a8
2 files changed
+22
-5
No files matched your search
@@ -524,15 +524,31 @@ async function handle247(ctx, message, value) {
|
|||||||
|
|
||||||
save247Channels(set, channels);
|
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) ||
|
const playerExists = ctx.players.playerMap.has(id) ||
|
||||||
[...ctx.players.playerMap.values()].some(p =>
|
[...ctx.players.playerMap.values()].some(p =>
|
||||||
cleanId(p?._channelId ?? "") === id && cleanId(p?._guildId ?? "") === cleanId(guildId)
|
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) {
|
if (playerExists) {
|
||||||
return message.reply(build247EnabledPanel(set, id, resolved, false, ctx, guildId));
|
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 {
|
try {
|
||||||
await ctx._spawnPlayer(guildId, id);
|
await ctx._spawnPlayer(guildId, id);
|
||||||
return message.reply(build247EnabledPanel(set, id, resolved, true, ctx, guildId));
|
return message.reply(build247EnabledPanel(set, id, resolved, true, ctx, guildId));
|
||||||
|
|||||||
@@ -796,19 +796,20 @@ export class GatewayHandler {
|
|||||||
? new Set(raw.map(id => String(id).replace(/\D/g, "")).filter(id => id.length >= 15))
|
? new Set(raw.map(id => String(id).replace(/\D/g, "")).filter(id => id.length >= 15))
|
||||||
: new Set();
|
: new Set();
|
||||||
if (channels.has(cleanOld) && cleanOld !== cleanId && cleanId.length >= 15) {
|
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);
|
channels.add(cleanId);
|
||||||
set.set("stay_247", [...channels]);
|
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");
|
const modes = set.get("stay_247_modes");
|
||||||
if (modes && typeof modes === "object" && !Array.isArray(modes) && modes[cleanOld]) {
|
if (modes && typeof modes === "object" && !Array.isArray(modes) && modes[cleanOld]) {
|
||||||
modes[cleanId] = modes[cleanOld];
|
if (!modes[cleanId]) modes[cleanId] = modes[cleanOld];
|
||||||
delete modes[cleanOld];
|
|
||||||
set.set("stay_247_modes", modes);
|
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) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in new issue
Block a user