Channels

Manager

class ChannelManager(client: HTTPClient, cache: CacheStorage)

Bases: BaseManager

Manager used to fetch PrivateChannel, GuildChannel or ThreadChannel objects.

get(channel_id: int) ThreadChannel | GuildChannel | PrivateChannel | None

Attempts to fetch a PrivateChannel, GuildChannel or ThreadChannel from the internal cache of the bot.

Parameters:

channel_id (int) – The channel_id of the channel to fetch.

Returns:

  • PrivateChannel – The PrivateChannel object recieved from the cache.

  • GuildChannel – The GuildChannel object recieved from the cache.

  • ThreadChannel – The ThreadChannel object received from the cache.

  • None – The Channel could not be found in the cache.

async fetch(channel_id: int) ThreadChannel | GuildChannel | PrivateChannel

Attempts to fetch a PrivateChannel, GuildChannel or ThreadChannel from the Discord API.

Parameters:

channel_id (int) – The channel_id of the channel to fetch.

Returns:

  • PrivateChannel – The PrivateChannel object recieved from Discord API.

  • GuildChannel – The GuildChannel object recieved from the Discord API.

  • ThreadChannel – The ThreadChannel object received from the Discord API.

Raises:
  • NotFound – Could not find an channel with that ID.

  • Forbidden – You are not allowed to fetch that channel.

  • HTTPException – A HTTP error occured.

async get_or_fetch(channel_id: int) ThreadChannel | GuildChannel | PrivateChannel

A couroutine function that attempts to fetch a PrivateChannel, GuildChannel or ThreadChannel from internal cache and if not present, makes an API call to discord.

Parameters:

channel_id (int) – The channel_id of the channel to fetch.

Returns:

  • PrivateChannel – The PrivateChannel object recieved from Discord API.

  • GuildChannel – The GuildChannel object recieved from the Discord API.

  • ThreadChannel – The ThreadChannel object received from the Discord API.

Raises:
  • NotFound – Could not find an channel with that ID.

  • Forbidden – You are not allowed to fetch that channel.

  • HTTPException – A HTTP error occured.

Objects

class ThreadMetaData(data: ThreadMetaDataPayload)

Bases: object

Represents the metadata of a thread.

archived: bool

Represents if the thread is archived.

auto_archive_duration: timedelta

The amount of time before the thread is auto-archived. Can only be 60, 1440, 4320, 10080 in terms of minutes.

archive_timestamp: datetime

Represents when the thread’s archive status was last changed, used for calculating recent activity

locked: bool

Represents if the thread is locked.

invitable: bool

Whether non-moderators can add other non-moderators to a thread, only available on Private Threads.

create_timestamp: datetime | None

Represents when the thread was created. Will be None for threads older than 2022-01-09.

class ThreadMember(data: ThreadMemberPayload, guild_id: int | None = None, user_id: int | None = None)

Bases: object

Represents information about an user that has joined a thread.

id: Snowflake | None

The ID of the Thread. Omitted in GUILD_CREATE.

user_id: Snowflake | None

The ID of the User. Omitted in GUILD_CREATE.

join_timestamp: datetime

Time the user last joined the thread.

notifications: bool

Represents if the User has notifications enabled.

member: Member | None

The Member Object for the user in the Guild. Omitted in GUILD_CREATE.

class ForumTag(data: ForumTagPayload)

Bases: object

Represents a Forum Tag which can be applied to Channels of types GUILD_FORUM and GUILD_MEDIA.

Note

Atleast one of emoji_id and emoji_name will always be present.

id: Snowflake

The ID of the Tag.

name: str

The name of the tag. (0-20 characters long)

moderated: bool

Whether this Tag can only be added to or removed from valid ChannelType by a member with the MANAGE_THREADS permission.

emoji_id: Snowflake | None

The ID of a Guild’s custom emoji.

emoji_name: str | None

The unicode character of the emoji.

class GuildChannel(data: GuildChannelPayload, guild_id: int | None = None)

Bases: BasePublicChannel

Represents a Channel/Category in a Guild.

Channel Types

parent_id: Snowflake | None

The ID of the category (channel of GUILD_CATEGORY), if any.

property created_at: datetime

The timestamp at which the Channel was created.

Return type:

datetime

flags: ChannelFlags

The flags of the Channel.

guild_id: Snowflake

The Guild ID of the Channel.

id: Snowflake

