Channel

discord_http.channel module

class discord_http.channel.BaseChannel(*, state: DiscordAPI, data: dict)[source]

Bases: PartialChannel

property mention: str

The channel’s mention

Type:

str

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.CategoryChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

async create_stage_channel(name: str, **kwargs) StageChannel[source]

Create a stage channel

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

  • bitrate (Optional[int]) – The bitrate of the channel

  • user_limit (Optional[int]) – The user limit of the channel

  • overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category

  • position (Optional[int]) – The position of the channel

  • video_quality_mode (Optional[Union[VideoQualityType, int]]) – The video quality mode of the channel

  • parent_id (Optional[Union[Snowflake, int]]) – The Category ID where the channel will be placed

  • reason (Optional[str]) – The reason for creating the stage channel

Returns:

The created channel

Return type:

StageChannel

async create_text_channel(name: str, **kwargs) TextChannel[source]

Create a text channel in the category

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

  • topic (Optional[str]) – The topic of the channel

  • rate_limit_per_user (Optional[int]) – The rate limit per user of the channel

  • overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category

  • parent_id (Optional[Snowflake]) – The Category ID where the channel will be placed

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not

  • reason (Optional[str]) – The reason for creating the text channel

Returns:

The channel object

Return type:

TextChannel

async create_voice_channel(name: str, **kwargs) VoiceChannel[source]

Create a voice channel to category

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

  • bitrate (Optional[int]) – The bitrate of the channel

  • user_limit (Optional[int]) – The user limit of the channel

  • rate_limit_per_user (Optional) – The rate limit per user of the channel

  • overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category

  • position (Optional[int]) – The position of the channel

  • parent_id (Optional[Snowflake]) – The Category ID where the channel will be placed

  • nsfw (Optional[bool]) – Whether the channel is NSFW or not

  • reason (Optional[str]) – The reason for creating the voice channel

Returns:

The channel object

Return type:

VoiceChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.DMChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

async edit(*args, **kwargs) None[source]

Only here to prevent errors

Raises:

TypeError – If you try to edit a DM channel

property mention: str

The channel’s mention

Type:

str

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.DirectoryChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.ForumChannel(state: DiscordAPI, data: dict)[source]

Bases: PublicThread

class discord_http.channel.ForumTag(*, data: dict)[source]

Bases: object

classmethod create(name: str | None = None, *, emoji_id: int | None = None, emoji_name: str | None = None, moderated: bool = False) ForumTag[source]

Create a forum tag, used for editing available_tags

Parameters:
  • name (Optional[str]) – The name of the tag

  • emoji_id (Optional[int]) – The emoji ID of the tag

  • emoji_name (Optional[str]) – The emoji name of the tag

  • moderated (bool) – If the tag is moderated

Returns:

The tag object

Return type:

ForumTag

to_dict() dict[source]
class discord_http.channel.ForumThread(state: DiscordAPI, data: dict)[source]

Bases: PublicThread

