Discord Gateway Registry (monitor/gateway-registry.ts)

openclaw-zero-token · extensions/discord/src/monitor/gateway-registry.ts · typescript · MIT
integration, chat, infra, realtime, tag:registry, tag:carbon

Module-level registry mapping account IDs to active Discord GatewayPlugin instances, bridging tool handlers to the gateway WebSocket for operations like presence updates. Reuse when tools need gateway access beyond REST.

// Source: https://github.com/linuxhsj/openclaw-zero-token | License: MIT | Copyright 2025 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
import type { GatewayPlugin } from "@buape/carbon/gateway";

/**
 * Module-level registry of active Discord GatewayPlugin instances.
 * Bridges the gap between agent tool handlers (which only have REST access)
 * and the gateway WebSocket (needed for operations like updatePresence).
 * Follows the same pattern as presence-cache.ts.
 */
const gatewayRegistry = new Map<string, GatewayPlugin>();

// Sentinel key for the default (unnamed) account. Uses a prefix that cannot
// collide with user-configured account IDs.
const DEFAULT_ACCOUNT_KEY = "\0__default__";

function resolveAccountKey(accountId?: string): string {
  re

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key