Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["5197"],{31669(e,r,s){s.r(r),s.d(r,{metadata:()=>n,default:()=>h,frontMatter:()=>t,contentTitle:()=>c,toc:()=>o,assets:()=>l});var n=JSON.parse('{"id":"integrations/discord","title":"Discord","description":"Mercury connects to Discord as a bot, providing a real-time conversational interface with slash commands, streaming responses, rich embeds, and an organization-style access model with admin roles and pairing codes.","source":"@site/docs/integrations/discord.mdx","sourceDirName":"integrations","slug":"/integrations/discord","permalink":"/docs/integrations/discord","draft":false,"unlisted":false,"editUrl":"https://github.com/cosmicstack-labs/mercury-agent/tree/main/website/docs/integrations/discord.mdx","tags":[],"version":"current","frontMatter":{"id":"discord","title":"Discord"},"sidebar":"docsSidebar","previous":{"title":"Telegram","permalink":"/docs/integrations/telegram"},"next":{"title":"Slack","permalink":"/docs/integrations/slack"}}'),i=s(74848),d=s(28453);let t={id:"discord",title:"Discord"},c,l={},o=[{value:"Prerequisites",id:"prerequisites",level:2},{value:"Setup",id:"setup",level:2},{value:"Step 1: Create a Discord Application",id:"step-1-create-a-discord-application",level:3},{value:"Step 2: Invite the Bot to Your Server",id:"step-2-invite-the-bot-to-your-server",level:3},{value:"Step 3: Create an Admin Role (Optional)",id:"step-3-create-an-admin-role-optional",level:3},{value:"Step 4: Configure Mercury",id:"step-4-configure-mercury",level:3},{value:"Step 5: Pair",id:"step-5-pair",level:3},{value:"Access Model",id:"access-model",level:2},{value:"CLI Commands",id:"cli-commands",level:3},{value:"Features",id:"features",level:2},{value:"Configuration Reference",id:"configuration-reference",level:2},{value:"Troubleshooting",id:"troubleshooting",level:2}];function a(e){let r={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.p,{children:"Mercury connects to Discord as a bot, providing a real-time conversational interface with slash commands, streaming responses, rich embeds, and an organization-style access model with admin roles and pairing codes."}),"\n",(0,i.jsx)(r.h2,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["A ",(0,i.jsx)(r.strong,{children:"Discord account"})," with permission to manage a server (or create one)."]}),"\n",(0,i.jsxs)(r.li,{children:["A ",(0,i.jsx)(r.strong,{children:"Discord Bot Token"})," from the ",(0,i.jsx)(r.a,{href:"https://discord.com/developers/applications",children:"Discord Developer Portal"}),"."]}),"\n",(0,i.jsxs)(r.li,{children:["A ",(0,i.jsx)(r.strong,{children:"server (guild)"})," where you have admin privileges to invite the bot."]}),"\n"]}),"\n",(0,i.jsx)(r.admonition,{title:"Platform note",type:"warning",children:(0,i.jsxs)(r.p,{children:["Discord integration requires Node.js 18 or later (the ",(0,i.jsx)(r.code,{children:"discord.js"})," v14 dependency). The standalone binary includes all necessary dependencies automatically."]})}),"\n",(0,i.jsx)(r.h2,{id:"setup",children:"Setup"}),"\n",(0,i.jsx)(r.h3,{id:"step-1-create-a-discord-application",children:"Step 1: Create a Discord Application"}),"\n",(0,i.jsxs)(r.ol,{children:["\n",(0,i.jsxs)(r.li,{children:["Go to ",(0,i.jsx)(r.a,{href:"https://discord.com/developers/applications",children:"Discord Developer Portal"})," and click ",(0,i.jsx)(r.strong,{children:"New Application"}),"."]}),"\n",(0,i.jsxs)(r.li,{children:['Give it a name (e.g. "Mercury") and click ',(0,i.jsx)(r.strong,{children:"Create"}),"."]}),"\n",(0,i.jsxs)(r.li,{children:["Navigate to ",(0,i.jsx)(r.strong,{children:"Bot"})," in the left sidebar and click ",(0,i.jsx)(r.strong,{children:"Reset Token"})," to generate a bot token. Copy it \u2014 you'll need it in Step 4."]}),"\n",(0,i.jsxs)(r.li,{children:["Under ",(0,i.jsx)(r.strong,{children:"Privileged Gateway Intents"}),", enable:","\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:[(0,i.jsx)(r.strong,{children:"Message Content Intent"})," \u2014 required for Mercury to read your messages."]}),"\n",(0,i.jsxs)(r.li,{children:[(0,i.jsx)(r.strong,{children:"Server Members Intent"})," \u2014 required for the access control system."]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["Click ",(0,i.jsx)(r.strong,{children:"Save Changes"}),"."]}),"\n"]}),"\n",(0,i.jsx)(r.h3,{id:"step-2-invite-the-bot-to-your-server",children:"Step 2: Invite the Bot to Your Server"}),"\n",(0,i.jsxs)(r.ol,{children:["\n",(0,i.jsxs)(r.li,{children:["Navigate to ",(0,i.jsx)(r.strong,{children:"OAuth2"})," \u2192 ",(0,i.jsx)(r.strong,{children:"URL Generator"})," in the left sidebar."]}),"\n",(0,i.jsxs)(r.li,{children:["Under ",(0,i.jsx)(r.strong,{children:"Scopes"}),", select: ",(0,i.jsx)(r.code,{children:"bot"}),", ",(0,i.jsx)(r.code,{children:"applications.commands"}),"."]}),"\n",(0,i.jsxs)(r.li,{children:["Under ",(0,i.jsx)(r.strong,{children:"Bot Permissions"}),", select:","\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"Send Messages"}),"\n",(0,i.jsx)(r.li,{children:"Read Message History"}),"\n",(0,i.jsx)(r.li,{children:"Use Slash Commands"}),"\n",(0,i.jsx)(r.li,{children:"Attach Files"}),"\n",(0,i.jsx)(r.li,{children:"Embed Links"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(r.li,{children:"Copy the generated URL and open it in your browser to invite the bot to your server."}),"\n"]}),"\n",(0,i.jsx)(r.h3,{id:"step-3-create-an-admin-role-optional",children:"Step 3: Create an Admin Role (Optional)"}),"\n",(0,i.jsxs)(r.ol,{children:["\n",(0,i.jsxs)(r.li,{children:["In your Discord server, go to ",(0,i.jsx)(r.strong,{children:"Server Settings"})," \u2192 ",(0,i.jsx)(r.strong,{children:"Roles"}),"."]}),"\n",(0,i.jsxs)(r.li,{children:["Create a role named ",(0,i.jsx)(r.strong,{children:"Mercury Admin"})," (or any name you prefer)."]}),"\n",(0,i.jsx)(r.li,{children:"Assign this role to yourself and anyone else who should have admin control over Mercury."}),"\n"]}),"\n",(0,i.jsx)(r.h3,{id:"step-4-configure-mercury",children:"Step 4: Configure Mercury"}),"\n",(0,i.jsxs)(r.p,{children:["Run ",(0,i.jsx)(r.code,{children:"mercury doctor"})," and select Discord when prompted, or set these environment variables:"]}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-bash",children:'# Required\nDISCORD_ENABLED=true\nDISCORD_BOT_TOKEN=your-bot-token-here\n\n# Optional \u2014 restrict to a specific server\nDISCORD_GUILD_ID=\n\n# Optional \u2014 restrict to a specific channel\nDISCORD_CHANNEL_ID=\n\n# Optional \u2014 admin role name (default: "Mercury Admin")\nDISCORD_ADMIN_ROLE_NAME=Mercury Admin\n\n# Optional \u2014 enable streaming (edit-in-place) responses (default: true)\nDISCORD_STREAMING=true\n'})}),"\n",(0,i.jsxs)(r.p,{children:["Or add them to ",(0,i.jsx)(r.code,{children:"~/.mercury/.env"}),"."]}),"\n",(0,i.jsx)(r.h3,{id:"step-5-pair",children:"Step 5: Pair"}),"\n",(0,i.jsxs)(r.ol,{children:["\n",(0,i.jsxs)(r.li,{children:["Start Mercury: ",(0,i.jsx)(r.code,{children:"mercury up"})]}),"\n",(0,i.jsxs)(r.li,{children:["In Discord, type ",(0,i.jsx)(r.code,{children:"/start"})," in any channel where the bot is present."]}),"\n",(0,i.jsxs)(r.li,{children:["Mercury will display a ",(0,i.jsx)(r.strong,{children:"pairing code"}),". Enter it in the CLI:","\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-bash",children:"mercury discord pair <code>\n"})}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["You are now the Discord admin. Other users can request access with ",(0,i.jsx)(r.code,{children:"/start"}),", and you can approve them."]}),"\n"]}),"\n",(0,i.jsx)(r.h2,{id:"access-model",children:"Access Model"}),"\n",(0,i.jsxs)(r.p,{children:["Mercury Discord uses an ",(0,i.jsx)(r.strong,{children:"organization access model"})," with admins and members."]}),"\n",(0,i.jsxs)(r.table,{children:[(0,i.jsx)(r.thead,{children:(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.th,{children:"Role"}),(0,i.jsx)(r.th,{children:"Description"}),(0,i.jsx)(r.th,{children:"Can approve requests?"})]})}),(0,i.jsxs)(r.tbody,{children:[(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.strong,{children:"Admin"})}),(0,i.jsx)(r.td,{children:"First user to pair (or anyone with the configured admin role). Can approve/reject access requests, promote/demote users."}),(0,i.jsx)(r.td,{children:"Yes"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.strong,{children:"Member"})}),(0,i.jsx)(r.td,{children:"Approved by an admin. Can send messages and receive responses."}),(0,i.jsx)(r.td,{children:"No"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.strong,{children:"Pending"})}),(0,i.jsxs)(r.td,{children:["Sent ",(0,i.jsx)(r.code,{children:"/start"})," but not yet approved."]}),(0,i.jsx)(r.td,{children:"No"})]})]})]}),"\n",(0,i.jsx)(r.h3,{id:"cli-commands",children:"CLI Commands"}),"\n",(0,i.jsxs)(r.table,{children:[(0,i.jsx)(r.thead,{children:(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.th,{children:"Command"}),(0,i.jsx)(r.th,{children:"Description"})]})}),(0,i.jsxs)(r.tbody,{children:[(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord list"})}),(0,i.jsx)(r.td,{children:"Show approved admins, members, and pending requests"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord approve <userId>"})}),(0,i.jsx)(r.td,{children:"Approve a pending request by Discord user ID"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord reject <userId>"})}),(0,i.jsx)(r.td,{children:"Reject a pending request"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord remove <userId>"})}),(0,i.jsx)(r.td,{children:"Remove an approved admin or member"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord promote <userId>"})}),(0,i.jsx)(r.td,{children:"Promote a member to admin"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord demote <userId>"})}),(0,i.jsx)(r.td,{children:"Demote an admin to member"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"mercury discord reset"})}),(0,i.jsx)(r.td,{children:"Clear all Discord access (start fresh)"})]})]})]}),"\n",(0,i.jsx)(r.h2,{id:"features",children:"Features"}),"\n",(0,i.jsxs)(r.table,{children:[(0,i.jsx)(r.thead,{children:(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.th,{children:"Feature"}),(0,i.jsx)(r.th,{children:"Description"})]})}),(0,i.jsxs)(r.tbody,{children:[(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"Slash commands"}),(0,i.jsxs)(r.td,{children:["Built-in ",(0,i.jsx)(r.code,{children:"/start"}),", ",(0,i.jsx)(r.code,{children:"/status"}),", ",(0,i.jsx)(r.code,{children:"/progress"}),", ",(0,i.jsx)(r.code,{children:"/permissions"}),", ",(0,i.jsx)(r.code,{children:"/models"}),", and more"]})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"Streaming responses"}),(0,i.jsxs)(r.td,{children:["Messages are edited in place as tokens arrive (toggle with ",(0,i.jsx)(r.code,{children:"DISCORD_STREAMING"}),")"]})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"Rich embeds"}),(0,i.jsx)(r.td,{children:"Task progress and completion banners use Discord embeds for visual clarity"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"DM support"}),(0,i.jsx)(r.td,{children:"Private conversations work alongside server channels"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"Admin role integration"}),(0,i.jsx)(r.td,{children:"Discord server roles can be used for access control"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"Rate limiting"}),(0,i.jsx)(r.td,{children:"Built-in busy detection and rate limiting for shared servers"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:"File handling"}),(0,i.jsx)(r.td,{children:"Send and receive file attachments"})]})]})]}),"\n",(0,i.jsx)(r.h2,{id:"configuration-reference",children:"Configuration Reference"}),"\n",(0,i.jsxs)(r.table,{children:[(0,i.jsx)(r.thead,{children:(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.th,{children:"Variable"}),(0,i.jsx)(r.th,{children:"Description"}),(0,i.jsx)(r.th,{children:"Default"})]})}),(0,i.jsxs)(r.tbody,{children:[(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"DISCORD_ENABLED"})}),(0,i.jsx)(r.td,{children:"Enable/disable Discord channel"}),(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"false"})})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"DISCORD_BOT_TOKEN"})}),(0,i.jsx)(r.td,{children:"Bot token from Discord Developer Portal"}),(0,i.jsx)(r.td,{children:"\u2014"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"DISCORD_GUILD_ID"})}),(0,i.jsx)(r.td,{children:"Restrict to a specific server. Leave empty for all servers."}),(0,i.jsx)(r.td,{children:"\u2014"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"DISCORD_CHANNEL_ID"})}),(0,i.jsx)(r.td,{children:"Restrict to a specific channel. Leave empty for all channels."}),(0,i.jsx)(r.td,{children:"\u2014"})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"DISCORD_ADMIN_ROLE_NAME"})}),(0,i.jsx)(r.td,{children:"Discord role name that grants admin access"}),(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"Mercury Admin"})})]}),(0,i.jsxs)(r.tr,{children:[(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"DISCORD_STREAMING"})}),(0,i.jsx)(r.td,{children:"Enable real-time streaming (edit-in-place)"}),(0,i.jsx)(r.td,{children:(0,i.jsx)(r.code,{children:"true"})})]})]})]}),"\n",(0,i.jsx)(r.h2,{id:"troubleshooting",children:"Troubleshooting"}),"\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.strong,{children:"Bot doesn't respond to messages"})}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["Make sure ",(0,i.jsx)(r.strong,{children:"Message Content Intent"})," is enabled in the Discord Developer Portal."]}),"\n",(0,i.jsxs)(r.li,{children:["Check that ",(0,i.jsx)(r.code,{children:"DISCORD_ENABLED=true"})," and ",(0,i.jsx)(r.code,{children:"DISCORD_BOT_TOKEN"})," is set correctly."]}),"\n",(0,i.jsxs)(r.li,{children:["Run ",(0,i.jsx)(r.code,{children:"mercury logs"})," to check for connection errors."]}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.strong,{children:"Bot joins servers it shouldn't"})}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["Set ",(0,i.jsx)(r.code,{children:"DISCORD_GUILD_ID"})," to restrict the bot to your server only."]}),"\n",(0,i.jsx)(r.li,{children:"If the bot joins an unconfigured guild, it will automatically leave and log a warning."}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.strong,{children:"Slash commands not showing up"})}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["Slash commands are registered when the bot starts. Restart Mercury (",(0,i.jsx)(r.code,{children:"mercury restart"}),") if commands don't appear immediately."]}),"\n",(0,i.jsx)(r.li,{children:"Discord caches slash commands \u2014 it may take up to an hour for changes to propagate globally."}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.strong,{children:"Streaming not working"})}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["Ensure ",(0,i.jsx)(r.code,{children:"DISCORD_STREAMING=true"})," (default)."]}),"\n",(0,i.jsx)(r.li,{children:"Discord rate-limits message edits \u2014 Mercury handles this automatically by falling back to new messages when rate-limited."}),"\n"]})]})}function h(e={}){let{wrapper:r}={...(0,d.R)(),...e.components};return r?(0,i.jsx)(r,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}},28453(e,r,s){s.d(r,{R:()=>t,x:()=>c});var n=s(96540);let i={},d=n.createContext(i);function t(e){let r=n.useContext(d);return n.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function c(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:t(e.components),n.createElement(d.Provider,{value:r},e.children)}}}]);