Channel¶
discord_http.channel module¶
- class discord_http.channel.BaseChannel(*, state, data, guild_id=None)¶
Bases:
PartialChannel
- Parameters:
state (DiscordAPI)
data (dict)
guild_id (int | None)
- 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
) – Guild ID to create the channel object with
- Return type:
- Returns:
The channel object
- 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.
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.CategoryChannel(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- 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 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
- 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
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.DMChannel(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.DirectoryChannel(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.ForumChannel(state, data)¶
Bases:
PublicThread
- Parameters:
state (DiscordAPI)
data (dict)
- 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.
- class discord_http.channel.ForumThread(state, data)¶
Bases:
PublicThread
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.GroupDMChannel(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.NewsChannel(state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.NewsThread(state, data)¶
Bases:
PublicThread
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.PartialChannel(*, state, id, guild_id=None)¶
Bases:
PartialBase
- Parameters:
state (DiscordAPI)
id (int)
guild_id (int | 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:
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
] |None
) – The message IDs to deletelimit (
int
|None
) – The maximum amount of messages to delete
- Return type:
- 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 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 beapplied_tags (
list
[ForumTag
|int
] |None
) – The tags to be applied to the thread
- Return type:
- Returns:
_description_
- async create_invite(*, max_age=86400, max_uses=0, temporary=False, unique=False) Invite ¶
Create an invite for the channel.
- 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) 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:
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:
- 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:
- Returns:
The list of private threads
- async fetch_archived_public_threads() list[PublicThread] ¶
Fetch all archived public threads.
- Return type:
- 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:
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:
Message – The message object
- 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() list[ThreadMember] ¶
Fetch all thread members.
- Return type:
- Returns:
The list of thread members
- async follow_announcement_channel(source_channel_id) None ¶
Follow an announcement channel to send messages to the webhook.
- 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 usedata (
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:
- 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¶
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:
- 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>, 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 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:
- 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:
state (DiscordAPI)
id (int)
guild_id (int)
parent_id (int)
type (ChannelType | int)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.PrivateThread(*, state, data)¶
Bases:
PublicThread
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.PublicThread(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- 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:
state (DiscordAPI)
data (dict)
- 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:
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:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.TextChannel(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.Thread(*, state, data)¶
Bases:
PublicThread
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.
- class discord_http.channel.VoiceChannel(*, state, data)¶
Bases:
BaseChannel
- Parameters:
state (DiscordAPI)
data (dict)
- property type: ChannelType¶
Returns the channel’s type.