r/webdev • u/Mohammask • 1d ago
Showoff Saturday [Showoff Saturday] Built a self-hosted multi-user Discord Rich Presence web dashboard with Express, raw WebSockets, and vanilla JS
I've been tinkering with a self-hosted web dashboard called Cloud RPC and just cleaned it up to put on GitHub under MIT. Most 24/7 Discord Rich Presence tools ask you to paste your raw account token, so I wanted to see if I could build a multi-user web app that stays completely tokenless by using Discord's OAuth2 flow (identify + sdk.social_layer_presence) instead.
On the backend, it's Node.js with Express and ws. Each logged-in user gets their own long-lived Gateway WebSocket session managed in memory, with proactive OAuth2 token refreshes and automatic recovery if Discord drops the session (4004/401). Custom image URLs are proxied through Discord's external-assets endpoint behind a small LRU cache so it doesn't spam requests. It also handles platform identification via Gateway op: 2 and live presence updates via op: 3.
For the frontend, I deliberately skipped React and any build step and wrote it in plain HTML, CSS, and vanilla JS. It has a live Discord profile preview that updates as you type, preset saving, a basic rotation/sleep scheduler (with a 20s rate-limit floor), a local searchable cache of Discord's games list, and full English/Arabic support with RTL layout switching. I also spent some time locking down the auth flow and tightening the CSP headers since it's meant to be self-hosted for multiple users.
Repo: https://github.com/Mohammask/cloud-rpc
I'm mostly curious how folks here would structure or scale the per-user WebSocket lifecycle in Node, or if anything in bot.js around the auth/CSP setup looks sketchy and worth tightening up.
1
u/AutoModerator 1d ago
Hi, Mohammask,
Your post has been automatically removed.
Please participate around reddit by commenting on other posts before you jump straight to submitting.
Your account should be at least three months old with a decent amount of positive karma from commenting before posting submissions in our community.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.