Channels¶
Manager¶
- class ChannelManager(client: HTTPClient, cache: CacheStorage)¶
Bases:
BaseManagerManager used to fetch
PrivateChannel,GuildChannelorThreadChannelobjects.- get(channel_id: int) ThreadChannel | GuildChannel | PrivateChannel | None¶
Attempts to fetch a
PrivateChannel,GuildChannelorThreadChannelfrom 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,GuildChannelorThreadChannelfrom 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,GuildChannelorThreadChannelfrom 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:
objectRepresents the metadata of a thread.
- 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
- class ThreadMember(data: ThreadMemberPayload, guild_id: int | None = None, user_id: int | None = None)¶
Bases:
objectRepresents information about an user that has joined a thread.
- id: Snowflake | None¶
The ID of the
Thread. Omitted inGUILD_CREATE.
- user_id: Snowflake | None¶
The ID of the
User. Omitted inGUILD_CREATE.
- member: Member | None¶
The Member Object for the user in the
Guild. Omitted inGUILD_CREATE.
- class ForumTag(data: ForumTagPayload)¶
Bases:
objectRepresents a Forum Tag which can be applied to Channels of types
GUILD_FORUMandGUILD_MEDIA.Note
Atleast one of
emoji_idandemoji_namewill always be present.- moderated: bool¶
Whether this Tag can only be added to or removed from valid ChannelType by a member with the
MANAGE_THREADSpermission.
- class GuildChannel(data: GuildChannelPayload, guild_id: int | None = None)¶
Bases:
BasePublicChannelRepresents a Channel/Category in a Guild.
Channel Types¶
- parent_id: Snowflake | None¶
The ID of the category (channel of
GUILD_CATEGORY), if any.
- flags: ChannelFlags¶
The flags of the Channel.
- last_message_id: Snowflake | None¶
The ID of the last message (or
ThreadforGUILD_FORUMandGUILD_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
Noneif no messages are pinned.
- permissions: Permissions | None¶
Computed permissions for the invoking user in the channel, including overwrites, only included when part of the
Resolved Datareceived on anInteraction. 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_FORUMandGUILD_MEDIA, 0-1024 for all others.
- default_auto_archive_duration: timedelta | None¶
The default amount of time before a newly created
threadis 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.
- available_tags: list[ForumTag]¶
The list of tags that can be used in
GUILD_FORUMandGUILD_MEDIAchannels.
- default_sort_order: SortOrderType | None¶
Default sortorder used when posting in a
GUILD_FORUMandGUILD_MEDIAchannel.Noneindicates that the setting hasn’t been set by an admin.
- default_forum_layout: ForumLayoutType | None¶
The default ForumLayout used to display posts in
GUILD_FORUMchannels.
- bitrate: int | None¶
The bitrate in bits/second for a voice channel. (
GUILD_VOICEandGUILD_STAGE_VOICE).
- user_limit: int | None¶
The User Limit for a voice channel. (
GUILD_VOICEandGUILD_STAGE_VOICE).
- rtc_region: str | None¶
The RTC Region ID for a voice channel. (
GUILD_VOICEandGUILD_STAGE_VOICE).
- video_quality_mode: VideoQualityMode¶
The VideoQualityMode of the channel, default
AUTO.
- class ThreadChannel(data: ThreadPayload, guild_id: int | None = None)¶
Bases:
BasePublicChannelRepresents a Thread Channel in a Guild.
Channel Types¶
- flags: ChannelFlags¶
The flags of the Channel.
- last_message_id: Snowflake | None¶
The ID of the last message (or
ThreadforGUILD_FORUMandGUILD_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
Noneif no messages are pinned.
- parent_id¶
- permissions: Permissions | None¶
Computed permissions for the invoking user in the channel, including overwrites, only included when part of the
Resolved Datareceived on anInteraction. 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.
- message_count: int¶
The amount of messages present in this thread, is inaccurate when above 50 for threads made before July 1, 2022.
- applied_tags: list[Snowflake]¶
The tags applied to a thead in a
GUILD_FORUMandGUILD_MEDIAchannel.
- class PrivateChannel(data: PrivateChannelPayload)¶
Bases:
BaseChannelRepresents a private (DM) channel.
- flags: ChannelFlags¶
The flags of the Channel.
- last_message_id: Snowflake | None¶
The ID of the last message (or
ThreadforGUILD_FORUMandGUILD_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
Noneif no messages are pinned.
- type: ChannelType¶
The ChannelType of this Channel. Always
DM.
- class PartialGuildChannel(data: PartialGuildChannelPayload, guild_id: int | None)¶
Bases:
BasePublicChannelRepresents a Partial Channel/Category in a Guild.
Channel Types¶
- flags: ChannelFlags¶
The flags of the Channel.
- last_message_id: Snowflake | None¶
The ID of the last message (or
ThreadforGUILD_FORUMandGUILD_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
Noneif no messages are pinned.
- permissions: Permissions | None¶
Computed permissions for the invoking user in the channel, including overwrites, only included when part of the
Resolved Datareceived on anInteraction. 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_FORUMandGUILD_MEDIA, 0-1024 for all others.
- class PartialThreadChannel(data: PartialThreadPayload, guild_id: int | None = None)¶
Bases:
BasePublicChannelRepresents a Thread Channel in a Guild.
Channel Types¶
- flags: ChannelFlags¶
The flags of the Channel.
- last_message_id: Snowflake | None¶
The ID of the last message (or
ThreadforGUILD_FORUMandGUILD_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
Noneif no messages are pinned.
- parent_id¶
- permissions: Permissions | None¶
Computed permissions for the invoking user in the channel, including overwrites, only included when part of the
Resolved Datareceived on anInteraction. 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:
objectRepresents a minimal channel object for
Message.mention_channels.- type: ChannelType¶
The type of the channel.
- type Channel = ThreadChannel | PrivateChannel | GuildChannel¶
This is only a type hint for all channel types, not an object.