mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
idk
This commit is contained in:
1 parent
42011a7e70
commit
b597964b76
3 files changed
+15
-62
No files matched your search
+7
-55
@@ -8,6 +8,7 @@ import { EmbedBuilder } from "@fluxerjs/core";
|
|||||||
import { getGlobalColor, cleanId, getMessageGuildId } from "../src/MessageHandler.mjs";
|
import { getGlobalColor, cleanId, getMessageGuildId } from "../src/MessageHandler.mjs";
|
||||||
import { logger } from "../src/constants/Logger.mjs";
|
import { logger } from "../src/constants/Logger.mjs";
|
||||||
import runnables from "../settings/runnables.mjs";
|
import runnables from "../settings/runnables.mjs";
|
||||||
|
import { get247ChannelMode, set247ChannelMode, remove247ChannelMode } from "../src/constants/Helpers247.mjs";
|
||||||
|
|
||||||
function embed(desc, opts = {}) {
|
function embed(desc, opts = {}) {
|
||||||
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
const b = new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc);
|
||||||
@@ -91,61 +92,6 @@ function getGuildName(message) {
|
|||||||
return message.message?.guild?.name ?? message.channel?.guild?.name ?? "this server";
|
return message.message?.guild?.name ?? message.channel?.guild?.name ?? "this server";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the 24/7 mode for a specific channel.
|
|
||||||
* Reads from the per-channel map (stay_247_modes) first,
|
|
||||||
* falls back to the guild-wide stay_247_mode for backward compat.
|
|
||||||
*
|
|
||||||
* @param {ServerSettings} set
|
|
||||||
* @param {string} channelId Clean channel ID
|
|
||||||
* @returns {string} "on" | "auto" | "off"
|
|
||||||
*/
|
|
||||||
function get247ChannelMode(set, channelId) {
|
|
||||||
const modes = set.get("stay_247_modes");
|
|
||||||
if (modes && typeof modes === "object" && !Array.isArray(modes)) {
|
|
||||||
const perChannel = modes[channelId];
|
|
||||||
if (perChannel === "on" || perChannel === "auto" || perChannel === "off") return perChannel;
|
|
||||||
}
|
|
||||||
const guildMode = set.get("stay_247_mode") ?? "off";
|
|
||||||
return guildMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the 24/7 mode for a specific channel.
|
|
||||||
*
|
|
||||||
* @param {ServerSettings} set
|
|
||||||
* @param {string} channelId Clean channel ID
|
|
||||||
* @param {string} mode "on" | "auto" | "off"
|
|
||||||
*/
|
|
||||||
function set247ChannelMode(set, channelId, mode) {
|
|
||||||
let modes = set.get("stay_247_modes");
|
|
||||||
if (!modes || typeof modes !== "object" || Array.isArray(modes)) modes = {};
|
|
||||||
modes[channelId] = mode;
|
|
||||||
set.set("stay_247_modes", modes);
|
|
||||||
set.set("stay_247_mode", mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a channel from the per-channel modes map.
|
|
||||||
* If no channels remain, clears stay_247_modes entirely.
|
|
||||||
*
|
|
||||||
* @param {ServerSettings} set
|
|
||||||
* @param {string} channelId Clean channel ID
|
|
||||||
* @param {Set} currentChannels Current set of all 247 channels for this guild
|
|
||||||
*/
|
|
||||||
function remove247ChannelMode(set, channelId, currentChannels) {
|
|
||||||
let modes = set.get("stay_247_modes");
|
|
||||||
if (!modes || typeof modes !== "object" || Array.isArray(modes)) return;
|
|
||||||
delete modes[channelId];
|
|
||||||
set.set("stay_247_modes", modes);
|
|
||||||
if (!currentChannels || currentChannels.size === 0) {
|
|
||||||
set.set("stay_247_mode", "off");
|
|
||||||
} else {
|
|
||||||
const firstChannel = [...currentChannels][0];
|
|
||||||
set.set("stay_247_mode", modes[firstChannel] ?? "auto");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function get247Channels(set) {
|
function get247Channels(set) {
|
||||||
const raw = set.get("stay_247");
|
const raw = set.get("stay_247");
|
||||||
if (!raw || raw === "none") return new Set();
|
if (!raw || raw === "none") return new Set();
|
||||||
@@ -417,6 +363,12 @@ async function handle247(ctx, message, value) {
|
|||||||
const { channelId } = await ctx.players.checkVoiceChannels(message);
|
const { channelId } = await ctx.players.checkVoiceChannels(message);
|
||||||
const channels = get247Channels(set);
|
const channels = get247Channels(set);
|
||||||
|
|
||||||
|
if (!channelId && channels.size > 1) {
|
||||||
|
return message.reply(embed(
|
||||||
|
ctx.t(message, "responses.settings.noVoice247", { mode: "off", prefix: ctx.handler.getPrefix(guildId) })
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (channelId) {
|
if (channelId) {
|
||||||
const id = cleanId(channelId);
|
const id = cleanId(channelId);
|
||||||
channels.delete(id);
|
channels.delete(id);
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ export class GatewayHandler {
|
|||||||
this._lastReadyAt = 0;
|
this._lastReadyAt = 0;
|
||||||
/** @type {number} Window after a Ready event during which voice disconnects are treated as WS-induced (ms). */
|
/** @type {number} Window after a Ready event during which voice disconnects are treated as WS-induced (ms). */
|
||||||
this._wsReconnectGraceMs = 30_000;
|
this._wsReconnectGraceMs = 30_000;
|
||||||
|
/** @type {number} How recently another player in the same guild must have connected to count as move evidence, vs. a long-stable second 24/7 channel (ms). */
|
||||||
|
this._moveEvidenceWindowMs = 10_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -916,12 +918,6 @@ export class GatewayHandler {
|
|||||||
const client = remix.client;
|
const client = remix.client;
|
||||||
const guildId = vsuGuildId;
|
const guildId = vsuGuildId;
|
||||||
|
|
||||||
const activeGuildPlayers = [...remix.players.playerMap.entries()].filter(([, p]) =>
|
|
||||||
cleanId(p?._guildId ?? "") === cleanId(guildId ?? "")
|
|
||||||
);
|
|
||||||
const multiVoiceGuild = activeGuildPlayers.length > 1;
|
|
||||||
|
|
||||||
|
|
||||||
if (newChannelId && guildId && oldChannelId && oldChannelId !== newChannelId) {
|
if (newChannelId && guildId && oldChannelId && oldChannelId !== newChannelId) {
|
||||||
try {
|
try {
|
||||||
const cleanNew = cleanId(newChannelId);
|
const cleanNew = cleanId(newChannelId);
|
||||||
@@ -1321,13 +1317,16 @@ export class GatewayHandler {
|
|||||||
const cleanOld = cleanId(oldChannelId);
|
const cleanOld = cleanId(oldChannelId);
|
||||||
if (!cleanGuild || !cleanOld) return false;
|
if (!cleanGuild || !cleanOld) return false;
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
const activePlayers = [...remix.players.playerMap.values()].filter(
|
const activePlayers = [...remix.players.playerMap.values()].filter(
|
||||||
p => !p._destroyed && cleanId(p._guildId ?? "") === cleanGuild
|
p => !p._destroyed && cleanId(p._guildId ?? "") === cleanGuild
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const player of activePlayers) {
|
for (const player of activePlayers) {
|
||||||
const playerChannel = cleanId(player._channelId ?? "");
|
const playerChannel = cleanId(player._channelId ?? "");
|
||||||
if (playerChannel && playerChannel !== cleanOld) {
|
if (!playerChannel || playerChannel === cleanOld) continue;
|
||||||
|
const connectedAt = player._lastConnectedAt ?? 0;
|
||||||
|
if (now - connectedAt < this._moveEvidenceWindowMs) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ export default class Player extends EventEmitter {
|
|||||||
connection = null;
|
connection = null;
|
||||||
_guildId = null;
|
_guildId = null;
|
||||||
_channelId = null;
|
_channelId = null;
|
||||||
|
_lastConnectedAt = null;
|
||||||
_home247Channel = null;
|
_home247Channel = null;
|
||||||
|
|
||||||
queue = null;
|
queue = null;
|
||||||
@@ -1178,6 +1179,7 @@ export default class Player extends EventEmitter {
|
|||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this._channelId = channelId;
|
this._channelId = channelId;
|
||||||
this._guildId = cleanId(channel.guildId);
|
this._guildId = cleanId(channel.guildId);
|
||||||
|
this._lastConnectedAt = Date.now();
|
||||||
this.leaving = false;
|
this.leaving = false;
|
||||||
|
|
||||||
const room = connection.room;
|
const room = connection.room;
|
||||||
|
|||||||
Reference in new issue
Block a user