Every component type Klang takes in messages and modals, with its fields and limits. Action rows, buttons, the five select menus, the layout components of IS_COMPONENTS_V2 messages, and the fields of a modal, from labels and text inputs to file uploads, radio groups and checkboxes.
Types and fields are Discord’s, with the same numbers, so library builders work as they are.
id is an optional number on every component, unique in its message or modal, from 1 to
2,147,483,647. Leave it out, or send 0, and Klang numbers the component itself, in order. It
always comes back.
What you send is what comes back, plus the ids and the fields Klang fills in for images
and files. Fields with null count as not sent.
Anything that breaks a rule answers 400 with 50035, and the error says where
(components.0.components.1.custom_id). Nothing is dropped quietly.
Component types
type
Name
In messages
In modals
In Klang
1
Action row
Yes
The older form only
Supported
2
Button
In an action row or a section
No
Supported, but style 6
3
String select
In an action row
In a label
Supported
4
Text input
No
In a label
Supported
5
User select
In an action row
In a label
Supported
6
Role select
In an action row
In a label
Supported
7
Mentionable select
In an action row
In a label
Supported
8
Channel select
In an action row
In a label
Supported
9
Section
v2
No
Supported
10
Text display
v2
Yes
Supported
11
Thumbnail
v2, in a section
No
Supported
12
Media gallery
v2
No
Supported
13
File
v2
No
Supported
14
Separator
v2
No
Supported
17
Container
v2
No
Supported
18
Label
No
Yes
Supported
19
File upload
No
In a label
Supported
21
Radio group
No
In a label
Supported
22
Checkbox group
No
In a label
Supported
23
Checkbox
No
In a label
Supported
“v2” means a message with the IS_COMPONENTS_V2 flag (1 << 15). Without it, a message takes
only action rows. Discord’s component types that aren’t listed don’t exist in Klang either, and a
type in a place it doesn’t fit answers 50035 with a message that says so, such as “Text inputs
only go in modals.”
1 to 100 characters, unique in the message or modal.
placeholder
string
Up to 150 characters.
min_values
integer
0 to 25. By default 1. Not more than max_values.
max_values
integer
1 to 25. By default 1.
disabled
boolean
In messages only. A modal can’t have disabled fields.
required
boolean
In modals only, true by default. A required menu needs min_values of at least 1.
String select (3) adds options: 1 to 25, with unique values.
Field
Type
Notes
label
string
1 to 100 characters.
value
string
1 to 100 characters. What your bot gets in values.
description
string
Up to 100 characters.
emoji
object
As in a button.
default
boolean
Chosen when the menu shows. Not more defaults than max_values.
min_values can’t be more than the number of options.
User, role, mentionable and channel selects (5–8) add default_values: up to 25
{ "id": "…", "type": "user" | "role" | "channel" }, of the kinds the menu takes (a mentionable
menu takes users and roles), and between min_values and max_values of them. @everyone is
the server’s ID, as everywhere in the bot API. Channel select (8) also takes
channel_types, a list of Discord’s channel type numbers; people only see the channels of those
types.
Layout components
These go in messages with IS_COMPONENTS_V2. Such a message has up to 40 components,
counting the ones inside others, and no content, embeds, stickers or polls.
1 to 4,000 characters of Markdown, with mentions that notify as in content (allowed_mentions applies). All the text displays of a message or a modal add up to 4,000 at most.
Only attachment:// and the name of one of the message’s files.
spoiler
boolean
name
string
Sent back: the file’s name.
size
integer
Sent back: the file’s size in bytes.
Separator
Field
Type
Notes
type
14
id
integer
divider
boolean
Whether a line is drawn. true by default.
spacing
integer
1 small (by default) or 2 large.
Container
Field
Type
Notes
type
17
Only at the top level of a message.
id
integer
components
array
At least one: action rows, text displays, sections, media galleries, separators and files.
accent_color
integer
An RGB color from 0 to 16777215 (0xFFFFFF), shown as a bar on the left. Without it, no bar.
spoiler
boolean
The whole box is blurred until someone clicks it.
Media item
What media and file hold. Your bot sends only url:
attachment:// and the name of one of the message’s files, uploaded with it or kept from
before (see Sending files). A name that matches no
file answers 50035;
or, for thumbnails and galleries, an https address on the Internet, up to 2,048 characters.
Private addresses and Discord’s image servers are refused.
Klang fills in the rest when it sends the message back:
Field
Type
Present
Notes
url
string
Always
The file’s address, or the address you gave.
proxy_url
string
Sometimes
The same image through Klang’s image proxy for an address on the Internet; the file’s address for a file.
Text already filled in, up to 4,000 characters and within max_length.
placeholder
string
Up to 100 characters.
label
string
Only in the older form: an action row with one text input that carries its label (1 to 45 characters).
File upload
Field
Type
Notes
type
19
id
integer
custom_id
string
1 to 100 characters, unique in the modal.
min_values
integer
0 to 10. 1 by default. Not more than max_values.
max_values
integer
1 to 10. 1 by default.
required
boolean
true by default. A required upload needs min_values of at least 1.
file_types
array of strings
Up to 10, without repeats: groups (image, video, audio) or extensions (.pdf).
file_types filters by the file’s extension, whatever its case. An extension in the list is a
dot and 1 to 31 letters or digits, and Klang keeps it in lowercase. Without file_types, or with
an empty list, any file goes. The groups take these extensions:
Group
Extensions
image
.png, .gif, .jpg, .jpeg, .jfif, .webp, .avif
video
.mp4, .mov, .qt, .webm
audio
.mp3, .m4a, .wav, .ogg, .opus, .flac
Klang also reads each file’s first bytes, whatever the list says: see
What Klang checks for you. In the submission, the
upload has values, the IDs of the files, which are in resolved.attachments.
What a person sends in a modal is checked too, but those problems never reach your bot: the
person sees them under the field. See
What Klang checks for you.