class discord_http.channel.GroupDMChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.NewsChannel(state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.NewsThread(state: DiscordAPI, data: dict)[source]

Bases: PublicThread

class discord_http.channel.PartialChannel(*, state: DiscordAPI, id: int, guild_id: int | None = None)[source]

Bases: PartialBase

async add_thread_member(user_id: int) None[source]

Add a thread member

Parameters:

user_id (int) – The user ID to add

async create_forum_or_media(name: str, *, content: str | None = None, embed: Embed | None = None, embeds: list[Embed] | None = None, file: File | None = None, files: list[File] | None = None, allowed_mentions: AllowedMentions | None = None, view: View | None = None, auto_archive_duration: int | None = 4320, rate_limit_per_user: int | None = None, applied_tags: list[ForumTag | int] | None = None) ForumThread[source]

Create a forum or media thread in the channel

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

  • content (Optional[str]) – The content of the message

  • embed (Optional[Embed]) – Embed to be sent

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

  • file (Optional[File]) – File to be sent

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

  • allowed_mentions (Optional[AllowedMentions]) – The allowed mentions for the message

  • view (Optional[View]) – The view to be sent

  • auto_archive_duration (Optional[int]) – The duration in minutes to automatically archive the thread after recent activity

  • rate_limit_per_user (Optional[int]) – How long the slowdown should be

  • applied_tags (Optional[list[Union["ForumTag", int]]]) – The tags to be applied to the thread

Returns:

_description_

Return type:

ForumThread

async create_invite(*, max_age: timedelta | int = 86400, max_uses: int | None = 0, temporary: bool = False, unique: bool = False) Invite[source]

Create an invite for the channel

Parameters:
  • max_age (Union[timedelta, int]) – How long the invite should last

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

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

Returns:

The invite object

Return type:

Invite

async create_thread(name: str, *, type: ChannelType | int = ChannelType.guild_private_thread, auto_archive_duration: int | None = 4320, invitable: bool = True, rate_limit_per_user: timedelta | int | None = None, reason: str | None = None) PublicThread | PrivateThread | NewsThread[source]

Creates a thread in the channel

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

  • type (Optional[Union[ChannelType, int]]) – The type of thread to create

  • auto_archive_duration (Optional[int]) – The duration in minutes to automatically archive the thread after recent activity

  • invitable (bool) – If the thread is invitable

  • rate_limit_per_user (Optional[Union[timedelta, int]]) – How long the slowdown should be

  • reason (Optional[str]) – The reason for creating the thread

Returns:

The thread object

Return type:

Union[PublicThread, PrivateThread, NewsThread]

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: str, *, avatar: File | bytes | None = None, reason: str | None = None) Webhook[source]

Create a webhook for the channel

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

  • avatar (Optional[File]) – The avatar of the webhook

  • reason (Optional[str]) – The reason for creating the webhook that appears in audit logs

Returns:

The webhook object

Return type:

Webhook

async delete(*, reason: str | None = None) None[source]

Delete the channel

Parameters:

reason (Optional[str]) – The reason for deleting the channel

async delete_messages(message_ids: list[int], *, reason: str | None = None) None[source]

_summary_

Parameters:
  • message_ids (list[int]) – List of message IDs to delete

  • reason (Optional[str]) – The reason of why you are deleting them (appears in audit log)

Raises:

ValueError – If you provide >100 IDs to delete

async delete_permission(id: Snowflake | int, *, reason: str | None = None) None[source]

Delete a permission overwrite for the channel

Parameters:
  • id (Union[Snowflake, int]) – The ID of the overwrite

  • reason (Optional[str]) – The reason for deleting the overwrite

