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

@botgate/botgate-stats-reporter

v1.3.3

Published

Módulo oficial do BotGate para reportar estatísticas do seu bot Discord automaticamente

Downloads

440

Readme

@botgate/botgate-stats-reporter

npm version license

O módulo oficial do BotGate para simplificar a integração de bots Discord com a nossa plataforma. Automatize o envio de estatísticas, monitore votos em tempo real e gerencie o plano do seu bot com facilidade.

📦 Instalação

npm install @botgate/botgate-stats-reporter

🚀 Como usar

A biblioteca foi projetada para ser "configure e esqueça". Ela gerencia automaticamente o intervalo de postagem com base no seu plano (Tier).

Integração Simples (com Votos em Tempo Real)

import { Client, GatewayIntentBits } from "discord.js";
import { BotGateReporter } from "@botgate/botgate-stats-reporter";

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const reporter = new BotGateReporter({
  botId: "SEU_BOT_ID",
  apiKey: "SUA_API_KEY",
  enableWebhooks: true, // Ativa o servidor interno para receber eventos (votos)
  lang: "pt-BR", // Opcional: "pt-BR" (padrão) ou "en-US"
  debug: true, // Opcional: true para logs detalhados, false para logs normais
});

// Evento disparado sempre que alguém votar no seu bot
reporter.on("vote", (vote) => {
  console.log(`🎁 Recompensando ${vote.username} por votar!`);
  // Sua lógica de cargos ou moedas aqui
});

client.once("ready", () => {
  reporter.start(client);
});

client.login("SEU_TOKEN_DISCORD");

⚙️ Configuração

O construtor BotGateReporter aceita as seguintes opções:

| Propriedade | Tipo | Padrão | Descrição | | :--------------- | :-------- | :-------------- | :-------------------------------------------------------------- | | botId | string | Obrigatório | O ID do seu bot no Discord. | | apiKey | string | Obrigatório | Sua API Key obtida no painel do BotGate. | | enableWebhooks | boolean | false | Ativa o servidor HTTP interno para receber votos em tempo real. | | lang | string | "pt-BR" | Idioma dos logs e respostas da API (pt-BR ou en-US). | | debug | boolean | false | Ativa logs detalhados no console para depuração. |


🛠️ Métodos Principais

| Método | Descrição | | :---------------------------- | :--------------------------------------------------------------- | | start(client) | Inicia o loop automático de estatísticas e heartbeats. | | stop() | Interrompe todos os processos em segundo plano. | | handleShardMessage(msg) | (Novo) Processa mensagens IPC para emitir eventos em Shards. | | getBotInfo() | Obtém dados completos do perfil do bot e do plano atual. | | getBotVotes(botId?, limit?) | Consulta os últimos eleitores e estatísticas de votação. | | getApiUsage() | Verifica o consumo mensal da sua cota de API. | | sendHeartbeat() | Envia um sinal de vida manual (Exclusivo para o plano Business). |


⚡ Monitoramento de Sharding

Se o seu bot utiliza ShardingManager, você deve centralizar o recebimento de Webhooks no Manager e repassar os dados para os shards.

No Manager (processo pai): Repasse as mensagens de voto para os shards. O sistema do BotGate enviará os dados para a porta 8080 do seu servidor.

No Shard (index.js):

const reporter = new BotGateReporter({
  botId: "BOT_ID",
  apiKey: "API_KEY",
  enableWebhooks: false, // Ativa o servidor interno para receber eventos (votos). OBS.: No sharding, é recomendado desativar o webhook no shard e ativar no manager.
  lang: "pt-BR",
  debug: true, // Opcional: true para logs detalhados, false para logs normais
});

// Escuta a ponte IPC entre os processos
process.on("message", (msg) => reporter.handleShardMessage(msg));

reporter.on("vote", (vote) => {
  client.users.send(vote.user_id, "Obrigado por votar! 💎");
});

🧠 Sincronização Inteligente

O @botgate/botgate-stats-reporter é reativo. Se você fizer um upgrade de plano no painel do BotGate, o bot detectará os novos limites na próxima comunicação com o servidor e ajustará o intervalo de postagem automaticamente.

  • Dual-Webhook: Alertas de erro continuam indo para o seu Discord, enquanto os dados de voto vão direto para o código do bot.
  • Upgrade (Hot-Swap): Acelera o intervalo de envio conforme o novo Tier.
  • Grace Period: Tolerância de segurança para evitar erros 429 por latência de rede.

🔗 Links Úteis

📄 Licença

Distribuído sob a licença MIT. Veja LICENSE para mais informações.