Channels Resource
Channel Object
Represents a guild or DM channel within Discord.
Channel Structure
Field | Type | Description |
---|---|---|
id | snowflake | the id of this channel |
type | integer | the type of channel |
guild_id? | snowflake | the id of the guild (may be missing for some channel objects received over gateway guild dispatches) |
position? | integer | sorting position of the channel |
permission_overwrites? | array of overwrite objects | explicit permission overwrites for members and roles |
name? | string | the name of the channel (1-100 characters) |
topic? | ?string | the channel topic (0-1024 characters) |
nsfw? | boolean | whether the channel is nsfw |
last_message_id? | ?snowflake | the id of the last message sent in this channel (may not point to an existing or valid message) |
bitrate? | integer | the bitrate (in bits) of the voice channel |
user_limit? | integer | the user limit of the voice channel |
rate_limit_per_user?* | integer | amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel , are unaffected |
recipients? | array of user objects | the recipients of the DM |
icon? | ?string | icon hash |
owner_id? | snowflake | id of the creator of the group DM or thread |
application_id? | snowflake | application id of the group DM creator if it is bot-created |
parent_id? | ?snowflake | for guild channels: id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created |
last_pin_timestamp? | ?ISO8601 timestamp | when the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. |
rtc_region? | ?string | voice region id for the voice channel, automatic when set to null |
video_quality_mode? | integer | the camera video quality mode of the voice channel, 1 when not present |
message_count? | integer | an approximate count of messages in a thread, stops counting at 50 |
member_count? | integer | an approximate count of users in a thread, stops counting at 50 |
thread_metadata? | a thread metadata object | thread-specific fields not needed by other channels |
member? | a thread member object | thread member object for the current user, if they have joined the thread, only included on certain API endpoints |
default_auto_archive_duration? | integer | default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 |
permissions? | string | computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a slash command interaction |
* rate_limit_per_user
also applies to thread creation. Users can send one message and create one thread during each rate_limit_per_user
interval.
Channel Types
Type | ID | Description |
---|---|---|
GUILD_TEXT | 0 | a text channel within a server |
DM | 1 | a direct message between users |
GUILD_VOICE | 2 | a voice channel within a server |
GROUP_DM | 3 | a direct message between multiple users |
GUILD_CATEGORY | 4 | an organizational category that contains up to 50 channels |
GUILD_NEWS | 5 | a channel that users can follow and crosspost into their own server |
GUILD_STORE | 6 | a channel in which game developers can sell their game on Discord |
GUILD_NEWS_THREAD | 10 | a temporary sub-channel within a GUILD_NEWS channel |
GUILD_PUBLIC_THREAD | 11 | a temporary sub-channel within a GUILD_TEXT channel |
GUILD_PRIVATE_THREAD | 12 | a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission |
GUILD_STAGE_VOICE | 13 | a voice channel for hosting events with an audience |
Video Quality Modes
Mode | Value | Description |
---|---|---|
AUTO | 1 | Discord chooses the quality for optimal performance |
FULL | 2 | 720p |
Example Guild Text Channel
json
{"id": "41771983423143937","guild_id": "41771983423143937","name": "general","type": 0,"position": 6,"permission_overwrites": [],"rate_limit_per_user": 2,"nsfw": true,"topic": "24/7 chat about how to gank Mike #2","last_message_id": "155117677105512449","parent_id": "399942396007890945","default_auto_archive_duration": 60}
Example Guild News Channel
Bots can post or publish messages in this type of channel if they have the proper permissions. These are called "Announcement Channels" in the client.
json
{"id": "41771983423143937","guild_id": "41771983423143937","name": "important-news","type": 5,"position": 6,"permission_overwrites": [],"nsfw": true,"topic": "Rumors about Half Life 3","last_message_id": "155117677105512449","parent_id": "399942396007890945","default_auto_archive_duration": 60}
Example Guild Voice Channel
json
{"id": "155101607195836416","guild_id": "41771983423143937","name": "ROCKET CHEESE","type": 2,"nsfw": false,"position": 5,"permission_overwrites": [],"bitrate": 64000,"user_limit": 0,"parent_id": null,"rtc_region": null}
Example DM Channel
json
{"last_message_id": "3343820033257021450","type": 1,"id": "319674150115610528","recipients": [{"username": "test","discriminator": "9999","id": "82198898841029460","avatar": "33ecab261d4681afa4d85a04691c4a01"}]}
Example Group DM Channel
json
{"name": "Some test channel","icon": null,"recipients": [{"username": "test","discriminator": "9999","id": "82198898841029460","avatar": "33ecab261d4681afa4d85a04691c4a01"},{"username": "test2","discriminator": "9999","id": "82198810841029460","avatar": "33ecab261d4681afa4d85a10691c4a01"}],"last_message_id": "3343820033257021450","type": 3,"id": "319674150115710528","owner_id": "82198810841029460"}
Example Channel Category
json
{"permission_overwrites": [],"name": "Test","parent_id": null,"nsfw": false,"position": 0,"guild_id": "290926798629997250","type": 4,"id": "399942396007890945"}
Example Store Channel
Bots can neither send or read messages from this channel type (as it is a store page).
json
{"id": "41771983423143937","guild_id": "41771983423143937","name": "buy dota-2","type": 6,"position": 0,"permission_overwrites": [],"nsfw": false,"parent_id": null}
Example Thread Channel
Threads can be either archived
or active
. Archived threads are generally immutable. To send a message or add a reaction, a thread must first be unarchived. The API will helpfully automatically unarchive a thread when sending a message in that thread.
Unlike with channels, the API will only sync updates to users about threads the current user can view. When receiving a guild create payload, the API will only include active threads the current user can view. Threads inside of private channels are completely private to the members of that private channel. As such, when gaining access to a channel the API sends a thread list sync, which includes all active threads in that channel.
Threads also track membership. Users must be added to a thread before sending messages in them. The API will helpfully automatically add users to a thread when sending a message in that thread.
Guilds have limits on the number of active threads and members per thread. Once these are reached additional threads cannot be created or unarchived, and users cannot be added. Threads do not count against the per-guild channel limit.
The threads topic has some more information.
json
{"id": "41771983423143937","guild_id": "41771983423143937","parent_id": "41771983423143937","owner_id": "41771983423143937","name": "don't buy dota-2","type": 11,"last_message_id": "155117677105512449","message_count": 1,"member_count": 5,"rate_limit_per_user": 2,"thread_metadata": {"archived": false,"auto_archive_duration": 1440,"archive_timestamp": "2021-04-12T23:40:39.855793+00:00","locked": false}}
Overwrite Object
See permissions for more information about the allow
and deny
fields.
Overwrite Structure
Field | Type | Description |
---|---|---|
id | snowflake | role or user id |
type | int | either 0 (role) or 1 (member) |
allow | string | permission bit set |
deny | string | permission bit set |
Thread Metadata Object
The thread metadata object contains a number of thread-specific channel fields that are not needed by other channel types.
Thread Metadata Structure
Field | Type | Description |
---|---|---|
archived | boolean | whether the thread is archived |
auto_archive_duration | integer | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 |
archive_timestamp | ISO8601 timestamp | timestamp when the thread's archive status was last changed, used for calculating recent activity |
locked | boolean | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it |
invitable? | boolean | whether non-moderators can add other non-moderators to a thread; only available on private threads |
Thread Member Object
A thread member is used to indicate whether a user has joined a thread or not.
Thread Member Structure
Field | Type | Description |
---|---|---|
id? * | snowflake | the id of the thread |
user_id? * | snowflake | the id of the user |
join_timestamp | ISO8601 timestamp | the time the current user last joined the thread |
flags | integer | any user-thread settings, currently only used for notifications |
* These fields are ommitted on the member sent within each thread in the GUILD_CREATE event
Endpoints
Get Channel
GET
/channels/{channel.id}
Get a channel by ID. Returns a channel object. If the channel is a thread, a thread member object is included in the returned result.
Modify Channel
PATCH
/channels/{channel.id}
Update a channel's settings. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. All JSON parameters are optional.
JSON Params (Group DM)
Fires a Channel Update Gateway event.
Field | Type | Description |
---|---|---|
name | string | 1-100 character channel name |
icon | binary | base64 encoded icon |
JSON Params (Guild channel)
Requires the MANAGE_CHANNELS
permission for the guild. Fires a Channel Update Gateway event. If modifying a category, individual Channel Update events will fire for each child channel that also changes. If modifying permission overwrites, the MANAGE_ROLES
permission is required. Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES
overwrite in the channel).
Field | Type | Description | Channel Type |
---|---|---|---|
name | string | 1-100 character channel name | All |
type | integer | the type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | Text, News |
position | ?integer | the position of the channel in the left-hand listing | All |
topic | ?string | 0-1024 character channel topic | Text, News |
nsfw | ?boolean | whether the channel is nsfw | Text, News, Store |
rate_limit_per_user | ?integer | amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel , are unaffected | Text |
bitrate | ?integer | the bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) | Voice |
user_limit | ?integer | the user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit | Voice |
permission_overwrites | ?array of overwrite objects | channel or category-specific permissions | All |
parent_id | ?snowflake | id of the new parent category for a channel | Text, News, Store, Voice |
rtc_region | ?string | channel voice region id, automatic when set to null | Voice |
video_quality_mode | ?integer | the camera video quality mode of the voice channel | Voice |
default_auto_archive_duration | ?integer | the default duration for newly created threads in the channel, in minutes, to automatically archive the thread after recent activity | Text, News |
JSON Params (Thread)
When setting archived
to false
, when locked
is also false
, only the SEND_MESSAGES
permission is required.
Otherwise, requires the MANAGE_THREADS
permission. Fires a Thread Update Gateway event. Requires the thread to have archived
set to false
or be set to false
in the request.
Field | Type | Description |
---|---|---|
name | string | 1-100 character channel name |
archived | boolean | whether the thread is archived |
auto_archive_duration* | integer | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 |
locked | boolean | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it |
invitable | boolean | whether non-moderators can add other non-moderators to a thread; only available on private threads |
rate_limit_per_user | ?integer | amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages , manage_thread , or manage_channel , are unaffected |
* The 3 day and 7 day archive durations require the server to be boosted. The guild features will indicate if a server is able to use those settings.
Delete/Close Channel
DELETE
/channels/{channel.id}
Delete a channel, or close a private message. Requires the MANAGE_CHANNELS
permission for the guild, or MANAGE_THREADS
if the channel is a thread. Deleting a category does not delete its child channels; they will have their parent_id
removed and a Channel Update Gateway event will fire for each of them. Returns a channel object on success. Fires a Channel Delete Gateway event (or Thread Delete if the channel was a thread).
Edit Channel Permissions
PUT
/channels/{channel.id}/permissions/{overwrite.id}
Edit the channel permission overwrites for a user or role in a channel. Only usable for guild channels. Requires the MANAGE_ROLES
permission. Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES
overwrite in the channel). Returns a 204 empty response on success. For more information about permissions, see permissions.
JSON Params
Field | Type | Description |
---|---|---|
allow | string | the bitwise value of all allowed permissions |
deny | string | the bitwise value of all disallowed permissions |
type | integer | 0 for a role or 1 for a member |
Get Channel Invites
GET
/channels/{channel.id}/invites
Returns a list of invite objects (with invite metadata) for the channel. Only usable for guild channels. Requires the MANAGE_CHANNELS
permission.
Create Channel Invite
POST
/channels/{channel.id}/invites
Create a new invite object for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE
permission. All JSON parameters for this route are optional, however the request body is not. If you are not sending any fields, you still have to send an empty JSON object ({}
). Returns an invite object. Fires an Invite Create Gateway event.
JSON Params
Field | Type | Description | Default |
---|---|---|---|
max_age | integer | duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days) | 86400 (24 hours) |
max_uses | integer | max number of uses or 0 for unlimited. between 0 and 100 | 0 |
temporary | boolean | whether this invite only grants temporary membership | false |
unique | boolean | if true, don't try to reuse a similar invite (useful for creating many unique one time use invites) | false |
target_type | integer | the type of target for this voice channel invite | |
target_user_id | snowflake | the id of the user whose stream to display for this invite, required if target_type is 1, the user must be streaming in the channel | |
target_application_id | snowflake | the id of the embedded application to open for this invite, required if target_type is 2, the application must have the EMBEDDED flag |
Delete Channel Permission
DELETE
/channels/{channel.id}/permissions/{overwrite.id}
Delete a channel permission overwrite for a user or role in a channel. Only usable for guild channels. Requires the MANAGE_ROLES
permission. Returns a 204 empty response on success. For more information about permissions, see permissions
Follow News Channel
POST
/channels/{channel.id}/followers
Follow a News Channel to send messages to a target channel. Requires the MANAGE_WEBHOOKS
permission in the target channel. Returns a followed channel object.
JSON Params
Field | Type | Description |
---|---|---|
webhook_channel_id | snowflake | id of target channel |
Trigger Typing Indicator
POST
/channels/{channel.id}/typing
Post a typing indicator for the specified channel. Generally bots should not implement this route. However, if a bot is responding to a command and expects the computation to take a few seconds, this endpoint may be called to let the user know that the bot is processing their message. Returns a 204 empty response on success. Fires a Typing Start Gateway event.
Group DM Add Recipient
PUT
/channels/{channel.id}/recipients/{user.id}
Adds a recipient to a Group DM using their access token.
JSON Params
Field | Type | Description |
---|---|---|
access_token | string | access token of a user that has granted your app the gdm.join scope |
nick | string | nickname of the user being added |
Group DM Remove Recipient
DELETE
/channels/{channel.id}/recipients/{user.id}
Removes a recipient from a Group DM.
Start Thread with Message
POST
/channels/{channel.id}/messages/{message.id}/threads
Creates a new thread from an existing message. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Thread Create Gateway event.
When called on a GUILD_TEXT
channel, creates a GUILD_PUBLIC_THREAD
. When called on a GUILD_NEWS
channel, creates a GUILD_NEWS_THREAD
. The id of the created thread will be the same as the id of the message, and as such a message can only have a single thread created from it.
JSON Params
Field | Type | Description |
---|---|---|
name | string | 1-100 character channel name |
auto_archive_duration* | integer | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 |
* The 3 day and 7 day archive durations require the server to be boosted. The guild features will indicate if a server is able to use those settings.
Start Thread without Message
POST
/channels/{channel.id}/threads
Creates a new thread that is not connected to an existing message. The created thread defaults to a GUILD_PRIVATE_THREAD
*. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Thread Create Gateway event.
JSON Params
Field | Type | Description |
---|---|---|
name | string | 1-100 character channel name |
auto_archive_duration** | integer | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 |
type?*** | integer | the type of thread to create |
invitable? | boolean | whether non-moderators can add other non-moderators to a thread; only available when creating a private thread |
* Creating a private thread requires the server to be boosted. The guild features will indicate if that is possible for the guild.
** The 3 day and 7 day archive durations require the server to be boosted. The guild features will indicate if that is possible for the guild.
*** In API v9, type
defaults to PRIVATE_THREAD
in order to match the behavior when thread documentation was first published. In API v10 this will be changed to be a required field, with no default.
Join Thread
PUT
/channels/{channel.id}/thread-members/@me
Adds the current user to a thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
Add Thread Member
PUT
/channels/{channel.id}/thread-members/{user.id}
Adds another member to a thread. Requires the ability to send messages in the thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
Leave Thread
DELETE
/channels/{channel.id}/thread-members/@me
Removes the current user from a thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
Remove Thread Member
DELETE
/channels/{channel.id}/thread-members/{user.id}
Removes another member from a thread. Requires the MANAGE_THREADS
permission, or the creator of the thread if it is a GUILD_PRIVATE_THREAD
. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
List Thread Members
GET
/channels/{channel.id}/thread-members
Returns array of thread members objects that are members of the thread.
List Active Threads
GET
/channels/{channel.id}/threads/active
Returns all active threads in the channel, including public and private threads. Threads are ordered by their id
, in descending order.
Response Body
Field | Type | Description |
---|---|---|
threads | array of channel objects | the active threads |
members | array of thread members objects | a thread member object for each returned thread the current user has joined |
has_more | boolean | whether there are potentially additional threads that could be returned on a subsequent call |
List Public Archived Threads
GET
/channels/{channel.id}/threads/archived/public
Returns archived threads in the channel that are public. When called on a GUILD_TEXT
channel, returns threads of type GUILD_PUBLIC_THREAD
. When called on a GUILD_NEWS
channel returns threads of type GUILD_NEWS_THREAD
. Threads are ordered by archive_timestamp
, in descending order. Requires the READ_MESSAGE_HISTORY
permission.
Query String Params
Field | Type | Description |
---|---|---|
before? | ISO8601 timestamp | returns threads before this timestamp |
limit? | integer | optional maximum number of threads to return |
Response Body
Field | Type | Description |
---|---|---|
threads | array of channel objects | the public, archived threads |
members | array of thread members objects | a thread member object for each returned thread the current user has joined |
has_more | boolean | whether there are potentially additional threads that could be returned on a subsequent call |
List Private Archived Threads
GET
/channels/{channel.id}/threads/archived/private
Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD
. Threads are ordered by archive_timestamp
, in descending order. Requires both the READ_MESSAGE_HISTORY
and MANAGE_THREADS
permissions.
Query String Params
Field | Type | Description |
---|---|---|
before? | ISO8601 timestamp | returns threads before this timestamp |
limit? | integer | optional maximum number of threads to return |
Response Body
Field | Type | Description |
---|---|---|
threads | array of channel objects | the private, archived threads |
members | array of thread members objects | a thread member object for each returned thread the current user has joined |
has_more | boolean | whether there are potentially additional threads that could be returned on a subsequent call |
List Joined Private Archived Threads
GET
/channels/{channel.id}/users/@me/threads/archived/private
Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD
, and the user has joined. Threads are ordered by their id
, in descending order. Requires the READ_MESSAGE_HISTORY
permission.
Query String Params
Field | Type | Description |
---|---|---|
before? | snowflake | returns threads before this id |
limit? | integer | optional maximum number of threads to return |
Response Body
Field | Type | Description |
---|---|---|
threads | array of channel objects | the private, archived threads the current user has joined |
members | array of thread members objects | a thread member object for each returned thread the current user has joined |
has_more | boolean | whether there are potentially additional threads that could be returned on a subsequent call |