async edit(*, name: str | None = <MISSING>, type: ~discord_http.enums.ChannelType | int | None = <MISSING>, position: int | None = <MISSING>, topic: str | None = <MISSING>, nsfw: bool | None = <MISSING>, rate_limit_per_user: int | None = <MISSING>, bitrate: int | None = <MISSING>, user_limit: int | None = <MISSING>, overwrites: list[~discord_http.flag.PermissionOverwrite] | None = <MISSING>, parent_id: ~discord_http.object.Snowflake | int | None = <MISSING>, rtc_region: str | None = <MISSING>, video_quality_mode: ~discord_http.enums.VideoQualityType | int | None = <MISSING>, default_auto_archive_duration: int | None = <MISSING>, flags: ~discord_http.flag.ChannelFlags | None = <MISSING>, available_tags: list[~discord_http.channel.ForumTag] | None = <MISSING>, default_reaction_emoji: str | None = <MISSING>, default_thread_rate_limit_per_user: int | None = <MISSING>, default_sort_order: ~discord_http.enums.SortOrderType | int | None = <MISSING>, default_forum_layout: ~discord_http.enums.ForumLayoutType | int | None = <MISSING>, archived: bool | None = <MISSING>, auto_archive_duration: int | None = <MISSING>, locked: bool | None = <MISSING>, invitable: bool | None = <MISSING>, applied_tags: list[~discord_http.channel.ForumTag | int] | None = <MISSING>, reason: str | None = None) Self[source]

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 (Optional[str]) – New name of the channel (All)

  • type (Optional[Union[ChannelType, int]]) – The new type of the channel (Text, Announcement)

  • position (Optional[int]) – The new position of the channel (All)

  • topic (Optional[str]) – The new topic of the channel (Text, Announcement, Forum, Media)

  • nsfw (Optional[bool]) – If the channel should be NSFW (Text, Voice, Announcement, Stage, Forum, Media)

  • rate_limit_per_user (Optional[int]) – How long the slowdown should be (Text, Voice, Stage, Forum, Media)

  • bitrate (Optional[int]) – The new bitrate of the channel (Voice, Stage)

  • user_limit (Optional[int]) – The new user limit of the channel (Voice, Stage)

  • overwrites (Optional[list[PermissionOverwrite]]) – The new permission overwrites of the channel (All)

  • parent_id (Optional[Union[Snowflake, int]]) – The new parent ID of the channel (Text, Voice, Announcement, Stage, Forum, Media)

  • rtc_region (Optional[str]) – The new RTC region of the channel (Voice, Stage)

  • video_quality_mode (Optional[Union[VideoQualityType, int]]) – The new video quality mode of the channel (Voice, Stage)

  • default_auto_archive_duration (Optional[int]) – The new default auto archive duration of the channel (Text, Announcement, Forum, Media)

  • flags (Optional[ChannelFlags]) – The new flags of the channel (Forum, Media)

  • available_tags (Optional[list[ForumTag]]) – The new available tags of the channel (Forum, Media)

  • default_reaction_emoji (Optional[str]) – The new default reaction emoji of the channel (Forum, Media)

  • default_thread_rate_limit_per_user (Optional[int]) – The new default thread rate limit per user of the channel (Text, Forum, Media)

  • default_sort_order (Optional[Union[SortOrderType, int]]) – The new default sort order of the channel (Forum, Media)

  • default_forum_layout (Optional[Union[ForumLayoutType, int]]) – The new default forum layout of the channel (Forum)

  • archived (Optional[bool]) – If the thread should be archived (Thread, Forum)

  • auto_archive_duration (Optional[int]) – The new auto archive duration of the thread (Thread, Forum)

  • locked (Optional[bool]) – If the thread should be locked (Thread, Forum)

  • invitable (Optional[bool]) – If the thread should be invitable by everyone (Thread)

  • applied_tags (Optional[list[Union[ForumTag, int]]) – The new applied tags of the forum thread (Forum, Media)

  • reason (Optional[str]) – The reason for editing the channel (All)

Returns:

The channel object

Return type:

BaseChannel

async fetch() BaseChannel[source]

BaseChannel: Fetches the channel and returns the channel object

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

Fetch all archived private threads

Parameters:

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

Returns:

The list of private threads

Return type:

list[PrivateThread]

async fetch_archived_public_threads() list[PublicThread][source]

Fetch all archived public threads

Returns:

The list of public threads

Return type:

list[PublicThread]

async fetch_history(*, before: datetime | Message | Snowflake | int | None = None, after: datetime | Message | Snowflake | int | None = None, around: datetime | Message | Snowflake | int | None = None, limit: int | None = 100) AsyncIterator[Message][source]

Fetch the channel’s message history

Parameters:
  • before (Optional[Union[datetime, Message, Snowflake, int]]) – Get messages before this message

  • after (Optional[Union[datetime, Message, Snowflake, int]]) – Get messages after this message

  • around (Optional[Union[datetime, Message, Snowflake, int]]) – Get messages around this message

  • limit (Optional[int]) – The maximum amount of messages to fetch. None will fetch all users.

Yields:

Message – The message object

async fetch_message(message_id: int) Message[source]

Fetch a message from the channel

Parameters:

message_id (int) – The message ID to fetch

Returns:

The message object

Return type:

Message

async fetch_pins() list[Message][source]

Fetch all pinned messages for the channel in question

Returns:

The list of pinned messages

Return type:

list[Message]

async fetch_thread_member(user_id: int) ThreadMember[source]

Fetch a thread member

Parameters:

user_id (int) – The user ID to fetch

Returns:

The thread member object

Return type:

ThreadMember

async fetch_thread_members() list[ThreadMember][source]

Fetch all thread members

Returns:

The list of thread members

Return type:

list[ThreadMember]

async follow_announcement_channel(source_channel_id: Snowflake | int) None[source]

Follow an announcement channel to send messages to the webhook

Parameters:

source_channel_id (int) – The channel ID to follow

classmethod from_dict(*, state: DiscordAPI, data: dict) Self[source]

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

Returns:

The channel object

Return type:

BaseChannel

get_partial_message(message_id: int) PartialMessage[source]

Get a partial message object from the channel

Parameters:

message_id (int) – The message ID to get the partial message from

Returns:

The partial message object

Return type:

PartialMessage

property guild: PartialGuild | None

The guild the channel belongs to (if available)

Type:

Optional[PartialGuild]

async join_thread() None[source]

Make the bot join a thread

async leave_thread() None[source]

Make the bot leave a thread

async remove_thread_member(user_id: int) None[source]

Remove a thread member

Parameters:

user_id (int) – The user ID to remove

async send(content: str | None = <MISSING>, *, embed: ~discord_http.embeds.Embed | None = <MISSING>, embeds: list[~discord_http.embeds.Embed] | None = <MISSING>, file: ~discord_http.file.File | None = <MISSING>, files: list[~discord_http.file.File] | None = <MISSING>, view: ~discord_http.view.View | None = <MISSING>, tts: bool | None = False, type: ~discord_http.enums.ResponseType | int = 4, poll: Poll | None = <MISSING>, allowed_mentions: ~discord_http.mentions.AllowedMentions | None = <MISSING>) Message[source]

Send a message to the channel

Parameters:
  • content (Optional[str]) – Cotnent of the message

  • embed (Optional[Embed]) – Includes an embed object

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

  • file (Optional[File]) – A file object

  • files (Union[list[File], File]) – A list of file objects

  • view (View) – Send components to the message

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

  • type (Optional[ResponseType]) – The type of response to the message

  • allowed_mentions (Optional[AllowedMentions]) – The allowed mentions for the message

  • poll (Optional[Poll]) – The poll to be sent

Returns:

The message object

Return type:

Message

async set_permission(id: Snowflake | int, *, overwrite: PermissionOverwrite, reason: str | None = None) None[source]

Set a permission overwrite for the channel

Parameters:
  • id (Union[Snowflake, int]) – The ID of the overwrite

  • overwrite (PermissionOverwrite) – The new overwrite permissions

  • reason (Optional[str]) – The reason for editing the overwrite

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

async typing() None[source]

Makes the bot trigger the typing indicator. Times out after 10 seconds

class discord_http.channel.PrivateThread(*, state: DiscordAPI, data: dict)[source]

Bases: PublicThread

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.PublicThread(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property channel: PartialChannel

Returns a partial channel object

Type:

PartialChannel

property guild: PartialGuild

Returns a partial guild object

Type:

PartialGuild

property last_message: PartialMessage | None

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

Type:

Optional[PartialMessage]

property owner: PartialUser

Returns a partial user object

Type:

PartialUser

class discord_http.channel.StageChannel(*, state: DiscordAPI, data: dict)[source]

Bases: VoiceChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.StoreChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.TextChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.Thread(*, state: DiscordAPI, data: dict)[source]

Bases: PublicThread

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.VoiceChannel(*, state: DiscordAPI, data: dict)[source]

Bases: BaseChannel

property type: ChannelType

Returns the channel’s type

Type:

ChannelType

class discord_http.channel.VoiceRegion(*, data: dict)[source]

Bases: object