# Discord Bot — BridgeSwarm.DiscordJS ## What this example does Runs an official **discord.js 14** bot from the page. The real `Client` lives in the Bare native host (`bare-discord-js`); the page uses `BridgeSwarm.DiscordJS` (`Client`, `GatewayIntentBits`, `Events`, `SlashCommandBuilder`, `REST`, `Routes`). `/ping` replies `pong`. Channel text `ping` → `pong` only if you enable Message Content Intent in the Developer Portal and check the box on this page. ## Prerequisites 1. Install the [BridgeSwarm extension and native host](../../README.md#easy-install-recommended). 2. Control Center → Settings → **Enable Discord**. 3. Create a Discord application → Bot → Reset Token. Copy the **bot token** (not the OAuth2 client secret). ## How to run **Recommended:** Extension Settings → enable **Examples server**, then open the demo URL below. Dev alternative from the repo root: ```bash npm run examples ``` Open **http://127.0.0.1:4173/discord-bot/**. Do not use `file://`. ## Usage 1. Paste the bot token (kept in this tab only). 2. Optionally paste a guild id so `/ping` registers immediately. 3. Click **Login**. Watch the log for `Logged in as …`. 4. In Discord, run `/ping`. Click **Destroy** when finished. See [docs/DISCORD.md](../../docs/DISCORD.md) for the API, the cache fidelity gap, and packing notes. ## Files in this directory - **index.html** — Token / guild / login UI - **app.js** — `new Client`, slash registration, ping/pong - **style.css** — Layout