Channel

discord_http.channel module

class discord_http.channel.BaseChannel(*, state, data, guild_id=None)

Bases: PartialChannel

Parameters:
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 use

  • data (dict) – Data provided by Discord API

  • guild_id (int | None) – Guild ID to create the channel object with

Return type:

BaseChannel

Returns:

The channel object

property mention: str

The channel’s mention.

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:

Permissions

Returns:

The permissions for the member in the channel.

property type: ChannelType

Returns the channel’s type.

class discord_http.channel.CategoryChannel(*, state, data)

Bases: BaseChannel

Parameters:
property channels: list[BaseChannel | PartialChannel]

Returns a list of channels in this category.

This will only return channels that are in the same guild as the category.

async create_stage_channel(name, **kwargs) StageChannel

Create a stage channel.

Parameters:
  • name (str) – The name of the channel

  • bitrate – 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:

StageChannel

Returns:

The created channel

async create_text_channel(name, **kwargs) TextChannel

Create a text channel in the category.

Parameters:
  • name (str) – The name of the channel

  • topic – 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:

TextChannel

Returns:

The channel object

async create_voice_channel(name, **kwargs) VoiceChannel

Create a voice channel to category.

Parameters:
  • name (str) – The name of the channel

  • bitrate – 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:

VoiceChannel

Returns:

The channel object

property type: ChannelType

Returns the channel’s type.

class discord_http.channel.DMChannel(*, state, data)

Bases: BaseChannel

Parameters:
async edit(*args, **kwargs) None

Only here to prevent errors.

Raises:

TypeError – If you try to edit a DM channel

Return type:

None

property mention: str

The channel’s mention.

property type: ChannelType

Returns the channel’s type.

class discord_http.channel.DirectoryChannel(*, state, data)

Bases: BaseChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.ForumChannel(state, data)

Bases: PublicThread

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.ForumTag(*, data)

Bases: object

Parameters:

data (dict)

classmethod create(name=None, *, emoji_id=None, emoji_name=None, moderated=False) ForumTag

Create a forum tag, used for editing available_tags.

Parameters:
  • name (str | None) – The name of the tag

  • emoji_id (int | None) – The emoji ID of the tag

  • emoji_name (str | None) – The emoji name of the tag

  • moderated (bool) – If the tag is moderated

Return type:

ForumTag

Returns:

The tag object

classmethod from_data(*, data) Self

Create a forum tag from a dictionary.

Parameters:

data (dict) – The dictionary to create the forum tag from

Return type:

Self

Returns:

The forum tag

to_dict() dict

The forum tag as a dictionary.

Return type:

dict

class discord_http.channel.ForumThread(state, data)

Bases: PublicThread

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.GroupDMChannel(*, state, data)

Bases: BaseChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.NewsChannel(state, data)

Bases: BaseChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.NewsThread(state, data)

Bases: PublicThread

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.PartialChannel(*, state, id, guild_id=None)

Bases: PartialBase

Parameters:
async add_thread_member(user_id) None

Add a thread member.

Parameters:

user_id (int) – The user ID to add

Return type:

None

async bulk_delete_messages(*, check=None, before=None, after=None, around=None, message_ids=None, limit=100, reason=None) list[Message] | None

Deletes messages in bulk.

Parameters:
Return type:

list[Message] | None

Returns:

Returns a list of messages deleted If you provide message_ids upfront, it will skip history search and delete

property channel: BaseChannel | CategoryChannel | PartialChannel | None

Returns 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, applied_tags=None) ForumThread

Create a forum or media thread in the channel.

Parameters:
  • name (str) – The name of the thread

  • content (str | None) – The content of the message

  • embed (Embed | None) – Embed to be sent

  • embeds (list[Embed] | None) – List of embeds to be sent

  • file (File | None) – File to be sent

  • files (list[File] | None) – List of files to be sent

  • allowed_mentions (AllowedMentions | None) – The allowed mentions for the message

  • view (View | None) – The view to be sent

  • auto_archive_duration (int | None) – The duration in minutes to automatically archive the thread after recent activity

  • rate_limit_per_user (int | None) – How long the slowdown should be

  • applied_tags (list[ForumTag | int] | None) – The tags to be applied to the thread

Return type:

ForumThread

Returns:

_description_

async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False) Invite

Create an invite for the channel.

Parameters:
  • max_age (timedelta | int) – How long the invite should last

  • max_uses (int | None) – The maximum amount of uses for the invite

  • temporary (bool) – If the invite should be temporary

  • unique (bool) – If the invite should be unique

Return type:

Invite

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 thread

  • type (ChannelType | int) – The type of thread to create

  • auto_archive_duration (int | None) – The duration in minutes to automatically archive the thread after recent activity

  • invitable (bool) – If the thread is invitable

  • rate_limit_per_user (timedelta | int | None) – How long the slowdown should be

  • reason (str | None) – The reason for creating the thread

Return type:

PublicThread | PrivateThread | NewsThread

Returns:

The thread object

Raises:

ValueError

  • 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 create_webhook(name, *, avatar=None, reason=None) Webhook

Create a webhook for the channel.

Parameters:
  • name (str) – The name of the webhook

  • avatar (File | bytes | None) – The avatar of the webhook

  • reason (str | None) – The reason for creating the webhook that appears in audit logs

