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

topgg-vote-logger

v1.0.1

Published

Log top.gg votes to Supabase and send custom embeds to Discord webhooks with user streaks and custom formatting

Readme

topgg-vote-logger

NPM Version NPM Downloads License

A database-agnostic, Discord-bot-focused NPM package for tracking, logging, and rewarding Top.gg votes. It includes custom database integrations and premium Discord webhook log embeds.

Features

  • Database Agnostic: Use any database (Postgres, MongoDB, MySQL, Prisma, Redis, etc.) by implementing a simple adapter interface.
  • Built-in Supabase Adapter: Start immediately with Supabase out-of-the-box.
  • Streak System: Tracks consecutive votes, automatically resetting streaks if more than 36 hours pass between votes.
  • Discord Lookup Integration: Resolves current Discord username and avatar dynamically.
  • Premium Discord Webhook Log: Sends customized, modern Discord embed logs to your log channel.

Installation

npm install topgg-vote-logger

Database Adapters

1. Default Supabase Setup

Initialize the logger with Supabase credentials:

import { TopGGVoteLogger } from 'topgg-vote-logger';

const logger = new TopGGVoteLogger({
  supabaseUrl: 'YOUR_SUPABASE_URL',
  supabaseKey: 'YOUR_SUPABASE_SERVICE_ROLE_KEY',
  topggWebhookSecret: 'YOUR_WEBHOOK_SECRET',
  discordBotToken: 'YOUR_DISCORD_BOT_TOKEN', // Optional
  discordWebhookUrl: 'YOUR_DISCORD_WEBHOOK_URL', // Optional
  botName: '@MyAwesomeBot', // Optional
  embedColor: 0xff477e, // Optional: Border color (hex integer)
  embedTitle: 'Vote Logged', // Optional: Custom embed title. Supports {username}, {userId}
  embedDescription: '**{username}** has supported the bot!' // Optional: Custom description. Supports {username}, {userId}, {streak}, {totalVotes}
});

Create the SQL schema in your Supabase SQL editor:

create table votes (
  id bigint generated by default as identity primary key,
  created_at timestamp with time zone default timezone('utc'::text, now()) not null,
  user_id text not null,
  bot_id text not null,
  is_weekend boolean not null default false,
  username text,
  avatar_url text,
  streak integer not null default 1,
  total_votes_at_time integer not null default 1
);

2. Custom Database Adapter (Prisma, MongoDB, MySQL, etc.)

To use any other database, implement the IDatabaseAdapter interface and pass it as dbAdapter. See the Database Adapters Guide for full instructions and examples.

import { TopGGVoteLogger } from 'topgg-vote-logger';

// Example: In-Memory Adapter
const myDatabaseAdapter = {
  async getVoteCount(userId) {
    // Return total votes count
  },

  async getLastVote(userId) {
    // Return last vote time and streak
  },

  async saveVote(record) {
    // Save vote record
  },

  async getLeaderboard(limit) {
    // Return monthly leaderboard
  }
};

const logger = new TopGGVoteLogger({
  dbAdapter: myDatabaseAdapter,
  topggWebhookSecret: 'YOUR_WEBHOOK_SECRET',
  discordWebhookUrl: 'YOUR_DISCORD_WEBHOOK_URL'
});

Quick Start (Express Webhook Endpoint)

See the Webhook Setup Guide for details on portal integration.

import express from 'express';

const app = express();
app.use(express.json());

app.post('/api/webhook', async (req, res) => {
  const auth = req.headers.authorization;

  // 1. Verify top.gg authorization header
  if (!logger.verifyWebhook(auth)) {
    return res.status(401).json({ error: 'Unauthorized' });
  }

  try {
    // 2. Process vote and log/save
    const result = await logger.handleWebhook(req.body);
    return res.status(200).json({ message: 'Success', result });
  } catch (error) {
    console.error('Webhook error:', error);
    return res.status(500).json({ error: 'Internal Server Error' });
  }
});

app.listen(3000);

Documentation


License

MIT