tether developers
Contents

Docs

Rich posts for bots

Cards, rows, setting fields, pickers and On/Off switches, built from Discord's components v2 with tether's extras.

A rich post is a message made of building blocks instead of text: cards, sections, rows side by side, pictures, dividers, buttons, menus and pickers. It is Discord's components v2, so a post your bot already sends to Discord works here, plus a few tether-only pieces for settings screens and dashboards: the setting field, the On/Off switch, buttons beside a section's text and rows side by side.

Send one with Create Message (or answer an interaction with it) with the flag IS_COMPONENTS_V2 (1 << 15, 32768) and the pieces in components. A rich post has no content or embeds: the text goes in its pieces. The flag stays on the message for good.

{
  "flags": 32768,
  "components": [
    {
      "type": 17,
      "accent_color": 9141494,
      "components": [
        { "type": 10, "content": "## Tickets dashboard\n-# Panel posted in <#123456789012345678>" },
        { "type": 14 },
        {
          "type": 1001,
          "components": [
            {
              "type": 1003,
              "label": "Panel channel",
              "component": {
                "type": 8,
                "custom_id": "set:panel",
                "channel_types": [0],
                "default_values": [{ "id": "123456789012345678", "type": "channel" }]
              }
            },
            {
              "type": 1003,
              "label": "Staff roles",
              "component": { "type": 6, "custom_id": "set:staff", "min_values": 0, "max_values": 5 }
            }
          ]
        },
        {
          "type": 9,
          "components": [
            { "type": 10, "content": "**Support** · 2 questions\n-# Questions and problems" }
          ],
          "accessory": {
            "type": 1,
            "components": [
              { "type": 2, "style": 2, "label": "Edit", "custom_id": "type:edit:1" },
              {
                "type": 2,
                "style": 2,
                "label": "On",
                "custom_id": "type:on:1",
                "tether_toggle": true
              }
            ]
          }
        }
      ]
    }
  ]
}

The pieces

type Piece What it holds
17 Container A card with a coloured edge (accent_color), holding any of the pieces below.
10 Text Display Markdown (content): headings, -# small print, mentions, <t:…:R> times.
9 Section 1 to 3 texts with an accessory beside them: a Thumbnail (11), a button, or a group of buttons (tether).
12 Media Gallery 1 to 10 pictures (items[].media.url).
14 Separator A line (divider, default true) or room; spacing 1 (small) or 2 (large).
1 Action Row Up to 10 buttons, or one menu or picker.
1001 Row (tether) 1 to 4 pieces side by side (texts, pictures, fields, action rows, sections); they stack on a phone.
1002 Author A small line with a round picture (name, icon_url).
1003 Field (tether) A setting field: a label and one component (a menu, a picker or a button). See "Setting fields".

Pictures (media.url, icon_url) are http(s) addresses or attachment://<file name> of the same message. Clients never contact your address: they get a signed link on tether's picture proxy, as for embeds.

Unknown keys are dropped and null counts as absent, as for other components; Discord's numeric id on a piece is accepted and dropped. tether_style (the style of a server post: colour, background, size, weight, align, padding, corners, width, border) is accepted on texts, cards, rows and pictures; colours are made readable against the theme the person uses.

