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

@lacunahub/letsfrag

v2.1.0

Published

Distributed Discord bot sharding with Redis-based orchestration

Downloads

183

Readme

About

Distributed sharding library for Discord.js bots with automatic shard assignment and rebalancing. This package is inspired by discord-hybrid-sharding.

Architecture Overview

flowchart TD
    Redis[(Redis)]
    ClusterBroker((ClusterBroker))
    BrokerClient([BrokerClient])
    ClusterManager{ClusterManager}
    Cluster0(Cluster)
    Cluster1(Cluster)
    Client0{{Client}}
    Client1{{Client}}
    Client2{{Client}}
    Client3{{Client}}

    Redis <-->|"PubSub"| ClusterBroker
    Redis <-->|"PubSub"| BrokerClient
    BrokerClient <--> ClusterManager
    ClusterManager <--> Cluster0
    ClusterManager <--> Cluster1
    Cluster0 <-->|"IPC"| Client0
    Cluster0 <-->|"IPC"| Client1
    Cluster1 <-->|"IPC"| Client2
    Cluster1 <-->|"IPC"| Client3

How It Works

  1. ClusterBroker manages shard distribution
  2. Each ClusterManager connects to the ClusterBroker via BrokerClient and spawns assigned shards
  3. All communication between ClusterBroker and BrokerClient happens through Redis PubSub channels

Key Features

  • Redis PubSub: Fast, reliable inter-process communication using Redis
  • Distributed architecture: Scale across unlimited hosts/machines
  • Automatic shard distribution: ClusterBroker automatically assigns shards to available cluster managers
  • Health monitoring: Automatic respawn of dead shards
  • Hot reload: Add or remove managers without restarting the entire system
  • Type-Safe: Full TypeScript support with proper typings

Links

Installation

Using NPM Registry

npm install @lacunahub/letsfrag

Using GitHub Packages Registry

  1. Create a GitHub Personal Access Token with read:packages scope

  2. Add to your shell profile (.bashrc, .zshrc, or .profile):

export GITHUB_TOKEN=your_token_here
  1. In your project directory, create .npmrc:
@lacunahub:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
  1. Install:
npm install @lacunahub/letsfrag

Alternative: npm login

Authenticate once with GitHub Packages:

npm login --registry=https://npm.pkg.github.com --scope=@lacunahub
# Username: your-github-username
# Password: your-personal-access-token (with read:packages scope)
# Email: your-email

Then install normally:

npm install @lacunahub/letsfrag

See Working with the npm registry for more information.

Usage

Prerequisites

You need a Redis server running. You can use Docker:

docker run -d -p 6379:6379 redis:latest

File structure

├── src
│   ├── client.ts
│   ├── cluster.ts
│   └── broker.ts
└── package.json
import { ClusterBroker } from '@lacunahub/letsfrag'

const broker = new ClusterBroker({
    redisURI: 'redis://localhost:6379',
    botToken: process.env.BOT_TOKEN
})

broker.on('ready', () => console.info('ClusterBroker is ready'))
broker.on('error', err => console.error(err))
broker.on('clientConnect', client => console.info(`Client "${client.id}" connected`))

broker.initialize()

src/cluster.ts

import { ClusterManager } from '@lacunahub/letsfrag'

const clusterManager = new ClusterManager(`${__dirname}/client.js`, {
    brokerClient: {
        redisURI: 'redis://localhost:6379'
    }
})

clusterManager.on('ready', manager => console.info(`Manager with clusters (${manager.clusters}) is ready`))
clusterManager.on('clusterCreate', cluster => console.info(`Cluster #${cluster.id} has been created`))

clusterManager.register()

src/client.ts

import { ClusterClient } from '@lacunahub/letsfrag'
import { GatewayIntentBits } from 'discord.js'

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

client.login()

License

This project is licensed under the MIT License.