Channel¶
discord_http.channel module¶
- class discord_http.channel.BaseChannel(*, state, data, guild_id=None)¶
Bases:
PartialChannelRepresents a base channel object.
- Parameters:
state (DiscordAPI)
data (dict)
guild_id (int | None)
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- property flags: ChannelFlags¶
The flags of the channel.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- property type: ChannelType¶
The channel’s type.
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.CategoryChannel(*, state, data)¶
Bases:
BaseChannelRepresents a category channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property channels: list[BaseChannel | PartialChannel]¶
A list of channels in this category.
This will only return channels that are in the same guild as the category.
- async create_text_channel(name, **kwargs) TextChannel¶
Create a text channel in the category.
- Parameters:
name (
str) – The name of the channeltopic – The topic of the channel
rate_limit_per_user – The rate limit per user of the channel
overwrites – The permission overwrites of the category
parent_id – The Category ID where the channel will be placed
nsfw – Whether the channel is NSFW or not
reason – The reason for creating the text channel
**kwargs – Keyword arguments to pass to the channel, look above
- Return type:
- Returns:
The channel object
- async create_voice_channel(name, **kwargs) VoiceChannel¶
Create a voice channel to category.
- Parameters:
name (
str) – The name of the channelbitrate – The bitrate of the channel
user_limit – The user limit of the channel
rate_limit_per_user – The rate limit per user of the channel
overwrites – The permission overwrites of the category
position – The position of the channel
parent_id – The Category ID where the channel will be placed
nsfw – Whether the channel is NSFW or not
reason – The reason for creating the voice channel
**kwargs – Keyword arguments to pass to the channel, look above
- Return type:
- Returns:
The channel object
- async create_stage_channel(name, **kwargs) StageChannel¶
Create a stage channel.
- Parameters:
name (
str) – The name of the channelbitrate – The bitrate of the channel
user_limit – The user limit of the channel
overwrites – The permission overwrites of the category
position – The position of the channel
video_quality_mode – The video quality mode of the channel
parent_id – The Category ID where the channel will be placed
reason – The reason for creating the stage channel
**kwargs – Keyword arguments to pass to the channel, look above
- Return type:
- Returns:
The created channel
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.DMChannel(*, state, data)¶
Bases:
BaseChannelRepresents a Direct Message channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property last_message: PartialMessage | None¶
The last message in the DM channel, if any.
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.DirectoryChannel(*, state, data)¶
Bases:
BaseChannelRepresents a directory channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.ForumChannel(state, data)¶
Bases:
PublicThreadRepresents a forum channel object.
- Parameters:
state (DiscordAPI)
data (dict)
- default_reaction_emoji: EmojiParser | None¶
The default reaction emoji for the forum channel.
- default_auto_archive_duration: int | None¶
The default auto archive duration in minutes for newly created threads, if set.
- default_thread_rate_limit_per_user: int¶
The initial rate limit per user in seconds for newly created threads.
- default_sort_order: SortOrderType | None¶
The default sort order of posts, None if not set by a channel admin.
- default_forum_layout: ForumLayoutType¶
The default layout used to display posts.
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- applied_tags: tuple[int, ...]¶
The IDs of the tags applied to the thread, only for forum and media threads.
- auto_archive_duration: int¶
The duration in minutes to automatically archive the thread after recent activity.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- property create_timestamp: datetime | None¶
The time the thread was created, only available for threads created after 2022-01-09.
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
A partial guild object.
- invitable: bool¶
Whether non-moderators can add other non-moderators to the thread, only for private threads.
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property last_message: PartialMessage | None¶
A partial message object if the last message ID is available.
- property owner: PartialUser | None¶
A partial user object.
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.ForumTag(*, data)¶
Bases:
objectRepresents a forum tag object.
- Parameters:
data (dict)
- class discord_http.channel.ForumThread(state, data)¶
Bases:
PublicThreadRepresents a thread in a forum channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- message¶
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- applied_tags: tuple[int, ...]¶
The IDs of the tags applied to the thread, only for forum and media threads.
- auto_archive_duration: int¶
The duration in minutes to automatically archive the thread after recent activity.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- property create_timestamp: datetime | None¶
The time the thread was created, only available for threads created after 2022-01-09.
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
A partial guild object.
- invitable: bool¶
Whether non-moderators can add other non-moderators to the thread, only for private threads.
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property last_message: PartialMessage | None¶
A partial message object if the last message ID is available.
- property owner: PartialUser | None¶
A partial user object.
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.GroupDMChannel(*, state, data)¶
Bases:
BaseChannelRepresents a group DM channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.NewsChannel(state, data)¶
Bases:
BaseChannelRepresents a news channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.NewsThread(state, data)¶
Bases:
PublicThreadRepresents a news thread.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- applied_tags: tuple[int, ...]¶
The IDs of the tags applied to the thread, only for forum and media threads.
- auto_archive_duration: int¶
The duration in minutes to automatically archive the thread after recent activity.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- property create_timestamp: datetime | None¶
The time the thread was created, only available for threads created after 2022-01-09.
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
A partial guild object.
- invitable: bool¶
Whether non-moderators can add other non-moderators to the thread, only for private threads.
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property last_message: PartialMessage | None¶
A partial message object if the last message ID is available.
- property owner: PartialUser | None¶
A partial user object.
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.PartialChannel(*, state, id, guild_id=None, parent_id=None)¶
Bases:
PartialBaseRepresents a partial channel object.
- Parameters:
state (DiscordAPI)
id (int)
guild_id (int | None)
parent_id (int | None)
- property type: ChannelType¶
The channel’s type.
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
However since this is Partial, it will always return Permissions.none()
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- class discord_http.channel.PartialThread(*, state, id, guild_id, parent_id, type)¶
Bases:
PartialChannelRepresents a partial thread channel object.
- Parameters:
state (DiscordAPI)
id (int)
guild_id (int)
parent_id (int)
type (ChannelType | int)
- property type: ChannelType¶
The channel’s type.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
However since this is Partial, it will always return Permissions.none()
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.PrivateThread(*, state, data)¶
Bases:
PublicThreadRepresents a private thread.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- applied_tags: tuple[int, ...]¶
The IDs of the tags applied to the thread, only for forum and media threads.
- auto_archive_duration: int¶
The duration in minutes to automatically archive the thread after recent activity.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- property create_timestamp: datetime | None¶
The time the thread was created, only available for threads created after 2022-01-09.
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
A partial guild object.
- invitable: bool¶
Whether non-moderators can add other non-moderators to the thread, only for private threads.
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property last_message: PartialMessage | None¶
A partial message object if the last message ID is available.
- property owner: PartialUser | None¶
A partial user object.
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.PublicThread(*, state, data)¶
Bases:
BaseChannelRepresents a public thread channel object.
- Parameters:
state (DiscordAPI)
data (dict)
- auto_archive_duration: int¶
The duration in minutes to automatically archive the thread after recent activity.
- invitable: bool¶
Whether non-moderators can add other non-moderators to the thread, only for private threads.
- applied_tags: tuple[int, ...]¶
The IDs of the tags applied to the thread, only for forum and media threads.
- property create_timestamp: datetime | None¶
The time the thread was created, only available for threads created after 2022-01-09.
- property type: ChannelType¶
The channel’s type.
- property guild: Guild | PartialGuild | None¶
A partial guild object.
- property owner: PartialUser | None¶
A partial user object.
- property last_message: PartialMessage | None¶
A partial message object if the last message ID is available.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.StageChannel(*, state, data)¶
Bases:
VoiceChannelRepresents a stage channel object.
- Parameters:
state (DiscordAPI)
data (dict)
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- async set_voice_status(status, *, reason=None) None¶
Set the status of the voice channel.
Requires the SET_VOICE_CHANNEL_STATUS permission. If the bot is not connected to the voice channel, MANAGE_CHANNELS is also required.
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- video_quality_mode: VideoQualityType¶
The camera video quality mode of the voice channel.
- property type: ChannelType¶
The channel’s type.
- property stage_instance: StageInstance | None¶
The stage instance for this channel, if available and cached.
- async fetch_stage_instance() StageInstance¶
Fetch the stage instance associated with this stage channel.
- Return type:
- async create_stage_instance(*, topic, privacy_level=<MISSING>, send_start_notification=<MISSING>, guild_scheduled_event=<MISSING>, reason=None) StageInstance¶
Create a stage instance.
- Parameters:
topic (
str) – The topic of the stage instanceprivacy_level (
PrivacyLevelType) – The privacy level of the stage instance. Defaults to PrivacyLevelType.guild_onlysend_start_notification (
bool) – Whether to notify @everyone that the stage instance has started.guild_scheduled_event (
Snowflake|int) – The guild scheduled event to associate with this stage instance.reason (
str|None) – The reason for creating the stage instance
- Return type:
- Returns:
The created stage instance
- class discord_http.channel.StageInstance(*, state, data) None¶
Bases:
PartialBaseRepresents a stage instance for a stage channel.
This holds information about a live stage.
- Parameters:
state (DiscordAPI)
data (dict)
- privacy_level: PrivacyLevelType¶
The privacy level of the stage instance.
- guild_scheduled_event_id: int | None¶
The guild scheduled event ID associated with this stage instance.
- property guild: Guild | PartialGuild | None¶
The guild this stage instance belongs to, or None if unknown.
- property channel: PartialChannel | StageChannel¶
The stage channel this instance is associated with.
- property scheduled_event: PartialScheduledEvent | None¶
The scheduled event linked to this stage instance, if any.
- async edit(*, topic=<MISSING>, privacy_level=<MISSING>, reason=None) Self¶
Edit this stage instance.
- Parameters:
topic (
str) – The new topic of this stage instance.privacy_level (
PrivacyLevelType) – The new privacy level of this stage instance.reason (
str|None) – The reason for editing the stage instance.
- Return type:
Self- Returns:
The edited stage instance
- class discord_http.channel.StoreChannel(*, state, data)¶
Bases:
BaseChannelRepresents a store channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.TextChannel(*, state, data)¶
Bases:
BaseChannelRepresents a text channel.
- Parameters:
state (DiscordAPI)
data (dict)
- default_auto_archive_duration: int | None¶
The default auto archive duration in minutes for newly created threads, if set.
- default_thread_rate_limit_per_user: int¶
The initial rate limit per user in seconds for newly created threads.
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.Thread(*, state, data)¶
Bases:
PublicThreadRepresents a thread channel.
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
The channel’s type.
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- applied_tags: tuple[int, ...]¶
The IDs of the tags applied to the thread, only for forum and media threads.
- auto_archive_duration: int¶
The duration in minutes to automatically archive the thread after recent activity.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- property create_timestamp: datetime | None¶
The time the thread was created, only available for threads created after 2022-01-09.
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
A partial guild object.
- invitable: bool¶
Whether non-moderators can add other non-moderators to the thread, only for private threads.
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property last_message: PartialMessage | None¶
A partial message object if the last message ID is available.
- property owner: PartialUser | None¶
A partial user object.
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- class discord_http.channel.Typing(*, state, channel)¶
Bases:
objectHelper class for the typing indicator.
- Parameters:
state (DiscordAPI)
channel (PartialChannel)
- loop: AbstractEventLoop¶
The event loop to use for the typing indicator.
- channel: PartialChannel¶
The channel the typing indicator is for.
- class discord_http.channel.VoiceChannel(*, state, data)¶
Bases:
BaseChannelRepresents a voice channel object.
- Parameters:
state (DiscordAPI)
data (dict)
- property app_permissions: Permissions | None¶
The bot’s permissions in this channel, only available on resolved channels from an interaction.
- async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None, return_messages=False) list[Message] | int¶
Deletes messages in bulk.
- Parameters:
check (
Callable[[Message],bool] |None) – A function to check if the message should be deletedbefore (
datetime|Message|Snowflake|int|None) – The message before which to deleteafter (
datetime|Message|Snowflake|int|None) – The message after which to deletearound (
datetime|Message|Snowflake|int|None) – The message around which to deletemessage_ids (
list[Message|Snowflake|int] |None) – The message IDs to deletelimit (
int|None) – The maximum amount of messages to deletereturn_messages (
bool) – Whether to return the deleted messages or just the count of deleted messages
- Return type:
- Returns:
Returns a list of messages deleted if return_messages is True, otherwise returns the count of deleted messages.
- property channel: BaseChannel | CategoryChannel | PartialChannel | None¶
The channel the thread is in.
Only returns a full object if cache is enabled for guild and channel.
- async create_forum_or_media(name, *, content=None, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, view=None, auto_archive_duration=4320, rate_limit_per_user=None, flags=None, applied_tags=None, stickers=None, reason=None) ForumThread¶
Create a forum or media thread in the channel.
- Parameters:
name (
str) – The name of the threadallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityrate_limit_per_user (
int|None) – How long the slowdown should beflags (
MessageFlags|None) – Flags of the messageapplied_tags (
list[ForumTag|int] |None) – The tags to be applied to the threadstickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3
- Return type:
- Returns:
The created thread
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user_id=None, target_application_id=None, user_ids=None, role_ids=None, reason=None) Invite¶
Create an invite for the channel.
- Parameters:
max_uses (
int|None) – The maximum amount of uses for the invitetemporary (
bool) – If the invite should be temporaryunique (
bool) – If the invite should be uniquetarget_type (
InviteTargetType|int|None) – The type of target for this voice channel invitetarget_user_id (
Snowflake|int|None) – The ID of the user whose stream to display for this invite. (Requiresd if target_type is InviteTargetType.stream)target_application_id (
Snowflake|int|None) – The ID of the embedded application to open for this invite. (Requiresd if target_type is InviteTargetType.embedded_application)user_ids (
list[Snowflake|int] |None) – The users to be able to use this invite. Any users not in this list, will see the invite as “invalid”. Up to 1000 users are sent directly, anything above is uploaded as a CSV file and processed in the background by Discord.role_ids (
list[Snowflake|int] |None) – The roles to be able to use this invite
- Return type:
- Returns:
The invite object
- async create_thread(name, *, type=ChannelType.guild_private_thread, auto_archive_duration=4320, invitable=True, rate_limit_per_user=None, reason=None) PublicThread | PrivateThread | NewsThread¶
Creates a thread in the channel.
- Parameters:
name (
str) – The name of the threadtype (
ChannelType|int) – The type of thread to createauto_archive_duration (
int|None) – The duration in minutes to automatically archive the thread after recent activityinvitable (
bool) – If the thread is invitablerate_limit_per_user (
timedelta|int|None) – How long the slowdown should be
- Return type:
- Returns:
The thread object
- Raises:
If the auto_archive_duration is not 60, 1440, 4320 or 10080 - If the rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, name=<MISSING>, type=<MISSING>, position=<MISSING>, topic=<MISSING>, nsfw=<MISSING>, rate_limit_per_user=<MISSING>, bitrate=<MISSING>, user_limit=<MISSING>, overwrites=<MISSING>, parent_id=<MISSING>, rtc_region=<MISSING>, video_quality_mode=<MISSING>, default_auto_archive_duration=<MISSING>, flags=<MISSING>, available_tags=<MISSING>, default_reaction_emoji=<MISSING>, default_thread_rate_limit_per_user=<MISSING>, default_sort_order=<MISSING>, default_forum_layout=<MISSING>, archived=<MISSING>, auto_archive_duration=<MISSING>, locked=<MISSING>, invitable=<MISSING>, applied_tags=<MISSING>, reason=None) BaseChannel¶
Edit the channel.
Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.
- Parameters:
type (
ChannelType|int|None) – The new type of the channel (Text, Announcement)position (
int|None) – The new position of the channel (All)topic (
str|None) – The new topic of the channel (Text, Announcement, Forum, Media)nsfw (
bool|None) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)rate_limit_per_user (
int|None) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)bitrate (
int|None) – The new bitrate of the channel (Voice, Stage)user_limit (
int|None) – The new user limit of the channel (Voice, Stage)overwrites (
list[PermissionOverwrite] |None) – The new permission overwrites of the channel (All)parent_id (
Snowflake|int|None) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)rtc_region (
str|None) – The new RTC region of the channel (Voice, Stage)video_quality_mode (
VideoQualityType|int|None) – The new video quality mode of the channel (Voice, Stage)default_auto_archive_duration (
int|None) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)flags (
ChannelFlags|None) – The new flags of the channel (Forum, Media)available_tags (
list[ForumTag] |None) – The new available tags of the channel (Forum, Media)default_reaction_emoji (
str|None) – The new default reaction emoji of the channel (Forum, Media)default_thread_rate_limit_per_user (
int|None) – The new default thread rate limit per user of the channel (Text, Forum, Media)default_sort_order (
SortOrderType|int|None) – The new default sort order of the channel (Forum, Media)default_forum_layout (
ForumLayoutType|int|None) – The new default forum layout of the channel (Forum)archived (
bool|None) – If the thread should be archived (Thread, Forum)auto_archive_duration (
int|None) – The new auto archive duration of the thread (Thread, Forum)locked (
bool|None) – If the thread should be locked (Thread, Forum)invitable (
bool|None) – If the thread should be invitable by everyone (Thread)applied_tags (
list[ForumTag|int] |None) – The new applied tags of the forum thread (Forum, Media)reason (
str|None) – The reason for editing the channel (All)
- Return type:
- Returns:
The channel object
- async fetch() BaseChannel¶
Fetches the channel and returns the channel object.
- Return type:
- async fetch_archived_private_threads(*, client=False, before=None, limit=None) list[PrivateThread]¶
Fetch all archived private threads.
- async fetch_archived_public_threads(*, before=None, limit=None) list[PublicThread]¶
Fetch all archived public threads.
- async fetch_history(*, before=None, after=None, around=None, limit=100, oldest_first=False) AsyncIterator[Message]¶
Fetch the channel’s message history.
- Parameters:
before (
datetime|Message|Snowflake|int|None) – Get messages before this messageafter (
datetime|Message|Snowflake|int|None) – Get messages after this messagearound (
datetime|Message|Snowflake|int|None) – Get messages around this messagelimit (
int|None) – The maximum amount of messages to fetch. None will fetch all users.oldest_first (
bool) – Whether to fetch the oldest messages first
- Yields:
The message object
- Return type:
- async fetch_pins(*, before=None, limit=50) AsyncIterator[MessagePin]¶
Fetch the pinned messages for the channel in question, newest pin first.
- Parameters:
- Yields:
The pinned message, along with when it was pinned
- Return type:
- async fetch_thread_member(user_id) ThreadMember¶
Fetch a thread member.
- Parameters:
user_id (
int) – The user ID to fetch- Return type:
- Returns:
The thread member object
- async fetch_thread_members(*, after=None, limit=100) list[ThreadMember]¶
Fetch thread members.
- property flags: ChannelFlags¶
The flags of the channel.
- async follow_announcement_channel(source_channel_id, *, reason=None) PartialWebhook¶
Follow an announcement channel to send messages to the webhook.
- Parameters:
- Return type:
- Returns:
The webhook created in this channel for the followed channel
- classmethod from_dict(*, state, data, guild_id=None) BaseChannel¶
Create a channel object from a dictionary.
Requires the state to be set
- Parameters:
state (
DiscordAPI) – The state to usedata (
dict) – Data provided by Discord APIguild_id (
int|None) – The ID of the guild the channel belongs to, if any
- Return type:
- Returns:
The channel object
- get_partial_message(message_id) PartialMessage¶
Get a partial message object from the channel.
- Parameters:
message_id (
int) – The message ID to get the partial message from- Return type:
- Returns:
The partial message object
- property guild: Guild | PartialGuild | None¶
The guild the channel belongs to (if available).
If you are using gateway cache, it can return full object too
- is_obfuscated() bool¶
Whether this channel’s data is obfuscated because the bot lacks VIEW_CHANNEL access to it.
Obfuscated channels have their name replaced with “___hidden___” and other sensitive fields nulled or reduced. Access is regained the moment the bot’s permissions change, at which point a CHANNEL_UPDATE event delivers full data.
- Return type:
- property parent: BaseChannel | CategoryChannel | PartialChannel | None¶
The parent channel of the thread or the parent category of the channel.
Only returns a full object if cache is enabled for guild and channel.
- property permission_overwrites: list[PermissionOverwrite]¶
Shows the permission overwrites for the channel.
- permissions_for(member) Permissions¶
Returns the permissions for a member in the channel.
Note that this only works if you are using Gateway with guild, role and channel cache.
- Parameters:
member (
Member) – The member to get the permissions for.- Return type:
- Returns:
The permissions for the member in the channel.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, type=4, poll=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>, delete_after=None) Message¶
Send a message to the channel.
- Parameters:
tts (
bool|None) – If the message should be sent as a TTS messagetype (
ResponseType|int) – The type of response to the messageallowed_mentions (
AllowedMentions|None) – The allowed mentions for the messageflags (
MessageFlags|None) – Flags of the messagestickers (
list[PartialSticker|Snowflake|int] |None) – Stickers from the guild to send with the message, max 3nonce (
int|str|None) – Nonce to verify the message was sent, max 25 charactersenforce_nonce (
bool) – Whether the nonce should be enforced, returning the existing message if it was already sentshared_client_theme (
SharedClientTheme|None) – Client theme to share with the messagedelete_after (
float|None) – How long to wait before deleting the message
- Return type:
- Returns:
The message object
- async set_permission(overwrite, *, reason=None) None¶
Set a permission overwrite for the channel.
- Parameters:
overwrite (
PermissionOverwrite) – The new overwrite permissions for the spesific role/user
- Return type:
- typing() Typing¶
Makes the bot trigger the typing indicator.
There are two ways you can use this: - Usual await call - Using async with to type as long as you need
# Method 1 await channel.typing() # Stops after 10 seconds or message sent # Method 2 async with channel.typing(): asyncio.sleep(4)
- Return type:
- video_quality_mode: VideoQualityType¶
The camera video quality mode of the voice channel.
- property type: ChannelType¶
The channel’s type.