Buttons, switches and menus

  • Buttons are Discord's: styles 1 (the accent), 2 (grey), 3 (green), 4 (red), or 5 (a link, with url). A press reaches your bot as INTERACTION_CREATE type 3, like any button (Buttons and interactions).
  • On/Off switch (tether): a button with tether_toggle: true (on, drawn in the accent) or false (off). It is an ordinary button press; flip it by updating the post (below). Label it as you like (On / Off).
  • Buttons beside a section: a section's accessory may be one button or an action row of buttons (a group).
  • String menus (3) take up to 100 options, each with an optional description shown under its label.
  • Pickers (Discord's auto-filled select menus): 5 people, 6 roles, 7 people and roles, 8 channels, with placeholder, min_values, max_values (up to 25), default_values ([{id, type}], type being user, role or channel) and, for a channel picker, channel_types.

Setting fields

A field (1003) is a settings row: its label on the left, the current value on the right, a chevron, and pressing it opens its list right under it. The value is what its component has chosen:

  • a picker: the default_values as chips (#support, @Moderator, @mira);
  • a string menu: the label of the option marked default: true ("3 quiet days");
  • a button: the field shows the label with the button on the right, usually a switch (tether_toggle).

Put two fields in a Row (1001) to show them side by side.

Pickers show only what the person can see

The app lists the people of the server, its roles (never @everyone) and the channels the person pressing can see, of the kinds you asked for. The server checks every pick again before your bot hears of it: a channel the person can't see, someone who isn't a member, a role of another server or too many values are refused (400), and your bot gets nothing. A chip for something the person can't see shows as unknown, never by name.

What you receive is Discord's: data.values holds the ids, and data.resolved what they stand for:

{
  "type": 3,
  "data": {
    "component_type": 8,
    "custom_id": "set:panel",
    "values": ["123456789012345678"],
    "resolved": {
      "channels": {
        "123456789012345678": {
          "id": "123456789012345678",
          "type": 0,
          "name": "support",
          "parent_id": null,
          "permissions": "…"
        }
      }
    }
  }
}

resolved has users and members (the member without its user, with permissions in the channel), roles and channels (with the presser's permissions there), as for a slash command's options.

Pickers in forms

A form (callback type 9) may ask with a picker: put it in a Label (18) like a menu. required (default true) and max_values work as in a message. The answers come back in the shape you asked in, with data.resolved beside data.components.

{
  "type": 18,
  "label": "Who should join this ticket?",
  "component": { "type": 5, "custom_id": "who", "max_values": 3 }
}

Update in place

A dashboard changes in place: answer a press with callback type 7 (Discord's "update message") and the whole new components. The post keeps its flag; a rich post can't be turned back into text, and an update that brings content or embeds is 400. You can also send flags: 32768 with type 4 for a new rich post, with flags: 32832 (64 | 32768) for one only the presser sees, or edit with Edit Message.

discord.js

discord.js has builders for Discord's pieces; tether's own (1001, 1003, tether_toggle) go as plain JSON through its REST client:

import { Routes } from 'discord.js';

await client.rest.post(Routes.channelMessages(channelId), {
  body: { flags: 1 << 15, components: dashboard() },
});

client.on('raw', async (packet) => {
  if (packet.t !== 'INTERACTION_CREATE' || packet.d.type !== 3) return;
  const i = packet.d;
  if (i.data.custom_id === 'set:panel') {
    saveChannel(i.guild_id, i.data.values[0]);
    await client.rest.post(Routes.interactionCallback(i.id, i.token), {
      body: { type: 7, data: { components: dashboard() } },
    });
  }
});

discord.py

route = discord.http.Route('POST', '/channels/{channel_id}/messages', channel_id=channel.id)
await client.http.request(route, json={'flags': 1 << 15, 'components': dashboard()})

Limits

tether does not copy Discord's small numbers (40 pieces, 5 buttons a row, 25 options). A rich post may hold:

What Limit
Pieces in all, nested ones included 250
Characters of text in all 16,000
Characters in one text piece 4,000
The whole components as JSON 96,000
How deep pieces nest 6
Buttons in an action row 10
Options in a string menu 100
Values a picker takes 25
Pieces side by side in a Row 4
Pieces directly in one card 100
Pictures in a gallery 10
Pictures from web addresses in all 30

A gallery's pictures count as pieces, so ten pictures in a gallery are eleven pieces toward the 250. The server fetches every web picture once when the post is sent, so that readers' apps never contact your host, which is why the number of web addresses in one post is limited: the same address twice is one picture, and attachment:// pictures (files of the same message) are not counted. A post over any of these limits is refused with 400, code 50035, naming what is too much.

Every custom_id in a post is different. The pieces still show your bot's name, picture and BOT tag above them: a rich post never passes for the app's own screens.

What other bots see

A rich post is content: another bot reads its pieces only under the same rule as text (it was mentioned, it has the prefix, or the server lets it read everything; see Privacy for bots).