@axon/discord
Adds a Discord bot to your agent. Incoming messages fire a hook your plugin handles.
Setup
- Create a bot at discord.com/developers and copy the token
- Under Bot → Privileged Gateway Intents, enable Message Content Intent
- Invite the bot to your server with the
botscope andSend Messages+Read Message Historypermissions - Add
DISCORD_BOT_TOKENto your agent's.env
Config
// axon.config.tsmodules: { discord: { channelIds: "123456789,987654321", // optional — omit to listen everywhere mentionOnly: false, // only trigger on @mentions prefix: "!ask", // require a prefix — ignored if empty guildId: "111222333", // restrict to one server — omit for all }}Handling messages
// server/plugins/discord.tsexport default defineAxonPlugin(async (axon) => { axon.hooks.on("discord:message.received", async ({ content, username, reply }) => { const prompt = await axon.prompt("discord", { content, username }) const response = await axon.request({ prompt: [prompt] }) if (response?.text) await reply(response.text) })})Messages are queued — if the agent is still processing one message when the next arrives, it waits. The agent's cognitive loop is never called concurrently.
Hook payload
| Field | Type | Description |
|---|---|---|
content |
string |
Message text, stripped of prefix and @mention |
username |
string |
Discord username of the sender |
userId |
string |
Discord user ID |
channelId |
string |
Channel the message arrived in |
guildId |
string | null |
Server ID — null for DMs |
messageId |
string |
Discord message ID |
reply |
(text: string) => Promise<void> |
Send a reply in the same channel |
Prompt
The module ships a discord prompt that frames the inbound message for the agent.
Override it by creating src/prompts/discord.vue in your agent — agent-owned prompts take precedence.