# tv-discord A Discord Activity for watching [bug.tv](https://tv.bug.tools) together. The Activity is the whole bug.tv site with a small watch-party overlay on top. Whoever starts the Activity is the **host** and controls everything. Everyone else in the call follows the host's page and playback in sync, and can only change volume and fullscreen. If the host leaves, the next person to have joined takes over. The contract is in [docs/protocol.md](docs/protocol.md). ## Layout - `src/server.js`: static files, `/api/config`, `/api/token` (OAuth code exchange), `/api/avatar/:id`, and the `/ws` relay (one hub per Activity instance). - `activity/js/discord.js`: the overlay. It handles the Discord SDK and auth, the WebSocket transport for bug.tv's `party.js`, the members pill, the viewer banner and input blocking. esbuild bundles it into `discord.js`. - `activity/overlay.css`: the overlay styles. - `scripts/build-activity.sh [apiBase=/tv]`: builds the Activity site. ## Run ```sh npm install bash scripts/build-activity.sh ../tv/web site # or nix build .#activity cp config.example.json config.json # applicationId, tokenFile, clientSecretFile npm start ``` The bot token is only used to check who is in an Activity instance; there is no gateway connection. **Discord URL mappings:** - `/` → this server - `/tv` → api-tv.bug.tools - `/tmdb` → api.themoviedb.org - `/img` → image.tmdb.org **Dev without Discord:** set `"dev": true` and `"devApiUrl": "http://127.0.0.1:8789"` (a local bug-tv API). Build the site with an absolute API base, or use the default `/tv`, which the dev server proxies. Then open `/?user=1&instance=x` and `/?user=2&instance=x` in two browsers. ## Test ```sh npm test ```