Channels
Pycord provides various channel classes to represent different types of Discord channels.TextChannel
Represents a Discord text channel.Attributes
The channel ID.
The channel name.
The guild the channel belongs to.
The channel’s topic. None if it doesn’t exist.
The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.
The category channel ID this channel belongs to, if applicable.
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.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.The last message ID of the message sent to this channel. It may not point to an existing or valid message.
Returns all the threads that you can see.
Returns all members that can see this channel.
Methods
async send(content, **options)
async send(content, **options)
Sends a message to the channel.Returns:
The content of the message to send.
The rich embed for the content.
A list of embeds to upload. Must be a maximum of 10.
The file to upload.
A list of files to upload. Must be a maximum of 10.
A Discord UI View to add to the message.
Whether the message should be sent using text-to-speech.
If provided, the number of seconds to wait before automatically deleting the message.
Message - The message that was sent.Example:async edit(**options)
async edit(**options)
Edits the channel.Returns:
You must have the
manage_channels permission to use this.The new channel name.
The new channel’s topic.
The new channel’s position.
Whether the channel is marked as NSFW.
Specifies the slowmode rate limit for user in this channel, in seconds.
The new category for this channel. Can be None to remove the category.
TextChannel | None - The newly edited text channel.Example:async create_thread(name, **options)
async create_thread(name, **options)
Creates a thread in this text channel.Returns:
The name of the thread.
A snowflake representing the message to create the thread with. If None is passed then a private thread is created.
The duration in minutes before a thread is automatically archived for inactivity.
The type of thread to create.
Specifies the slowmode rate limit for users in this thread, in seconds.
Thread - The created thread.Example:async purge(limit=100, **options)
async purge(limit=100, **options)
Purges a list of messages that meet the criteria given by the predicate check.Returns:
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.The number of messages to search through. This is not the number of messages that will be deleted.
The function used to check if a message should be deleted.
Same as before in history.
Same as after in history.
The reason for deleting the messages. Shows up on the audit log.
list[Message] - The list of messages that were deleted.Example:async create_webhook(name, **options)
async create_webhook(name, **options)
Creates a webhook for this channel.Returns:
Requires
manage_webhooks permissions.The webhook’s name.
A bytes-like object representing the webhook’s default avatar.
The reason for creating this webhook. Shows up in the audit logs.
Webhook - The created webhook.Example:VoiceChannel
Represents a Discord voice channel.Attributes
The channel ID.
The channel name.
The guild the channel belongs to.
The position in the channel list.
The channel’s preferred audio bitrate in bits per second.
The channel’s limit for number of members that can be in a voice channel. A value of 0 indicates no limit.
Returns all members that are currently inside this voice channel.
Methods
async connect(**options)
async connect(**options)
Connects to the voice channel.Returns:
The timeout for the connection.
Whether the bot should automatically attempt a reconnect if a part of the handshake fails.
A type that subclasses
VoiceProtocol to connect with. Defaults to VoiceClient.VoiceProtocol - A voice client that is connected to the voice channel.Example:async edit(**options)
async edit(**options)
CategoryChannel
Represents a Discord channel category.Attributes
The category ID.
The category name.
The guild the category belongs to.
The position in the category list.
Returns the channels that are under this category.
Methods
async create_text_channel(name, **options)
async create_text_channel(name, **options)
Creates a Returns:
TextChannel under this category.The channel name.
TextChannel - The channel that was just created.async create_voice_channel(name, **options)
async create_voice_channel(name, **options)
Creates a Returns:
VoiceChannel under this category.The channel name.
VoiceChannel - The channel that was just created.Thread
Represents a Discord thread.Attributes
The thread ID.
The thread name.
The guild the thread belongs to.
The parent channel ID this thread belongs to.
The user ID that created this thread.
Whether the thread is archived.
Whether the thread is locked.
The duration in minutes before a thread is automatically archived for inactivity.
An aware timestamp of when the thread’s archived status was last updated.
Methods
async send(content, **options)
async send(content, **options)
Sends a message to the thread. Same parameters as
TextChannel.send().Example:async edit(**options)
async edit(**options)
async join()
async join()
Joins the thread.Example:
async leave()
async leave()
Leaves the thread.Example:
async add_member(member)
async add_member(member)
async remove_member(member)
async remove_member(member)
