Files
fluxer/commands/statustest.mjs
T
NoLogicAlan 36139837ba feat(status): implement public status channel system with live telemetry, automated incident tracking, and multi-language support
- StatusChannelManager Service:
  • Implement dedicated public status channel manager with periodic self-updating live telemetry card.
  • Report real-time Fluxer gateway latency, uptime, active music sessions, listener counts, guild footprint, and subsystem statuses.
  • Add visual Unicode progress bars for RAM (process RSS vs. system total) and CPU utilization across CPU cores.
  • Add dual-color incident lifecycle management:
    - 🔴 Incident Outage embeds with start timestamp, severity level, investigating status, and optional role mentions.
    - ✅ Incident Resolution embeds with automatic downtime duration calculation and stable verification.
  • Wire automated incident triggers into Bot lifecycle (Lavalink node disconnect/reconnect, process shutdown) and GatewayHandler (gateway drops and ready/resumed reconnects).
- Owner Diagnostic Command:
  • Add `statustest` owner-only command with subcommands:
    - `refresh`: Force an immediate update and edit of the live status card.
    - `incident <target> [reason]`: Simulate subsystem outage alerts.
    - `resolve <target> [note]`: Simulate incident resolution with calculated downtime.
- Complete Multi-Language Localization:
  • Add full translations for `statustest` and `statusChannel` across all 6 supported locales:
    - English (`en.json`)
    - German (`de-DE.json`)
    - Portuguese (`pt-BR.json`)
    - Turkish (`tr.json`)
    - Arabic (`ar-SA.json`)
    - Central Kurdish (`ckb.json`)
  • Wire `StatusChannelManager` and `statustest` to dynamically resolve translated strings via `remix.locale.translate`.
2026-11-10 02:31:48 +03:00

92 lines
3.4 KiB
JavaScript

/**
* @module commands/statustest
* @description Owner-only diagnostic command to test the public status channel,
* force-refresh the live health card, and simulate subsystem incidents / resolutions.
*/
import { CommandBuilder } from "../src/commands/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/ui/index.mjs";
/** @type {CommandBuilder} @description Command definition for statustest (owner-only). */
export const command = new CommandBuilder()
.setName("statustest")
.setDescription("Test public status channel updates, live cards, and incidents.", "commands.statustest")
.setCategory("util")
.setRequirement(r => r.setOwnerOnly(true));
/**
* @async
* Run handler for the statustest command.
* @param {object} msg - The command message wrapper.
* @returns {Promise<void>}
*/
export async function run(msg) {
const statusMgr = this.statusChannel;
if (!statusMgr || !statusMgr.enabled || !statusMgr.channelId) {
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.statustest.disabledAuthor") })
.setTitle(this.t(msg, "responses.statustest.disabledTitle"))
.setDescription(this.t(msg, "responses.statustest.disabledDesc"));
return msg.reply({ embeds: [embed] });
}
const prefix = this.commands?.getPrefix?.(msg.message?.guildId) || "%";
const args = (msg.args || []).map(a => String(a).trim().toLowerCase());
const subCommand = args[0] || "help";
if (subCommand === "refresh") {
await statusMgr.updateLiveCard();
const embed = new EmbedBuilder()
.setColor(0x2ecc71)
.setTitle(this.t(msg, "responses.statustest.refreshedTitle"))
.setDescription(this.t(msg, "responses.statustest.refreshedDesc", {
channelId: statusMgr.channelId,
messageId: statusMgr.liveMessageId || "New",
}));
return msg.reply({ embeds: [embed] });
}
if (subCommand === "incident") {
const target = args[1] || "gateway";
const customReason = msg.args.slice(2).join(" ") || "Manual test incident triggered by bot owner.";
await statusMgr.triggerIncident(target, customReason);
const embed = new EmbedBuilder()
.setColor(0xe74c3c)
.setTitle(this.t(msg, "responses.statustest.incidentTitle"))
.setDescription(this.t(msg, "responses.statustest.incidentDesc", {
target,
channelId: statusMgr.channelId,
prefix,
}));
return msg.reply({ embeds: [embed] });
}
if (subCommand === "resolve") {
const target = args[1] || "gateway";
const customNote = msg.args.slice(2).join(" ") || "Manual test resolution confirmed stable.";
await statusMgr.resolveIncident(target, customNote);
const embed = new EmbedBuilder()
.setColor(0x2ecc71)
.setTitle(this.t(msg, "responses.statustest.resolvedTitle"))
.setDescription(this.t(msg, "responses.statustest.resolvedDesc", {
target,
channelId: statusMgr.channelId,
}));
return msg.reply({ embeds: [embed] });
}
/* Default Help */
const embed = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: this.t(msg, "responses.statustest.author") })
.setTitle(this.t(msg, "responses.statustest.helpTitle"))
.setDescription(this.t(msg, "responses.statustest.helpDesc", {
channelId: statusMgr.channelId,
cardId: statusMgr.liveMessageId || "Not yet created",
prefix,
}));
return msg.reply({ embeds: [embed] });
}