OriginBridge is a Node.js script that bridges messages between a Discord and OriginChat.
- Listens for new messages in a specified Discord channel using a Discord bot.
- Forwards those messages to an external chat service via a WebSocket connection.
- Receives messages from the WebSocket and posts them into the Discord channel.
- The script connects to Discord using the
discord.jslibrary and logs in as a bot. - It establishes a WebSocket connection to the OriginChat server using the
wslibrary. - When a message is posted in the Discord channel (and not by a bot), the script sends the message content to the WebSocket server in JSON format.
- When a new message is received from the WebSocket server, the script posts it to the Discord channel.
- The script handles authentication with the WebSocket server using a handshake and validator key process.
- Node.js and npm installed on your system.
- Discord bot token and channel ID.
- Clone or download this repository.
- Open a terminal in the project directory.
- Install dependencies:
npm install discord.js ws
- Update the bot tokens and channel IDs in
index.jswith your own credentials for security and proper operation. - Make sure your Discord bot is invited to your server and has permission to read and send messages in the target channel.
- Start the script:
node index.js
- The script will log in to Discord and connect to the WebSocket server. Messages will be bridged automatically.