Docs
Getting started
Make a bot, add it to a server, and point discord.py or discord.js at tether with three addresses.
tether speaks Discord's REST and gateway protocols, so most Discord bots work here after you change a
few addresses. This page takes you from nothing to a bot that answers !ping.
Everywhere below, https://app.tethr.lol is the official server. If you run your own tether, or use
someone else's, put its address there instead. Your bot talks to one server: the one it was made on.
1. Make a bot
Sign in at developer.tethr.lol with your tether account ("Sign in with tether"; closing the tab signs you out). Press New bot, give it a name and press Make bot. You land on the bot's pages, which have four tabs:
- Token. The token is shown once, right after you make the bot: copy it. It is not kept anywhere, so if you lose it, press Reset token for a new one (the old one stops working at once, and the bot's open gateway connections close). The tab also shows the discord.js lines that change.
- Add to server. The permissions the bot asks for (every one tether has, grouped as Discord's picker groups them: General, Text and Voice), the prefix its commands start with ("Its commands start with"), and the link to share. Administrator is first, with a warning: a bot that has it can do anything in the server, so only ask for it if the bot really needs it.
- General. Its picture, name and About, Music player (for a music bot), and Anyone can add it. A new bot is private: only you can add it. Turn "Anyone can add it" on to let people who manage a server add it too.
- Servers. Where the bot is, with Leave for each.
A bot's name must be free, and it must not look like tether or its staff ("tether", "Tether Support", system,
official) or advertise something illegal. A refused name comes back as 400 with the field error
NAME_NOT_ALLOWED ("That name isn't allowed."); it never says which rule matched, so pick another name.
Ordinary names, swearing included, are fine.
Prefer a terminal, or running your own tether without a developer site? The same thing is three calls with your session token (Create Bot, Modify Bot):
curl -X POST https://app.tethr.lol/api/v1/users/@me/bots \
-H "Authorization: Bearer $SESSION_TOKEN" -H "Content-Type: application/json" \
-d '{"username":"my_bot"}'
# -> { "id": "...", "username": "my_bot", "bot": true, "token": "<id>.<secret>", ... }
2. Add it to a server
The link is Discord's own:
https://app.tethr.lol/oauth2/authorize?client_id=<bot id>&scope=bot&permissions=<bits>
Whoever opens it, signed in, sees a page with the bot and its maker, a picker of the servers where they
have Manage Server, what the bot will be able to do in plain words, and Add. On Add the bot joins
and gets a managed role named after it, holding exactly the permissions the link asked for, never
more than the person adding it holds themselves. (The portal builds the link for you; guild_id in it
preselects a server, disable_guild_select=true locks the choice.)
Or, from a script, with Manage Server: Add Bot to Server.
3. Point your library at tether
A library needs three addresses. Everything else is the library as installed.
| What | Address |
|---|---|
| REST (the API) | https://app.tethr.lol/api/v1 |
| The gateway | wss://app.tethr.lol/gateway |
| Pictures (avatars, emoji…) | https://app.tethr.lol/api/v1 (the "CDN base") |
Tokens are used as on Discord: Authorization: Bot <token>.
4. A bot that answers !ping
The server decides which messages a bot may read: those that mention it, those that start with the
prefix registered for it, and (if the server allowed it) everything. A new bot has no prefix, so
set one first: in the portal, "Its commands start with" on the Add to server tab, or default_prefix in
Modify Bot. It is registered in every server the bot is added to. This bot uses !.
More in Privacy for bots.
discord.py
import discord
import yarl
ORIGIN = 'https://app.tethr.lol' # your tether server
# The three addresses; the rest is plain discord.py.
discord.http.Route.BASE = f'{ORIGIN}/api/v1'
discord.asset.Asset.BASE = f'{ORIGIN}/api/v1'
discord.gateway.DiscordWebSocket.DEFAULT_GATEWAY = yarl.URL(ORIGIN.replace('http', 'ws', 1) + '/gateway')
intents = discord.Intents.default()
intents.message_content = True # accepted; the server decides what the bot reads
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
@client.event
async def on_message(message):
if not message.author.bot and message.content == '!ping':
await message.reply('Pong!')
client.run('YOUR BOT TOKEN')
discord.js
import { Client, Events, GatewayIntentBits } from 'discord.js';
const ORIGIN = 'https://app.tethr.lol'; // your tether server
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent, // accepted; the server decides what the bot reads
],
// The three addresses: REST, the CDN base for pictures, and (asked from /gateway/bot) the gateway.
rest: { api: `${ORIGIN}/api`, version: '1', cdn: `${ORIGIN}/api/v1` },
});
client.once(Events.ClientReady, (c) => console.log(`Logged in as ${c.user.tag}`));
client.on(Events.MessageCreate, (message) => {
if (!message.author.bot && message.content === '!ping') message.reply('Pong!');
});
client.login(process.env.BOT_TOKEN);
Run it, then write !ping in a channel the bot can see. It replies Pong!.
discord.js asks GET /gateway/bot for the WebSocket address and the server answers it; discord.py
connects to the address you set. Do not install zlib-sync or erlpack: tether sends plain JSON.
5. What to read next
- Coming from a Discord bot? Coming from Discord lists what is the same, what differs, and what to check when something is quiet.
- Slash commands: Slash commands. Buttons and menus: Buttons and interactions.
- Every route, every gateway event: the API reference.
- Shipping a bot others will add: Privacy for bots says exactly what your bot can and cannot see, and what people are told about it.