Lane 10: Discord pickers for the server, channel and voice channel (D226, #736) #904
Loading…
Reference in a new issue
No description provided.
Delete branch "build/lane10-pickers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #736 (lane 10). This builds D226, the owner's choice: pickers for all three fields, listing only the Discord servers the GM belongs to, through their own linked Discord, and only channels the bot can see. Without a link, you type the ID as before.
Bot (additive; the contract stays at v2)
GET /discord/guilds?user_id=returns the guilds the bot shares with that Discord user. It never includes a guild the user isn't in.GET /discord/channels?user_id=&guild_id=first re-checks that the user is a member of that guild and returns 404 if not. It then lists the text and voice channels the bot canview_channel.Backend
GET /campaigns/{id}/discord-guildsand…/discord-guilds/{guild_id}/channels, bothrequire_gm.guild_idin the path is untrusted, and the bot re-validates it.{linked: false}without calling the bot;The page (Settings → Discord)
Render check (real stack)
scrollWidth <= innerWidth. I looked at them myself.Checks
changelog.d/fragment.🤖 Generated with Claude Code
GET /api/campaigns/{id}/discord-guilds and .../discord-guilds/{guild_id}/channels back Settings -> Discord's three pickers. Gated by require_gm, so a player or a GM of another campaign is refused (403) before the body runs. The only Discord id these routes ever ask the bot about is the signed-in GM's own verified platform_links row -- never anything from the client -- and an unlinked or unverified GM gets {linked: false} with no bot call at all, matching the typed-ID fallback. A guild_id the client sends is not trusted either: the bot re-checks that guild against the GM's own Discord id and a refusal there passes straight through as 404. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>Server, channel and voice channel each become a <select> once the signed-in GM's own Discord is linked and the bot has answered GET /api/campaigns/{id}/discord-guilds and .../discord-guilds/{guild}/channels. Every other case -- no verified link, the bot unreachable, the bot in none of this GM's servers, or a GM who simply clicks "Type IDs instead" -- falls back to the typed-ID fields the page already had. A stored id no longer in the bot's answer (deleted in Discord, or hidden from the bot) stays selected as its own option with a "can't see it any more" warning (IS-458), rather than silently reading as "none". Also adds the voice channel field this page never had (D159's backend support landed earlier without a frontend to go with it). CampaignSettingsDiscord.test.jsx: existing tests default fetchDiscordGuilds to {linked: false}, which is also the typed-ID-fallback scenario they were already describing, so nothing about them changed in substance. Added coverage for the linked/picker, gone, nobot, unreachable and manual-toggle states. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>