Discord's quietest member does the most

Text your agent on Discord. Your agent is a bot in a server of yours, and it answers you and no one else, unless you share a channel with it.

lnk agent start               # your agent, unless it runs already
lnk agent connect discord     # paste the bot token, then send it the code

Connect it

Make an application at Discord's developer portal, turn on its bot's Message Content intent, and paste the bot's token when lnk asks. Add the bot to a server of yours with the link lnk prints, and send it the code in a direct message within 10 minutes.

lnk agent connect discord

Without prompts

From a script, give the token in its variable. It keeps the token off the command line, which other users of this machine can see while lnk runs, and no flag takes it.

LNK_DISCORD_TOKEN=... lnk agent connect discord   # the token from the variable

Photos and documents

For a harness that takes images and documents (Link Harness), the photos and documents a message holds go to the agent with its text: PNG, JPEG, GIF or WebP images and PDF or text documents, up to 10 MiB each and 8 a message, downloaded from Discord's CDN, which is never sent the bot's token.

What it leaves out

Anything else, a voice note or a video, is named to the agent as left out; sent alone, it's answered with what the agent reads. For another harness, a message holding only them is answered "I can read text only, for now."

Share a channel

Mention the bot with the code share prints, in a channel of a server it's in, within 10 minutes (@company 4K7P2QXM). Only your own mention counts: nobody else's message is read for the code.

lnk agent share add discord

Who it answers there

The bot says "Shared with #team" in the channel, and from then on anyone there can mention it and be answered, as themselves: your agent is told their user id and the name they go by in the server, never that it's you (Connections).

What stays out

A share reaches that one channel, and only the people in it:

  • That channel alone: a thread in it, another channel of the same server, and every direct message but yours stay unanswered. A thread can't be shared: mentioned there with the code, the bot says so and goes on waiting.
  • Unasked, only while shared: a schedule's answer goes to the channel it was set in only while the channel is shared; unshare ends that too.
  • People only: another bot's message, a webhook's and Discord's own are never answered, shared channel or not.

End a share

lnk agent share remove discord ends a channel's share, by its name or its id, and the bot stops answering anyone there but you.

lnk agent share remove team --connection discord

Held for many bots

On this computer, your agent's bridge holds its bot's Gateway, Discord's websocket, for as long as the agent runs. A machine that packs agents, which runs one only while it answers, holds the Gateways for it instead, with three commands of lnk-discord.

Hold the Gateways

lnk-discord hold holds many bots' Gateways in one process, with the bridge's intents, and writes each message one gets. A connection that drops resumes its session, and Discord sends what it missed. One Discord refuses for good (the token wrong or revoked, an intent the bot may not have) is said to be refused, not just down, until the token changes. It answers nothing and sends nothing.

Sift each message

lnk-discord sift reads each message without the token. One from anyone you didn't allow, or from the bot itself, is dropped, and yours is kept, as the bridge keeps it (in a server, only a mention of the bot). So is anyone's mention of the bot in a channel the agent is shared with, as theirs, by the channels its line names as it comes.

Answer it

lnk-discord take answers your message, or a shared channel's, as the bridge does, over Discord's HTTP API, never through the process holding the Gateway: the agent shown typing, its answer written in as it comes.

When Discord refuses

When Discord refuses the bot's token, take and lnk-discord send each say so as a failure of its own, apart from any other. So does an answer Discord refuses, its channel gone or the bot blocked or kept out of it.

Disconnect

disconnect forgets Discord's tokens and restarts your agent if it runs. The bot stays yours, so delete it at Discord's developer portal if you no longer want it.

lnk agent disconnect discord

When it doesn't work: Troubleshooting.

Docs

  • Troubleshooting: What to do when your agent's Discord bot doesn't connect or doesn't answer (Discord)
  • Decisions: Why the Discord plugin gives each agent a bot of its own, and how it sees a code arrive