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

@sharptrick/parley-discord

v0.8.0

Published

@sharptrick/parley-discord — hosted-SaaS chat backend (message snowflake = cursor, gateway websocket MESSAGE_CREATE = subscribe, channel = topic) against the frozen Parley seam.

Readme

@sharptrick/parley-discord

A Parley backend plugin that carries topics over Discord channels, spoken to via the raw REST v10 API with the global fetch plus a minimal gateway websocket subset (ws) — no discord.js dependency.

It implements the frozen seam (connect / disconnect / subscribe / post / fetchRecent / resolveIdentity); adding it required zero changes to @sharptrick/parley-core.

Positioning: hosted SaaS. Discord is a hosted SaaS, unlike the self-hosted core backends — history durability, availability, and identity live under Discord's policy, not yours. There is no server you run, no retention knob you own, and no export path this plugin can promise. Choose it when your humans already live in Discord; choose a self-hosted backend (SQLite/Redis/Matrix/XMPP/NATS) when the transcript itself must be under your control.

Seam mapping

| Seam concept | Discord mapping | | ------------------------- | --------------- | | connect(config) | Stores config; auth is stateless per request (Authorization: Bot <token>). The gateway socket opens lazily on first subscribe. | | topic → channel | channel_map[topic] if present; otherwise the topic string is used as a channel id literal — the zero-config path when topics simply are channel ids. | | post | POST /channels/<id>/messages { content, message_reference? } → returns the message id. inReplyTo maps to message_reference.message_id (a native Discord reply). | | backendMsgId = cursor | The message snowflake id — time-ordered and strictly increasing per channel; serves as both the dedup key and the order key. Snowflakes are decimal strings and not lexically comparable; ordering is delegated to the API (core never compares cursors either). | | fetchRecent (no since) | GET /channels/<id>/messages?limit=N (newest-first) → reverse to ascending. The API caps a page at 100 — that cap is the default window. | | fetchRecent (since) | GET /channels/<id>/messages?after=<since>&limit=nafter is exclusive server-side; each newest-first page is reversed, and for limit > 100 the plugin pages forward advancing after until filled or a short page. | | subscribe | One shared gateway websocket per plugin instance: HELLO → IDENTIFY (intents GUILDS \| GUILD_MESSAGES \| MESSAGE_CONTENT) → READY, then MESSAGE_CREATE dispatch per subscribed channel — including the bot's own sends. Starts at the tail; history is owned by catch-up. Reconnect re-IDENTIFYs (no RESUME — the push gap is harmless; cursor catch-up reconciles). | | resolveIdentity | GET /users/@me (memoized): our own bot handle resolves to its real user id; every other handle passes through as a string convention — Discord has no global name → id lookup. |

senderHandleauthor.username, contentcontent, timestamp ← the message timestamp (informational only — never used for ordering or dedup).

post's identity argument (your config's identity.handle) is not used. Discord stamps author from whichever bot token is configured — see "Multiple concurrent sessions".

Config (backend_config)

| key | default | meaning | | ------------- | ----------------------------- | ------- | | token | (unset) | Bot token (secret — .env, never committed). | | api_url | https://discord.com/api/v10 | REST base URL. Tests point this at an in-process fake. | | gateway_url | (unset) | Gateway websocket URL override (tests/fakes). Default: resolved live via GET /gateway/bot. | | channel_map | {} | Parley topic → channel id. Unmapped topics are used as channel ids directly. |

Provisioning the bot (pointers, not infra)

Everything happens in the Discord developer portal — this package authors none of it:

  1. Create an application → Bot → copy the token into backend_config.token (via .env).
  2. On the same Bot page, toggle on the MESSAGE CONTENT privileged intent — without it, MESSAGE_CREATE events arrive with empty content.
  3. Invite the bot to your server via the OAuth2 URL generator with the bot scope and permissions to View Channels, Send Messages, and Read Message History in the channels you'll map as topics.

Multiple concurrent sessions (one backend_config per config file, same bot)

Any number of bridge instances — one per Claude Code session plus the remote/chat server — may share a single bot: each post is an independent REST call, snowflake minting is Discord's and globally consistent, and each instance holds its own gateway socket. The tradeoff: every post from every session is attributed to the bot identity (author = the bot), because the seam's identity argument cannot override the token's account. If per-session attribution in the Discord transcript matters, provision a distinct application/bot token per session and put it in that session's backend_config — the same role identity.handle plays for SQLite/Redis/NATS, just carried in the token. channel_map must agree across configs that share topics; api_url/gateway_url only ever vary for tests.

Tests

npx vitest run packages/bridge-discord

The shared seam conformance suite (@sharptrick/parley-conformance) runs against an in-process fake (test/fake-discord.ts) that speaks the same REST + gateway subset — hermetic, no credentials, always on. To exercise a real server manually: put a real token in backend_config, use a real channel id as the topic (or map one in channel_map), and drive post/fetchRecent/subscribe from a scratch script — mind Discord's rate limits (the plugin honors 429 retry_after automatically).