The ID of the Channel.

last_message_id: Snowflake | None

The ID of the last message (or Thread for GUILD_FORUM and GUILD_MEDIA) that was sent in that channel. May or may not point to a valid message.

last_pin_timestamp: datetime | None

The timestamp when the last pinned message was pinned. May be None if no messages are pinned.

name: str

The name of the channel

permissions: Permissions | None

Computed permissions for the invoking user in the channel, including overwrites, only included when part of the Resolved Data received on an Interaction. This does not include implicit permissions, which may need to be checked separately

rate_limit_per_user: int | None

The amount of time an user has to wait before sending a message (Slowmode). Bots remain unaffected.

type: ChannelType

The type of this Channel.

topic: str | None

The topic of the channel. 0-4096 character limit for GUILD_FORUM and GUILD_MEDIA, 0-1024 for all others.

default_auto_archive_duration: timedelta | None

The default amount of time before a newly created thread is auto-archived. Can only be 60, 1440, 4320, 10080 in terms of minutes.

default_thread_rate_limit_per_user: int | None

The default rate limit for new threads. Does not live-update with the channel’s rate limit. Bots remain unaffected.

position: int | None

Sorting position of the channel (Channels with the same position are sorted by id)

permission_overwrites: list[ChannelPermissionOverwrite]

Explicit permission overwrites for member and roles.

nsfw: bool

Whether the channel is NSFW.

available_tags: list[ForumTag]

The list of tags that can be used in GUILD_FORUM and GUILD_MEDIA channels.

default_sort_order: SortOrderType | None

Default sortorder used when posting in a GUILD_FORUM and GUILD_MEDIA channel. None indicates that the setting hasn’t been set by an admin.

default_forum_layout: ForumLayoutType | None

The default ForumLayout used to display posts in GUILD_FORUM channels.

bitrate: int | None

The bitrate in bits/second for a voice channel. (GUILD_VOICE and GUILD_STAGE_VOICE).

user_limit: int | None

The User Limit for a voice channel. (GUILD_VOICE and GUILD_STAGE_VOICE).

rtc_region: str | None

The RTC Region ID for a voice channel. (GUILD_VOICE and GUILD_STAGE_VOICE).

video_quality_mode: VideoQualityMode

The VideoQualityMode of the channel, default AUTO.

class ThreadChannel(data: ThreadPayload, guild_id: int | None = None)

Bases: BasePublicChannel

Represents a Thread Channel in a Guild.

Channel Types

property created_at: datetime

The timestamp at which the Channel was created.

Return type:

datetime

flags: ChannelFlags

The flags of the Channel.

guild_id: Snowflake

The Guild ID of the Channel.

id: Snowflake

The ID of the Channel.

last_message_id: Snowflake | None

The ID of the last message (or Thread for GUILD_FORUM and GUILD_MEDIA) that was sent in that channel. May or may not point to a valid message.

last_pin_timestamp: datetime | None

The timestamp when the last pinned message was pinned. May be None if no messages are pinned.

name: str

The name of the channel

parent_id
permissions: Permissions | None

Computed permissions for the invoking user in the channel, including overwrites, only included when part of the Resolved Data received on an Interaction. This does not include implicit permissions, which may need to be checked separately

rate_limit_per_user: int | None

The amount of time an user has to wait before sending a message (Slowmode). Bots remain unaffected.

type: ChannelType

The type of this channel.

owner_id: Snowflake

The owner of this thread.

thread_metadata: ThreadMetaData

Metadata of the thread.

message_count: int

The amount of messages present in this thread, is inaccurate when above 50 for threads made before July 1, 2022.

member_count: int

The amount of members in this thread. Stops counting at 50.

total_message_sent: int

The total amount of messages ever sent in this thread.

applied_tags: list[Snowflake]

The tags applied to a thead in a GUILD_FORUM and GUILD_MEDIA channel.

class PrivateChannel(data: PrivateChannelPayload)

Bases: BaseChannel

Represents a private (DM) channel.

property created_at: datetime

The timestamp at which the Channel was created.

Return type:

datetime

flags: ChannelFlags

The flags of the Channel.

id: Snowflake

The ID of the Channel.

last_message_id: Snowflake | None

The ID of the last message (or Thread for GUILD_FORUM and GUILD_MEDIA) that was sent in that channel. May or may not point to a valid message.

last_pin_timestamp: datetime | None

