Docs
Threads
Public threads in text channels, with Discord's routes and events, and what is not offered.
tether has Discord's public threads in text channels (channel type 11). A thread has its own
messages, members and slow mode; who may see it and write in it comes from its text channel.
An example
discord.py
import discord
import yarl
ORIGIN = 'https://app.tethr.lol' # your tether server
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
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 == '!thread':
thread = await message.create_thread(name='Ideas for Friday')
await thread.send('Post your ideas here.')
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,
],
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, async (message) => {
if (message.author.bot || message.content !== '!thread') return;
const thread = await message.startThread({ name: 'Ideas for Friday' });
await thread.send('Post your ideas here.');
});
client.login(process.env.BOT_TOKEN);
Routes
| Route | What it does |
|---|---|
| Start Thread from Message | {name, auto_archive_duration?, rate_limit_per_user?}. The thread has the message's id; one thread per message (160004). The message shows it as thread. |
| Start Thread without Message | A thread of its own. type is 11 or left out; 12 (private) is 400. |
| Modify Thread | PATCH /channels/{thread.id}: name, archived, locked, auto_archive_duration, rate_limit_per_user. |
| Delete Thread | DELETE /channels/{thread.id}, with its messages. Needs Manage Threads. |
| Join / Leave | PUT and DELETE /channels/{thread.id}/thread-members/@me, or /{user.id} to add or remove someone. |
| Get / List | Who follows it (with_member, after, limit). |
| List Public Archived Threads | The archived threads of a text channel, the most recently archived first (before an ISO time, limit, has_more). |
| List Active Guild Threads | The active threads of a server you can see, with your own memberships. |
Messages in a thread are the ordinary message routes with the thread's id.
A thread's thread_metadata is {archived, auto_archive_duration, archive_timestamp, locked, invitable, create_timestamp}, and it counts message_count and member_count (up to 50) and total_message_sent.
Permissions
Send Messages in Threads is the right to write in a thread (in a thread it is what Send Messages is in a
channel); Create Public Threads starts one (starting one also needs Send Messages in the text channel);
Manage Threads renames, archives, locks and deletes any. A thread is as open as its text channel: a
thread in a private channel is private, and a read-only channel stays read-only for threads.
Archiving
A thread archives itself after auto_archive_duration minutes (60, 1440, 4320 or 10080) with no message.
Writing in an archived thread wakes it again, unless it is locked (then only people who manage threads
may write, 160005). Joining or adding someone to an archived thread is 400 50083. An archived thread
refuses editing a message, reactions, pins and typing; a locked one refuses the same, and new messages.
A wake counts against the server's limit of active threads (160006).
Events
Under the GUILDS intent: THREAD_CREATE (with newly_created), THREAD_UPDATE, THREAD_DELETE,
THREAD_LIST_SYNC (when you gain a text channel, its active threads) and THREAD_MEMBER_UPDATE (your own
membership); THREAD_MEMBERS_UPDATE needs GUILD_MEMBERS. GUILD_CREATE carries the active threads in
threads.
A thread's messages arrive as MESSAGE_CREATE for everyone who can see the text channel, not only
for its members: a bot that can read a channel sees every message of its threads, whether it joined or not.
(The same content rule applies as everywhere: Privacy for bots.)
Names reach bots. A thread's name is typed by the person who starts it (the app never fills it from the
message), and every bot that can see the channel receives it in THREAD_CREATE and the thread lists, even
a bot that may not read messages. As on Discord, names are not message content.
Threads in DMs
tether also has threads in DMs and group DMs (Discord has none). A thread there is the same type 11 channel
with no guild_id, and parent_id is the DM or group DM. The routes are the ones above; everyone in the
conversation is in the thread, so thread-members lists them and joining or leaving does nothing. A bot sees
a DM thread like any DM channel: the DM intents (DIRECT_MESSAGES) carry THREAD_CREATE, THREAD_UPDATE,
THREAD_DELETE, THREAD_MEMBERS_UPDATE and the thread's MESSAGE_CREATE, and the content rule is the
one for DMs (Privacy for bots). List Active DM Threads
lists the open ones of one conversation, and READY carries dm_threads for all of them. At most 100 threads
are active in one conversation (160006).
Not offered
Private threads (type 12), announcement threads, forum channels and thread tags, and the "X started a thread" system messages (types 18 and 21).