This commit is contained in:
NoLogicAlan committed 2026-05-04 16:31:20 +03:00
1 parent 3d66043864
commit a557c37d08
2 files changed
+28 -9

No files matched your search

+16 -1
View File
@@ -72,6 +72,21 @@ function getUserCount(client) {
return inflightPromise; return inflightPromise;
} }
function getLivePlayerCount(playerMap) {
const liveChannels = new Set();
for (const [mapKey, player] of playerMap ?? []) {
if (!player || player._destroyed || player.leaving) continue;
const channelId = String(player._channelId ?? mapKey ?? "").replace(/\D/g, "");
if (!channelId) continue;
liveChannels.add(channelId);
}
return liveChannels.size;
}
// ── Embed builder ───────────────────────────────────────────────────────────── // ── Embed builder ─────────────────────────────────────────────────────────────
function buildEmbed({ guildCount, userCount, playerCount, ping, uptime, comHash, comLink, reason, footer, loading }) { function buildEmbed({ guildCount, userCount, playerCount, ping, uptime, comHash, comLink, reason, footer, loading }) {
@@ -106,7 +121,7 @@ function buildEmbed({ guildCount, userCount, playerCount, ping, uptime, comHash,
export async function run(message) { export async function run(message) {
const shared = { const shared = {
guildCount: this.client.guilds.cache.size, guildCount: this.client.guilds.cache.size,
playerCount: this.players.playerMap.size, playerCount: getLivePlayerCount(this.players.playerMap),
uptime: Utils.prettifyMS(Math.round(process.uptime()) * 1000), uptime: Utils.prettifyMS(Math.round(process.uptime()) * 1000),
comHash: this.comHash, comHash: this.comHash,
comLink: this.comLink, comLink: this.comLink,
+12 -8
View File
@@ -114,9 +114,13 @@ export class PlayerManager {
const cleanServerId = serverId ? String(serverId).replace(/\D/g, "") : null; const cleanServerId = serverId ? String(serverId).replace(/\D/g, "") : null;
const userChannelId = this.checkVoiceChannels(message); const userChannelId = this.checkVoiceChannels(message);
const cleanUserChannelId = userChannelId ? String(userChannelId).replace(/\D/g, "") : null;
if (userChannelId) { if (cleanUserChannelId) {
const player = this.playerMap.get(userChannelId); const player = this.playerMap.get(cleanUserChannelId)
?? [...this.playerMap.values()].find(p =>
String(p?._channelId ?? "").replace(/\D/g, "") === cleanUserChannelId
);
if (player) { if (player) {
player.textChannel = message.channel; player.textChannel = message.channel;
return player; return player;
@@ -124,11 +128,9 @@ export class PlayerManager {
} }
const serverPlayers = cleanServerId const serverPlayers = cleanServerId
? [...this.playerMap.entries()].filter(([chId]) => { ? [...this.playerMap.entries()].filter(([, player]) => {
const ch = this.commands.client?.channels?.get(chId) ?? const playerGuildId = String(player?._guildId ?? "").replace(/\D/g, "");
this.commands.client?.channels?.cache?.get(chId); return playerGuildId === cleanServerId;
const chGuild = String(ch?.guildId ?? ch?.server_id ?? ch?.serverId ?? "").replace(/\D/g, "");
return chGuild === cleanServerId;
}) })
: []; : [];
@@ -147,7 +149,9 @@ export class PlayerManager {
return null; return null;
} }
const match = serverPlayers.find(([chId]) => chId === userChannelId); const match = serverPlayers.find(([, player]) =>
String(player?._channelId ?? "").replace(/\D/g, "") === cleanUserChannelId
);
if (match) { if (match) {
match[1].textChannel = message.channel; match[1].textChannel = message.channel;
return match[1]; return match[1];