A Discord API mock for testing bot replies.
Seed a guild with channels, members and messages. Your bot can reply to a message; read the channel history to check the reply’s content and message reference.
message_postedCalls POST /api/v10/channels/*/messages
Starting records
channels / help / messages
- key
export-question
channels
- name
help
Connect your agent to the Discord mock
When ancha runs your agent, it sets:
DISCORD_API_URLDISCORD_BOT_TOKEN
Point the client you already use at them.
const discord = (path: string, init: RequestInit = {}) => fetch(`${process.env.DISCORD_API_URL}${path}`, { ...init, headers: { Authorization: `Bot ${process.env.DISCORD_BOT_TOKEN}`, 'Content-Type': 'application/json' } }).then(r => r.json());
const [guild] = await discord('/users/@me/guilds');
const help = (await discord(`/guilds/${guild.id}/channels`)).find((c: any) => c.name === 'help');
const [latest] = await discord(`/channels/${help.id}/messages?limit=1`);
await discord(`/channels/${help.id}/messages`, { method: 'POST', body: JSON.stringify({ content: 'Looking into it now.', message_reference: { message_id: latest.id } }) });Locally, ancha runs your agent as an ordinary process, so keep real Discord credentials out of its environment.
See all 25 endpoints
channels
/api/v10/channels/{channel_id}/api/v10/channels/{channel_id}/messages/api/v10/channels/{channel_id}/messages/api/v10/channels/{channel_id}/messages/{message_id}/api/v10/channels/{channel_id}/messages/{message_id}/api/v10/channels/{channel_id}/messages/{message_id}/api/v10/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/api/v10/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me/api/v10/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me/api/v10/channels/{channel_id}/messages/{message_id}/threads/api/v10/channels/{channel_id}/pins/api/v10/channels/{channel_id}/pins/{message_id}/api/v10/channels/{channel_id}/pins/{message_id}/api/v10/channels/{channel_id}/threads/api/v10/channels/{channel_id}/typingguilds
/api/v10/guilds/{guild_id}/api/v10/guilds/{guild_id}/channels/api/v10/guilds/{guild_id}/members/api/v10/guilds/{guild_id}/members/{user_id}/api/v10/guilds/{guild_id}/roles/api/v10/guilds/{guild_id}/threads/activeusers
/api/v10/users/{user_id}/api/v10/users/@me/api/v10/users/@me/channels/api/v10/users/@me/guildsSeed your own data
The data the Discord mock starts with on every run, cut to a few records. ancha twins seed discord prints every field.
Full seed YAML
twins:
- discord
seed:
discord:
guild:
name: Acme Community
description: Questions, ideas and news for people who use Acme.
owner: mike.turner
bot:
username: acme_assistant
globalName: Acme Assistant
permissions:
- VIEW_CHANNEL
- SEND_MESSAGES
- READ_MESSAGE_HISTORY
- ADD_REACTIONS
- EMBED_LINKS
- CREATE_PUBLIC_THREADS
- SEND_MESSAGES_IN_THREADS
roles:
- name: Acme Staff
permissions:
- MANAGE_MESSAGES
- MANAGE_THREADS
- MENTION_EVERYONE
- KICK_MEMBERS
color: 1323612
hoist: true
mentionable: true
- name: Beta testers
color: 3050327
mentionable: true
members:
- username: mike.turner
globalName: Mike Turner
roles:
- Acme Staff
joined: -3000h
- username: erin.walsh
globalName: Erin Walsh
roles:
- Beta testers
joined: -190h
channels:
- name: help
topic: Ask how to do something in Acme.
messages:
- key: export-question
author: erin.walsh
content: Anyone know where last month’s CSV export ends up? The email says it’s ready but Reports → Exports is empty.
at: -50m
Check what your agent did
Checks YAML
checks:
- id: message_posted
trace:
called: POST /api/v10/channels/*/messagesMore chat and email tools
All 43 toolsDiscord API mock FAQ
How do I verify that a Discord bot replied to the right message?
Send POST / with message_reference.message_id pointing to a message in that channel. Ancha stores the reply and returns its message_reference and referenced_message when you read it back.
Can I exercise Discord permission errors before giving a bot access to a channel?
The mock checks the bot's channel permissions before posting a message. A channel the bot cannot view returns 403 with code 50001; a visible channel where it lacks permission to send returns code 50013.
How does the Discord mock fetch history around a message?
Use before, after or around with a message ID on GET /, with limit from 1 to 100. The mock returns messages newest first and rejects requests that combine more than one of those anchors.
Install the CLI and run your agent against the Discord mock.
Ancha is not affiliated with Discord.