Skip to main content

Channels

Pycord provides various channel classes to represent different types of Discord channels.

TextChannel

Represents a Discord text channel.

Attributes

id
int
The channel ID.
name
str
The channel name.
guild
Guild
The guild the channel belongs to.
topic
str | None
The channel’s topic. None if it doesn’t exist.
position
int | None
The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.
category_id
int | None
The category channel ID this channel belongs to, if applicable.
nsfw
bool
If the channel is marked as “not safe for work”.
To check if the channel or the guild of that channel are marked as NSFW, consider is_nsfw() instead.
slowmode_delay
int
The number of seconds a member must wait between sending messages in this channel. A value of 0 denotes that it is disabled. Bots and users with manage_channels or manage_messages bypass slowmode.
last_message_id
int | None
The last message ID of the message sent to this channel. It may not point to an existing or valid message.
threads
list[Thread]
Returns all the threads that you can see.
members
list[Member]
Returns all members that can see this channel.

Methods

Sends a message to the channel.
content
str
The content of the message to send.
embed
Embed
The rich embed for the content.
embeds
list[Embed]
A list of embeds to upload. Must be a maximum of 10.
file
File
The file to upload.
files
list[File]
A list of files to upload. Must be a maximum of 10.
view
View
A Discord UI View to add to the message.
tts
bool
Whether the message should be sent using text-to-speech.
delete_after
float
If provided, the number of seconds to wait before automatically deleting the message.
Returns: Message - The message that was sent.Example:
await channel.send("Hello world!")
await channel.send("Embed example", embed=my_embed)
Edits the channel.
You must have the manage_channels permission to use this.
name
str
The new channel name.
topic
str
The new channel’s topic.
position
int
The new channel’s position.
nsfw
bool
Whether the channel is marked as NSFW.
slowmode_delay
int
Specifies the slowmode rate limit for user in this channel, in seconds.
category
CategoryChannel | None
The new category for this channel. Can be None to remove the category.
Returns: TextChannel | None - The newly edited text channel.Example:
await channel.edit(name="new-name", topic="New topic")
Creates a thread in this text channel.
name
str
required
The name of the thread.
message
Snowflake | None
A snowflake representing the message to create the thread with. If None is passed then a private thread is created.
auto_archive_duration
int
The duration in minutes before a thread is automatically archived for inactivity.
type
ChannelType | None
The type of thread to create.
slowmode_delay
int
Specifies the slowmode rate limit for users in this thread, in seconds.
Returns: Thread - The created thread.Example:
thread = await channel.create_thread(name="Discussion", auto_archive_duration=60)
Purges a list of messages that meet the criteria given by the predicate check.
You must have the manage_messages permission to delete messages even if they are your own. The read_message_history permission is also needed to retrieve message history.
limit
int
The number of messages to search through. This is not the number of messages that will be deleted.
check
Callable[[Message], bool]
The function used to check if a message should be deleted.
before
Snowflake | datetime
Same as before in history.
after
Snowflake | datetime
Same as after in history.
reason
str
The reason for deleting the messages. Shows up on the audit log.
Returns: list[Message] - The list of messages that were deleted.Example:
def is_bot(m):
    return m.author.bot

deleted = await channel.purge(limit=100, check=is_bot)
print(f"Deleted {len(deleted)} bot messages")
Creates a webhook for this channel.
Requires manage_webhooks permissions.
name
str
required
The webhook’s name.
avatar
bytes
A bytes-like object representing the webhook’s default avatar.
reason
str
The reason for creating this webhook. Shows up in the audit logs.
Returns: Webhook - The created webhook.Example:
webhook = await channel.create_webhook(name="My Webhook")

VoiceChannel

Represents a Discord voice channel.

Attributes

id
int
The channel ID.
name
str
The channel name.
guild
Guild
The guild the channel belongs to.
position
int
The position in the channel list.
bitrate
int
The channel’s preferred audio bitrate in bits per second.
user_limit
int
The channel’s limit for number of members that can be in a voice channel. A value of 0 indicates no limit.
members
list[Member]
Returns all members that are currently inside this voice channel.

Methods

Connects to the voice channel.
timeout
float
The timeout for the connection.
reconnect
bool
Whether the bot should automatically attempt a reconnect if a part of the handshake fails.
cls
VoiceProtocol
A type that subclasses VoiceProtocol to connect with. Defaults to VoiceClient.
Returns: VoiceProtocol - A voice client that is connected to the voice channel.Example:
voice_client = await voice_channel.connect()
Edits the voice channel.
You must have the manage_channels permission to use this.
name
str
The new channel name.
position
int
The new channel’s position.
bitrate
int
The new channel’s bitrate.
user_limit
int
The new channel’s user limit.
Returns: VoiceChannel | None - The newly edited voice channel.

CategoryChannel

Represents a Discord channel category.

Attributes

id
int
The category ID.
name
str
The category name.
guild
Guild
The guild the category belongs to.
position
int
The position in the category list.
channels
list[GuildChannel]
Returns the channels that are under this category.

Methods

Creates a TextChannel under this category.
name
str
required
The channel name.
Returns: TextChannel - The channel that was just created.
Creates a VoiceChannel under this category.
name
str
required
The channel name.
Returns: VoiceChannel - The channel that was just created.

Thread

Represents a Discord thread.

Attributes

id
int
The thread ID.
name
str
The thread name.
guild
Guild
The guild the thread belongs to.
parent_id
int
The parent channel ID this thread belongs to.
owner_id
int
The user ID that created this thread.
archived
bool
Whether the thread is archived.
locked
bool
Whether the thread is locked.
auto_archive_duration
int
The duration in minutes before a thread is automatically archived for inactivity.
archive_timestamp
datetime
An aware timestamp of when the thread’s archived status was last updated.

Methods

Sends a message to the thread. Same parameters as TextChannel.send().Example:
await thread.send("Thread message")
Edits the thread.
name
str
The new thread name.
archived
bool
Whether to archive the thread.
locked
bool
Whether to lock the thread.
auto_archive_duration
int
The new auto archive duration in minutes.
Returns: Thread - The newly edited thread.
Joins the thread.Example:
await thread.join()
Leaves the thread.Example:
await thread.leave()
Adds a member to the thread.
member
Member
required
The member to add to the thread.
Example:
await thread.add_member(member)
Removes a member from the thread.
member
Member
required
The member to remove from the thread.
Example:
await thread.remove_member(member)

Build docs developers (and LLMs) love