Channel schema
A channel object describes one entry in the server’s channel list. channels_get returns them in display order, and channel_get returns one. Every channel has a name and a type. The other fields depend on the type, so check type first.
{ "name": "general", "type": "text", "display_name": "General", "description": "Say hello", "icon": "https://cdn.example.com/icons/general.png", "permissions": { "view": ["user"], "send": ["user", "!muted"], "delete": ["owner", "admin"], "delete_own": ["user"], "edit": ["owner"], "edit_own": ["user"], "react": ["user"], "pin": ["owner", "admin", "moderator"], "create_thread": ["user"] }, "slow_mode_cooldown": 10, "sticky_message": "b2d4f6a8-1c3e-4a5b-8d7f-0e9c1b2a3d4e", "last_message": 1788177600.412, "last_message_id": "c3e5a7b9-2d4f-4b6c-9e8a-1f0b2c3d4e5f", "last_message_by_user": 1788177512.08}type ChannelType = "text" | "voice" | "forum" | "separator";
interface ChannelPermissions { view: string[]; send: string[]; delete: string[]; delete_own: string[]; edit: string[]; edit_own: string[]; react: string[]; pin: string[]; create_thread: string[];}
interface Channel { name: string; type: ChannelType; display_name?: string; description?: string | null; icon?: string | null; permissions: ChannelPermissions; size?: number | null; slow_mode_cooldown?: number | null; max_message_age?: number | null; sticky_message?: string | null; // Text and voice channels last_message?: number | null; last_message_id?: string | null; last_message_by_user?: number | null; // Voice channels voice_state?: Array<{ username: string; muted: boolean }>; // Forum channels threads?: Thread[];}Fields for every channel
Section titled “Fields for every channel”| Field | Description |
|---|---|
name |
The channel’s ID, up to 64 characters. Send this, not display_name, wherever a command asks for a channel. |
type |
text, voice, forum, or separator. |
display_name |
Name to show instead of name, when set. |
description |
Topic text. |
icon |
Icon image, an absolute http or https URL. |
permissions |
Which roles can do what. See permissions. Always complete: any key the channel doesn’t set is filled from the server defaults. |
size |
Separators only: the divider’s height, for layout. |
slow_mode_cooldown |
Seconds each member must wait between messages. 0 or missing means no slow mode. Owners, admins, and manage_server holders are exempt. |
max_message_age |
Stored, but the server doesn’t act on it. |
sticky_message |
ID of a message the server keeps re-posting at the bottom of the channel. Set with the /sticky slash command. |
Fields that were never set are left out. A field cleared with channel_update can come back as null.
Fields by type
Section titled “Fields by type”Text and voice channels hold messages, so they add:
| Field | Description |
|---|---|
last_message |
Timestamp of the newest message, in Unix seconds, or null if the channel is empty. |
last_message_id |
ID of the newest message, or null. |
last_message_by_user |
Timestamp of your own newest message here, or null. This one is personal to the viewer. |
Voice channels also add voice_state, the people in the call right now, each with username and muted. Unlike the voice_state command, this list isn’t filtered for severed users.
Forum channels add threads, a short list of threads: pinned threads first, then the rest. It leaves out threads you haven’t joined and threads whose last message is more than seven days old. Use threads_get for the full, paged list.
Separators hold nothing. They appear in every member’s list, whatever the view permission says.
Permissions
Section titled “Permissions”Each permission key holds a list of role names:
| Key | Allows |
|---|---|
view |
Seeing the channel and its messages. |
send |
Posting messages. |
delete, delete_own |
Deleting anyone’s messages, or your own. |
edit, edit_own |
Editing anyone’s messages, or your own. |
react |
Adding reactions. |
pin |
Pinning and unpinning messages. |
create_thread |
Creating threads in a forum. |
The server checks a list like this:
- The
ownerrole always passes. - A role written with
!, such as!muted, blocks anyone who has that role. - Otherwise, you pass if you have any listed role, or if the list has no plain role names at all.
A channel without its own settings uses these defaults:
| Key | Default roles |
|---|---|
view, send, delete_own, edit_own, react, create_thread |
user |
delete |
owner, admin |
edit |
owner |
pin |
owner, admin, moderator |
Roles and permissions explains how channel permissions combine with server permissions.
See also
Section titled “See also”- Channels: how channel types are used.
- Thread schema: the objects in a forum’s
threads.
