@originchats/discord
v0.1.3
Published
OriginChats-compatible server that bridges a user's Discord token to Discord guilds over the OriginChats WebSocket protocol
Readme
@originchats/discord
Bridges Discord and Spacebar backends to the OriginChats wire protocol.
Provides two integration modes:
- Browser Translation Layer: A zero-dependency browser client (
SpacebarClient) letting web applications connect directly to Discord/Spacebar via standardfetchandWebSocket. - Bridge Server: A local WebSocket bridge daemon allowing standard OriginChats clients to access Discord servers and DMs via a guest lobby and slash commands.
Quick Start
npm install
npm run build
npm test # runs browser unit tests
npm start # starts bridge on ws://localhost:4123/1. Browser Client Usage
import { SpacebarClient } from "@originchats/discord/browser";
const client = new SpacebarClient({
apiBase: "https://discord.com/api/v9",
gatewayUrl: "wss://gateway.discord.gg/?v=9&encoding=json",
cdnBase: "https://cdn.discordapp.com",
onPacket: (frame) => console.log("Received:", frame.cmd, frame),
});
await client.login({ token: "YOUR_DISCORD_OR_SPACEBAR_TOKEN" });
client.connect();
// Send an OriginChats frame
await client.send({
cmd: "message_new",
channel: "general",
content: "Hello from OriginChats!",
});See the Browser Translation Layer Guide for full API reference and examples.
2. Local Bridge Server Usage
PORT=4123 npm startConnect any OriginChats client to ws://localhost:4123/. You land in #cmds where you can authenticate and manage servers safely:
/login <token> [server]— connect with your Discord user token./guilds— list available servers./connect <name|number|id|dms>— switch servers or jump to DMs./dms— view direct messages./join <invite>— join a server by invite./logout— disconnect back to the guest lobby.
See the Bridge Server Documentation for configuration options and persistence details.
Documentation
- Browser Translation Layer: Architecture, client lifecycle, methods, and web integration.
- Bridge Server: Server setup, environment variables, slash commands, and local storage.
- Protocol Mapping Reference: How channels, threads, messages, reactions, roles, and presences map between systems.
