mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
cleaning
This commit is contained in:
1 parent
3d66043864
commit
a557c37d08
2 files changed
+28
-9
No files matched your search
+16
-1
@@ -72,6 +72,21 @@ function getUserCount(client) {
|
||||
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 ─────────────────────────────────────────────────────────────
|
||||
|
||||
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) {
|
||||
const shared = {
|
||||
guildCount: this.client.guilds.cache.size,
|
||||
playerCount: this.players.playerMap.size,
|
||||
playerCount: getLivePlayerCount(this.players.playerMap),
|
||||
uptime: Utils.prettifyMS(Math.round(process.uptime()) * 1000),
|
||||
comHash: this.comHash,
|
||||
comLink: this.comLink,
|
||||
|
||||
+12
-8
@@ -114,9 +114,13 @@ export class PlayerManager {
|
||||
const cleanServerId = serverId ? String(serverId).replace(/\D/g, "") : null;
|
||||
|
||||
const userChannelId = this.checkVoiceChannels(message);
|
||||
const cleanUserChannelId = userChannelId ? String(userChannelId).replace(/\D/g, "") : null;
|
||||
|
||||
if (userChannelId) {
|
||||
const player = this.playerMap.get(userChannelId);
|
||||
if (cleanUserChannelId) {
|
||||
const player = this.playerMap.get(cleanUserChannelId)
|
||||
?? [...this.playerMap.values()].find(p =>
|
||||
String(p?._channelId ?? "").replace(/\D/g, "") === cleanUserChannelId
|
||||
);
|
||||
if (player) {
|
||||
player.textChannel = message.channel;
|
||||
return player;
|
||||
@@ -124,11 +128,9 @@ export class PlayerManager {
|
||||
}
|
||||
|
||||
const serverPlayers = cleanServerId
|
||||
? [...this.playerMap.entries()].filter(([chId]) => {
|
||||
const ch = this.commands.client?.channels?.get(chId) ??
|
||||
this.commands.client?.channels?.cache?.get(chId);
|
||||
const chGuild = String(ch?.guildId ?? ch?.server_id ?? ch?.serverId ?? "").replace(/\D/g, "");
|
||||
return chGuild === cleanServerId;
|
||||
? [...this.playerMap.entries()].filter(([, player]) => {
|
||||
const playerGuildId = String(player?._guildId ?? "").replace(/\D/g, "");
|
||||
return playerGuildId === cleanServerId;
|
||||
})
|
||||
: [];
|
||||
|
||||
@@ -147,7 +149,9 @@ export class PlayerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
const match = serverPlayers.find(([chId]) => chId === userChannelId);
|
||||
const match = serverPlayers.find(([, player]) =>
|
||||
String(player?._channelId ?? "").replace(/\D/g, "") === cleanUserChannelId
|
||||
);
|
||||
if (match) {
|
||||
match[1].textChannel = message.channel;
|
||||
return match[1];
|
||||
|
||||
Reference in new issue
Block a user