Build bots for communities.
Create tools that welcome new members, share announcements and make everyday work easier. A small idea is enough to begin.
Your first bot in three steps.
Create your bot
In the Windows app, open Settings, then My Bots.
Keep your token safe
It’s shown only once. Store it in an environment variable instead of in your code.
Add it to your server
You’ll need permission to manage bots on that server.
mercys.js hasn’t been published on npm yet. Until we officially announce it, don’t install packages published under this name. They aren’t ours.
Works today. Requires Node 18 and socket.io-client.
import { io } from 'socket.io-client';
const API = 'https://api.mercys.cc';
const auth = 'Bot ' + process.env.MERCYS_TOKEN;
const socket = io(API, { path: '/gateway', auth: { token: auth } });
socket.on('ready', () => console.log('Bot is ready.'));
socket.on('message:create', async (msg) => {
if (msg.author.isBot || msg.content !== '!hello') return;
const res = await fetch(API + '/api/channels/' + msg.channelId + '/messages', {
method: 'POST',
headers: { Authorization: auth, 'Content-Type': 'application/json' },
body: JSON.stringify({ content: 'Hello!', replyToId: msg.id }),
});
if (!res.ok) console.error('Could not send the reply:', res.status);
});Every bot is a responsibility.
The people who use your bot trust you. Three principles help you keep that trust:
Keep credentials private
We store a hash of your token, not the token itself. Regenerating it invalidates the old one immediately.
Know which bots you can add
You can add your own bots to a server, as well as bots verified by Mercys.
Check who sent the command
Your bot having permission doesn’t mean the person sending the command has it too.
API reference.
The most commonly used endpoints and events.
REST endpoints
The host is api.mercys.cc. Bot management uses a user session (Bearer), while messages use a bot token (Bot).
- GET /api/bots
- Lists your bots
- POST /api/bots
- Creates a bot, up to 5 per person
- POST /api/bots/:id/token
- Regenerates the token and revokes the old one
- DELETE /api/bots/:id
- Deletes the bot, its messages and the servers it owns
- POST /api/servers/:id/bots
- Adds a bot to a server using { botId }
- POST /api/channels/:id/messages
- Sends a message
Real-time events
Connect to the /gateway path with Socket.IO. Set auth.token to “Bot ” followed by your token.
- ready
- The connection is ready
- message:create
- A new message
- message:update
- A message was edited
- message:delete
- A message was deleted
- member:join
- A new member joined
- member:leave
- A member left
- server:create
- The bot was added to a server
- voice:state
- A state changed in a voice room
We’re curious what you’ll build.
You’ll find the tools to create and manage bots in the Windows app.