npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@enerthya-labs/status

v1.1.0

Published

Status embed system for the Enerthya bot: constants, embed builders, formatters, validators and a dashboard-side StatusMonitor.

Readme

@enerthya-labs/status

Status embed system for the Enerthya Discord bot.

Provides constants, embed builders, formatters, validators and a dashboard-side StatusMonitor that edits the embed via Discord REST when the bot is offline.


Exports

Constants

| Name | Description | |------|-------------| | BOT_STATUS | ONLINE, OFFLINE, RESTARTING, DEGRADED | | DASHBOARD_STATUS | ONLINE, OFFLINE | | EMBED_COLORS | Hex color numbers for each status | | STATUS_EMOJI | Display emojis for each status | | DEFAULT_MONITOR_INTERVAL_MS | 30 000 — dashboard polling interval | | DEFAULT_BOT_REFRESH_INTERVAL_MS | 60 000 — bot embed refresh interval |

Embed Builders

All embeds use a 3-field-per-row layout (2 real + 1 blank spacer per row) to prevent inline stacking on Discord mobile when a thumbnail is present.

| Function | Description | |----------|-------------| | buildOnlineEmbed(data) | Green embed with ping, uptime, servers, members | | buildOfflineEmbed(opts?) | Red embed — rendered by dashboard when bot is down | | buildRestartingEmbed(opts?) | Yellow embed for planned restarts | | buildDegradedEmbed(data) | Orange embed when bot is up but degraded | | buildStatusEmbed(botStatus, data) | Auto-selects the right builder |

buildStatusComponents(opts?)

Returns the Discord ActionRow with the refresh interval button.

buildStatusComponents()
// → "Atualiza a cada 1 minuto"

buildStatusComponents({ intervalMs: 120_000 })
// → "Atualiza a cada 2 minutos"

| Option | Type | Default | Description | |--------|------|---------|-------------| | intervalMs | number | DEFAULT_BOT_REFRESH_INTERVAL_MS | Shown in the button label |

Formatters

| Function | Example | |----------|---------| | formatUptime(seconds) | "2d 4h 13m 7s" | | formatPing(ms) | "42ms ⚡" / "350ms ⚠️" | | formatCount(n) | "12.345" | | formatDate(date) | "15/01/2024, 12:00" | | discordRelativeTimestamp(date) | "<t:1705320000:R>" |

Validators

| Function | Returns | |----------|---------| | validateBotStatusData(data) | { valid, errors? } | | validateOfflineData(data) | { valid, errors? } |

StatusMonitor

Dashboard-side class. Polls /internal/status every N seconds. On bot going offline (after failureThreshold consecutive failures), edits all status embeds via Discord REST. Single-failure false positives are suppressed by the threshold.

const { StatusMonitor } = require("@enerthya-labs/status");

const monitor = new StatusMonitor({
  botInternalUrl:   process.env.BOT_URL,
  internalToken:    process.env.INTERNAL_API_TOKEN,
  discordToken:     process.env.TOKEN,
  getEmbedTargets:  async () => {
    const guilds = await Guild.find({ "status_embed.enabled": true });
    return guilds
      .map(g => ({ channelId: g.status_embed.channel_id, messageId: g.status_embed.message_id }))
      .filter(t => t.channelId && t.messageId);
  },
  intervalMs:       30_000,  // default: 30 000
  failureThreshold: 2,       // default: 2
  onStatusChange:   async (newStatus, prevStatus) => {
    console.log(`Bot: ${prevStatus} → ${newStatus}`);
  },
});

monitor.start();

// Force an immediate check
await monitor.forceCheck();

// Read diagnostics
console.log(monitor.info);
// { status, running, consecutiveFailures, failureThreshold, offlineSince, intervalMs }

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | botInternalUrl | string | required | Bot internal API URL | | internalToken | string | required | x-internal-token value | | discordToken | string | required | Discord bot token | | getEmbedTargets | Function | required | async () => [{ channelId, messageId }] | | intervalMs | number | 30_000 | Polling interval | | failureThreshold | number | 2 | Consecutive failures before marking offline | | onStatusChange | Function | — | async (newStatus, prevStatus) => void | | logger | object | console | Logger with .info() .warn() .error() |

API

| Member | Description | |--------|-------------| | start() | Start polling. Idempotent. | | stop() | Stop polling. | | forceCheck() | Immediate check, doesn't reset interval. | | currentStatus | Last known status string or null. | | info | { status, running, consecutiveFailures, failureThreshold, offlineSince, intervalMs } |