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

@pioneer-platform/discord

v1.2.0

Published

Discord integration for Pioneer platform - Redis to Discord bridge

Readme

@pioneer-platform/discord

Discord integration for Pioneer Platform - Redis to Discord event bridge.

Overview

This module subscribes to Redis pub/sub channels and forwards events to Discord channels. It's designed to monitor server health, errors, and important events in real-time.

Features

  • 🔄 Redis → Discord Bridge: Subscribe to Redis channels, forward to Discord
  • 🎨 Rich Embeds: Color-coded messages with severity levels
  • 📊 Event Formatting: Structured event display with fields
  • Real-time: Instant notification delivery
  • 🛡️ Error Handling: Robust error recovery

Installation

bun install
bun run build

Configuration

Required environment variables:

# Discord Bot Configuration
KEEPKEY_DISCORD_BOT_TOKEN=<your-bot-token>
KEEPKEY_BOT_NAME=pioneer
KEEPKEY_DISCORD_BOT_CHANNEL=keepkey-events

# Optional
DISCORD_ADMIN_USERID=<discord-user-id>

# Redis Connection
REDIS_CONNECTION=redis://localhost:6379
# or
REDIS_CONNECTION_PROD=rediss://...

Usage

Basic Usage

import { createDiscordBridge } from '@pioneer-platform/discord';
import Redis from 'ioredis';

const redis = new Redis(process.env.REDIS_CONNECTION);

const bridge = await createDiscordBridge({
  botToken: process.env.KEEPKEY_DISCORD_BOT_TOKEN!,
  botName: 'pioneer',
  defaultChannel: 'keepkey-events',
  redisChannels: ['keepkey-events']
}, redis);

// Bridge is now listening and will forward events

Publishing Events

import { publisher } from '@pioneer-platform/default-redis';

// Publish an event
await publisher.publish('keepkey-events', JSON.stringify({
  type: 'server_startup',
  service: 'pioneer-server',
  level: 'success',
  message: 'Server started successfully',
  timestamp: new Date().toISOString(),
  details: {
    port: '9001',
    environment: 'production'
  }
}));

Event Format

Events should follow this structure:

interface DiscordEvent {
  type: string;                  // Event type (e.g., 'server_startup', 'error')
  service?: string;              // Service name (e.g., 'pioneer-server')
  level?: 'info' | 'success' | 'warning' | 'error' | 'critical';
  message: string;               // Main message
  timestamp?: string;            // ISO timestamp
  details?: Record<string, any>; // Additional fields
}

Severity Levels

| Level | Color | Icon | Use Case | |-------|-------|------|----------| | info | Blue | ℹ️ | General information | | success | Green | ✅ | Successful operations | | warning | Orange | ⚠️ | Non-critical issues | | error | Red | ❌ | Errors | | critical | Dark Red | 🚨 | Critical failures |

Testing

Standalone Test

# Set environment variables in .env file
KEEPKEY_DISCORD_BOT_TOKEN=...
REDIS_CONNECTION_PROD=...

# Run the test
bun run src/test.ts

This will:

  1. Connect to Discord
  2. Subscribe to keepkey-events Redis channel
  3. Publish 5 test events with different severity levels
  4. Verify they appear in Discord

Example Events

Server Startup:

{
  "type": "server_startup",
  "service": "pioneer-server",
  "level": "success",
  "message": "Pioneer Server started successfully",
  "details": {
    "port": "9001",
    "environment": "production"
  }
}

Error:

{
  "type": "database_error",
  "service": "pioneer-server",
  "level": "error",
  "message": "Failed to connect to MongoDB",
  "details": {
    "error": "Connection timeout",
    "retries": 3
  }
}

Discord Bot Setup

  1. Create Discord Application:

    • Go to https://discord.com/developers/applications
    • Click "New Application"
    • Name it "Pioneer Bot"
  2. Create Bot:

    • Go to "Bot" tab
    • Click "Add Bot"
    • Copy the token → KEEPKEY_DISCORD_BOT_TOKEN
  3. Bot Permissions:

    • Enable "Message Content Intent"
    • Required permissions:
      • Send Messages
      • Embed Links
      • Read Message History
  4. Invite Bot to Server:

    • Go to "OAuth2" → "URL Generator"
    • Select scopes: bot
    • Select permissions: 2048 (Send Messages), 16384 (Embed Links)
    • Use generated URL to invite bot
  5. Create Channel:

    • Create #keepkey-events channel in your Discord server
    • Bot will automatically find it by name

Integration with Pioneer Server

See ../../services/pioneer-server/docs/DISCORD_INTEGRATION.md for server integration details.

API Reference

DiscordBridge

class DiscordBridge {
  constructor(config: DiscordConfig, redis: Redis)
  async start(): Promise<void>
  async stop(): Promise<void>
  isConnected(): boolean
  getClient(): Client
}

createDiscordBridge

function createDiscordBridge(
  config: DiscordConfig,
  redis: Redis
): Promise<DiscordBridge>

Troubleshooting

Bot doesn't connect

  • Verify KEEPKEY_DISCORD_BOT_TOKEN is correct
  • Check bot has "Message Content Intent" enabled
  • Ensure bot is invited to server

Messages don't appear in Discord

  • Verify channel name matches KEEPKEY_DISCORD_BOT_CHANNEL
  • Check bot has permissions in the channel
  • Look for errors in logs

Redis connection fails

  • Verify REDIS_CONNECTION_PROD is correct
  • Check Redis server is accessible
  • Confirm Redis channels match configuration

License

MIT