The timestamp when the last pinned message was pinned. May be None if no messages are pinned.

recipients: list[User]

The recipients or the members of the channel.

type: ChannelType

The ChannelType of this Channel. Always DM.

class PartialGuildChannel(data: PartialGuildChannelPayload, guild_id: int | None)

Bases: BasePublicChannel

Represents a Partial Channel/Category in a Guild.

Channel Types

property created_at: datetime

The timestamp at which the Channel was created.

Return type:

datetime

flags: ChannelFlags

The flags of the Channel.

guild_id: Snowflake

The Guild ID of the Channel.

id: Snowflake

The ID of the Channel.

last_message_id: Snowflake | None

The ID of the last message (or Thread for GUILD_FORUM and GUILD_MEDIA) that was sent in that channel. May or may not point to a valid message.

last_pin_timestamp: datetime | None

The timestamp when the last pinned message was pinned. May be None if no messages are pinned.

name: str

The name of the channel

permissions: Permissions | None

Computed permissions for the invoking user in the channel, including overwrites, only included when part of the Resolved Data received on an Interaction. This does not include implicit permissions, which may need to be checked separately

rate_limit_per_user: int | None

The amount of time an user has to wait before sending a message (Slowmode). Bots remain unaffected.

parent_id: Snowflake | None

The ID of the category (channel of GUILD_CATEGORY), if any.

type: ChannelType

The type of this Channel.

topic: str | None

The topic of the channel. 0-4096 character limit for GUILD_FORUM and GUILD_MEDIA, 0-1024 for all others.

position: int | None

Sorting position of the channel (Channels with the same position are sorted by id)

nsfw: bool

Whether the channel is NSFW.

class PartialThreadChannel(data: PartialThreadPayload, guild_id: int | None = None)

Bases: BasePublicChannel

Represents a Thread Channel in a Guild.

Channel Types

property created_at: datetime

The timestamp at which the Channel was created.

Return type:

datetime

flags: ChannelFlags

The flags of the Channel.

guild_id: Snowflake

The Guild ID of the Channel.

id: Snowflake

The ID of the Channel.

last_message_id: Snowflake | None

The ID of the last message (or Thread for GUILD_FORUM and GUILD_MEDIA) that was sent in that channel. May or may not point to a valid message.

last_pin_timestamp: datetime | None

The timestamp when the last pinned message was pinned. May be None if no messages are pinned.

name: str

The name of the channel

parent_id
permissions: Permissions | None

Computed permissions for the invoking user in the channel, including overwrites, only included when part of the Resolved Data received on an Interaction. This does not include implicit permissions, which may need to be checked separately

rate_limit_per_user: int | None

The amount of time an user has to wait before sending a message (Slowmode). Bots remain unaffected.

type: ChannelType

The type of this channel.

thread_metadata: ThreadMetaData

Metadata of the thread.

class ChannelMention(data: ChannelMentionPayload)

Bases: object

Represents a minimal channel object for Message.mention_channels.

id: Snowflake

The ID of the channel.

guild_id: Snowflake

The Guild ID of the channel.

type: ChannelType

The type of the channel.

name: str

The name of the channel.

type Channel = ThreadChannel | PrivateChannel | GuildChannel

This is only a type hint for all channel types, not an object.

Enums

class ChannelType(*values)
GUILD_TEXT = 0
DM = 1
GUILD_VOICE = 2
GROUP_DM = 3
GUILD_CATEGORY = 4
GUILD_ANNOUNCEMENT = 5
ANNOUNCEMENT_THREAD = 10
PUBLIC_THREAD = 11
PRIVATE_THREAD = 12
GUILD_STAGE_VOICE = 13
GUILD_DIRECTORY = 14
GUILD_FORUM = 15
GUILD_MEDIA = 16
class ChannelPermissionOverwriteType(*values)
ROLE = 0
MEMBER = 1
class VideoQualityMode(*values)
AUTO = 1
FULL = 2
class SortOrderType(*values)
LATEST_ACTIVITY = 0
CREATION_DATE = 1
class ForumLayoutType(*values)
NOT_SET = 0
LIST_VIEW = 1
GALLERY_VIEW = 2

Errors

class UnknownChannelType

Raised when the channel parser could not parse the channel you received.

add_note(object, /)

Exception.add_note(note) – add a note to the exception

args
with_traceback(object, /)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.