Return type:

Webhook

Returns:

The webhook object

async delete(*, reason=None) None

Delete the channel.

Parameters:

reason (str | None) – The reason for deleting the channel

Return type:

None

async delete_permission(id, *, reason=None) None

Delete a permission overwrite for the channel.

Parameters:
  • id (Snowflake | int) – The ID of the overwrite

  • reason (str | None) – The reason for deleting the overwrite

Return type:

None

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) Self

Edit the channel.

Note that this method globaly edits any channel type. So be sure to use the correct parameters for the channel.

Parameters:
  • name (str | None) – New name of the channel (All)

  • 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:

Self

Returns:

The channel object

async fetch() BaseChannel

Fetches the channel and returns the channel object.

Return type:

BaseChannel

async fetch_archived_private_threads(*, client=False) list[PrivateThread]

Fetch all archived private threads.

Parameters:

client (bool) – If it should fetch only where the client is a member of the thread

Return type:

list[PrivateThread]

Returns:

The list of private threads

async fetch_archived_public_threads() list[PublicThread]

Fetch all archived public threads.

Return type:

list[PublicThread]

Returns:

The list of 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:
Yields:

Message – The message object

Return type:

AsyncIterator[Message]

async fetch_message(message_id) Message

Fetch a message from the channel.

Parameters:

message_id (int) – The message ID to fetch

Return type:

Message

Returns:

The message object

async fetch_pins() list[Message]

Fetch all pinned messages for the channel in question.

Return type:

list[Message]

Returns:

The list of pinned messages

async fetch_thread_member(user_id) ThreadMember

Fetch a thread member.

Parameters:

user_id (int) – The user ID to fetch

Return type:

ThreadMember

Returns:

The thread member object

async fetch_thread_members() list[ThreadMember]

Fetch all thread members.

Return type:

list[ThreadMember]

Returns:

The list of thread members

async follow_announcement_channel(source_channel_id) None

Follow an announcement channel to send messages to the webhook.

Parameters:

source_channel_id (Snowflake | int) – The channel ID to follow

Return type:

None

classmethod from_dict(*, state, data) Self

Create a channel object from a dictionary.

Requires the state to be set

Parameters:
  • state (DiscordAPI) – The state to use

  • data (dict) – Data provided by Discord API

Return type:

Self

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:

PartialMessage

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

async join_thread() None

Make the bot join a thread.

Return type:

None

async leave_thread() None

Make the bot leave a thread.

Return type:

None

property mention: str

The channel’s mention.

property parent: BaseChannel | CategoryChannel | PartialChannel | None

Returns 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:

Permissions

Returns:

The permissions for the member in the channel.

async remove_thread_member(user_id) None

Remove a thread member.

Parameters:

user_id (int) – The user ID to remove

Return type:

None

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>, delete_after=None) Message

Send a message to the channel.

Parameters:
  • content (str | None) – Cotnent of the message

  • embed (Embed | None) – Includes an embed object

  • embeds (list[Embed] | None) – List of embed objects

  • file (File | None) – A file object

  • files (list[File] | None) – A list of file objects

  • view (View | None) – Send components to the message

  • tts (bool | None) – If the message should be sent as a TTS message

  • type (ResponseType | int) – The type of response to the message

  • allowed_mentions (AllowedMentions | None) – The allowed mentions for the message

  • poll (Poll | None) – The poll to be sent

  • flags (MessageFlags | None) – Flags of the message

  • delete_after (float | None) – How long to wait before deleting the message

Return type:

Message

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

  • reason (str | None) – The reason for editing the overwrite

Return type:

None

property type: ChannelType

Returns the channel’s 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:

Typing

class discord_http.channel.PartialThread(*, state, id, guild_id, parent_id, type)

Bases: PartialChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.PrivateThread(*, state, data)

Bases: PublicThread

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.PublicThread(*, state, data)

Bases: BaseChannel

Parameters:
property guild: Guild | PartialGuild | None

Returns a partial guild object.

property last_message: PartialMessage | None

Returns a partial message object if the last message ID is available.

property owner: PartialUser | None

Returns a partial user object.

property type: ChannelType

Returns the channel’s type.

class discord_http.channel.StageChannel(*, state, data)

Bases: VoiceChannel

Parameters:
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 instance

  • privacy_level (PrivacyLevelType) – The privacy level of the stage instance. Defaults to PrivacyLevelType.guild_only

  • send_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:

StageInstance

Returns:

The created stage instance

async fetch_stage_instance() StageInstance

Fetch the stage instance associated with this stage channel.

Return type:

StageInstance

Returns:

The stage instance of the channel

property stage_instance: StageInstance | None

Returns the stage instance for this channel, if available and cached.

property type: ChannelType

Returns the channel’s type.

class discord_http.channel.StoreChannel(*, state, data)

Bases: BaseChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.TextChannel(*, state, data)

Bases: BaseChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.Thread(*, state, data)

Bases: PublicThread

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.VoiceChannel(*, state, data)

Bases: BaseChannel

Parameters:
property type: ChannelType

Returns the channel’s type.

class discord_http.channel.VoiceRegion(*, data)

Bases: object

Parameters:

data (dict)