Channel Models#
- enum interactions.api.models.channel.ChannelType(value)[source]#
An enumerable object representing the type of channels.
- Member Type:
Valid values are as follows:
- GUILD_TEXT = <ChannelType.GUILD_TEXT: 0>#
- DM = <ChannelType.DM: 1>#
- GUILD_VOICE = <ChannelType.GUILD_VOICE: 2>#
- GROUP_DM = <ChannelType.GROUP_DM: 3>#
- GUILD_CATEGORY = <ChannelType.GUILD_CATEGORY: 4>#
- GUILD_ANNOUNCEMENT = <ChannelType.GUILD_ANNOUNCEMENT: 5>#
- GUILD_STORE = <ChannelType.GUILD_STORE: 6>#
- ANNOUNCEMENT_THREAD = <ChannelType.ANNOUNCEMENT_THREAD: 10>#
- PUBLIC_THREAD = <ChannelType.PUBLIC_THREAD: 11>#
- PRIVATE_THREAD = <ChannelType.PRIVATE_THREAD: 12>#
- GUILD_STAGE_VOICE = <ChannelType.GUILD_STAGE_VOICE: 13>#
- GUILD_DIRECTORY = <ChannelType.GUILD_DIRECTORY: 14>#
- GUILD_FORUM = <ChannelType.GUILD_FORUM: 15>#
- class interactions.api.models.channel.Thread(kwargs_dict=None, /, **other_kwargs)[source]#
New in version 4.0.2.
An object representing a thread.
Note
This is a derivation of the base Channel, since a thread can be its own event.
- class interactions.api.models.channel.Channel(kwargs_dict=None, /, **other_kwargs)[source]#
A class object representing all types of channels.
- Variables:
id (Snowflake) – The (snowflake) ID of the channel.
type (ChannelType) – The type of channel.
guild_id (Optional[Snowflake]) – The ID of the guild if it is not a DM channel.
position (Optional[int]) – The position of the channel.
permission_overwrites (List[Overwrite]) – The non-synced permissions of the channel.
name (str) – The name of the channel.
topic (Optional[str]) – The description of the channel.
nsfw (Optional[bool]) – Whether the channel is NSFW.
last_message_id (Snowflake) – The ID of the last message sent.
bitrate (Optional[int]) – The audio bitrate of the channel.
user_limit (Optional[int]) – The maximum amount of users allowed in the channel.
rate_limit_per_user (Optional[int]) – The concurrent ratelimit for users in the channel.
recipients (Optional[List[User]]) – The recipients of the channel.
icon (Optional[str]) – The icon of the channel.
owner_id (Optional[Snowflake]) – The owner of the channel.
application_id (Optional[Snowflake]) – The application of the channel.
parent_id (Optional[Snowflake]) – The ID of the “parent”/main channel.
last_pin_timestamp (Optional[datetime]) – The timestamp of the last pinned message in the channel.
rtc_region (Optional[str]) – The region of the WebRTC connection for the channel.
video_quality_mode (Optional[int]) – The set quality mode for video streaming in the channel.
message_count (int) – The amount of messages in the channel.
member_count (Optional[int]) – The amount of members in the channel.
newly_created (Optional[bool]) – Boolean representing if a thread is created.
thread_metadata (Optional[ThreadMetadata]) – The thread metadata of the channel.
member (Optional[ThreadMember]) – The member of the thread in the channel.
default_auto_archive_duration (Optional[int]) – The set auto-archive time for all threads to naturally follow in the channel.
permissions (Optional[Permissions]) – The permissions of the channel.
flags (Optional[int]) – The flags of the channel.
total_message_sent (Optional[int]) – Number of messages ever sent in a thread.
default_thread_slowmode_delay (Optional[int]) – The default slowmode delay in seconds for threads, if this channel is a forum.
available_tags (Optional[List[Tags]]) – Tags in a forum channel, if any.
applied_tags (Optional[List[Snowflake]]) – The IDs of tags that have been applied to a thread, if any.
default_reaction_emoji (Optional[Emoji]) – Default reaction emoji for threads created in a forum, if any.
- property guild_id: Snowflake | None#
New in version 4.4.0.
Attempts to get the guild ID the channel is in.
- Returns:
The ID of the guild this channel belongs to.
- Return type:
Optional[Snowflake]
- property guild: Guild | None#
New in version 4.4.0.
Attempts to get the guild the channel is in.
- Returns:
The guild this channel belongs to.
- Return type:
- property typing: Awaitable | AbstractContextManager#
New in version 4.3.2.
Manages the typing of the channel. Use with await or async with
- Returns:
A manager for typing
- Return type:
- property mention: str#
New in version 4.1.0.
Returns a string that allows you to mention the given channel.
- Returns:
The string of the mentioned channel.
- Return type:
- property voice_states: List[VoiceState]#
New in version 4.4.0.
Returns all voice states this channel has. Only applicable for voice channels.
- Return type:
List[VoiceState]
- history(start_at=<interactions.MISSING>, reverse=False, maximum=inf, check=None)[source]#
New in version 4.3.2.
- Parameters:
start_at (Optional[Union[int, str, Snowflake, Message]]) – The message to begin getting the history from
reverse (Optional[bool]) – Whether to only get newer message. Default False
maximum (Optional[int]) – A set maximum of messages to get before stopping the iteration
check (Optional[Callable[[Message], Union[bool, Awaitable[bool]]]]) – A custom check to ignore certain messages
- Returns:
An asynchronous iterator over the history of the channel
- Return type:
- async send(content=<interactions.MISSING>, *, tts=<interactions.MISSING>, attachments=<interactions.MISSING>, files=<interactions.MISSING>, embeds=<interactions.MISSING>, allowed_mentions=<interactions.MISSING>, stickers=<interactions.MISSING>, components=<interactions.MISSING>)[source]#
New in version 4.0.2.
Sends a message in the channel.
- Parameters:
content (Optional[str]) – The contents of the message as a string or string-converted value.
tts (Optional[bool]) – Whether the message utilizes the text-to-speech Discord programme or not.
files (Optional[Union[File, List[File]]]) –
New in version 4.2.0.
A file or list of files to be attached to the message.
attachments (Optional[List[Attachment]]) –
New in version 4.3.0.
The attachments to attach to the message. Needs to be uploaded to the CDN first.
embeds (Optional[Union[Embed, List[Embed]]]) – An embed, or list of embeds for the message.
allowed_mentions (Optional[Union[AllowedMentions, dict]]) – The allowed mentions for the message.
stickers (Optional[List[Sticker]]) –
New in version 4.3.0.
A list of stickers to send with your message. You can send up to 3 stickers per message.
components (Optional[Union[ActionRow, Button, SelectMenu, List[Actionrow], List[Button], List[SelectMenu]]]) – A component, or list of components for the message.
- Returns:
The sent message as an object.
- Return type:
- async modify(name=<interactions.MISSING>, topic=<interactions.MISSING>, bitrate=<interactions.MISSING>, user_limit=<interactions.MISSING>, rate_limit_per_user=<interactions.MISSING>, position=<interactions.MISSING>, permission_overwrites=<interactions.MISSING>, parent_id=<interactions.MISSING>, nsfw=<interactions.MISSING>, archived=<interactions.MISSING>, auto_archive_duration=<interactions.MISSING>, locked=<interactions.MISSING>, reason=None)[source]#
New in version 4.0.2.
Edits the channel.
New in version 4.2.0: The fields
archived
,auto_archive_duration
andlocked
. All require the provided channel to be a thread.- Parameters:
name (Optional[str]) – The name of the channel, defaults to the current value of the channel
topic (Optional[str]) – The topic of that channel, defaults to the current value of the channel
bitrate (Optional[int]) – (voice channel only) The bitrate (in bits) of the voice channel, defaults to the current value of the channel
user_limit (Optional[int]) – (voice channel only) Maximum amount of users in the channel, defaults to the current value of the channel
rate_limit_per_user (Optional[int]) – Amount of seconds a user has to wait before sending another message (0-21600), defaults to the current value of the channel
position (Optional[int]) – Sorting position of the channel, defaults to the current value of the channel
parent_id (Optional[int]) – The id of the parent category for a channel, defaults to the current value of the channel
nsfw (Optional[bool]) – Whether the channel is nsfw or not, defaults to the current value of the channel
permission_overwrites (Optional[List[Overwrite]]) – The permission overwrites, if any
archived (Optional[bool]) –
New in version 4.2.0.
Whether the thread is archived
auto_archive_duration (Optional[int]) –
New in version 4.2.0.
The time after the thread is automatically archived. One of 60, 1440, 4320, 10080
locked (Optional[bool]) –
New in version 4.2.0.
Whether the thread is locked
reason (Optional[str]) – The reason for the edit
- Returns:
The modified channel as new object
- Return type:
- async set_topic(topic, *, reason=None)[source]#
New in version 4.1.0.
Sets the topic of the channel.
- async set_bitrate(bitrate, *, reason=None)[source]#
New in version 4.1.0.
Sets the bitrate of the channel.
- async set_user_limit(user_limit, *, reason=None)[source]#
New in version 4.1.0.
Sets the user_limit of the channel.
- async set_rate_limit_per_user(rate_limit_per_user, *, reason=None)[source]#
New in version 4.1.0.
Sets the amount of seconds a user has to wait before sending another message.
- async set_position(position, *, reason=None)[source]#
New in version 4.1.0.
Sets the position of the channel.
- async set_parent_id(parent_id, *, reason=None)[source]#
New in version 4.1.0.
Sets the parent_id of the channel.
- async set_nsfw(nsfw, *, reason=None)[source]#
New in version 4.1.0.
Sets the nsfw-flag of the channel.
- async archive(archived=True, *, reason=None)[source]#
New in version 4.2.0.
Sets the archived state of the thread.
- async set_auto_archive_duration(auto_archive_duration, *, reason=None)[source]#
New in version 4.2.0.
Sets the time after the thread is automatically archived.
- async lock(locked=True, *, reason=None)[source]#
New in version 4.2.0.
Sets the locked state of the thread.
- async add_member(member_id)[source]#
New in version 4.2.0.
This adds a member to the channel, if the channel is a thread.
- Parameters:
member_id (int) – The id of the member to add to the channel
- async remove_member(member_id)[source]#
New in version 4.3.0.
This removes a member of the channel, if the channel is a thread.
- Parameters:
member_id (int) – The id of the member to remove of the channel
- async publish_message(message_id)[source]#
New in version 4.0.2.
Publishes (API calls it crossposts) a message in the channel to any that is followed by.
- async get_pinned_messages()[source]#
New in version 4.0.2.
Get all pinned messages from the channel.
- Returns:
A list of pinned message objects.
- Return type:
List[Message]
- async purge(amount, check=<interactions.MISSING>, before=<interactions.MISSING>, reason=None, bulk=True, force_bulk=False)[source]#
New in version 4.1.0.
Purges a given amount of messages from a channel. You can specify a check function to exclude specific messages.
Warning
Calling this method can lead to rate-limits when purging higher amounts of messages.
def check_pinned(message): return not message.pinned # This returns `True` only if the message is the message is not pinned await channel.purge(100, check=check_pinned) # This will delete the newest 100 messages that are not pinned in that channel
- Parameters:
amount (int) – The amount of messages to delete
check (Optional[Callable[[Any], Union[bool, Awaitable[bool]]]]) – The function used to check if a message should be deleted. The message is only deleted if the check returns True
before (Optional[int]) – An id of a message to purge only messages before that message
bulk (Optional[bool]) –
Whether to use the bulk delete endpoint for deleting messages. This only works for 14 days
Changed in version 4.4.0: Purge now automatically continues deleting messages even after the 14 days limit was hit. Check
force_bulk
for more information. If the 14 days span is exceeded the bot will encounter rate-limits more frequently.reason (Optional[st]) – The reason of the deletes
force_bulk (Optional[bool]) –
New in version 4.4.0: Whether to stop deleting messages when the 14 days bulk limit was hit, default
False
- Returns:
A list of the deleted messages
- Return type:
List[Message]
- async create_thread(name, type=ChannelType.PUBLIC_THREAD, auto_archive_duration=<interactions.MISSING>, invitable=<interactions.MISSING>, message_id=<interactions.MISSING>, reason=None)[source]#
New in version 4.1.0.
Creates a thread in the Channel.
- Parameters:
name (str) – The name of the thread
auto_archive_duration (Optional[int]) – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
type (Optional[ChannelType]) – The type of thread, defaults to public. ignored if creating thread from a message
invitable (Optional[bool]) – Boolean to display if the Thread is open to join or private.
message_id (Optional[Union[int, Snowflake, Message]]) – An optional message to create a thread from.
reason (Optional[str]) – An optional reason for the audit log
- Returns:
The created thread
- Return type:
- async create_invite(max_age=86400, max_uses=0, temporary=False, unique=False, target_type=<interactions.MISSING>, target_user_id=<interactions.MISSING>, target_application_id=<interactions.MISSING>, reason=None)[source]#
Creates an invite for the channel
- Parameters:
max_age (Optional[int]) – Duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days). Default 86400 (24h)
max_uses (Optional[int]) – Max number of uses or 0 for unlimited. between 0 and 100. Default 0
temporary (Optional[bool]) – Whether this invite only grants temporary membership. Default False
unique (Optional[bool]) – If true, don’t try to reuse a similar invite (useful for creating many unique one time use invites). Default False
target_type (Optional[InviteTargetType]) – The type of target for this voice channel invite
target_user_id (Optional[int]) – The id of the user whose stream to display for this invite, required if target_type is STREAM, the user must be streaming in the channel
target_application_id (Optional[int]) – The id of the embedded application to open for this invite, required if target_type is EMBEDDED_APPLICATION, the application must have the EMBEDDED flag
reason (Optional[str]) – The reason for the creation of the invite
- Return type:
- async get_history(limit=100)[source]#
New in version 4.2.0.
Deprecated since version 4.3.2: Use the
history()
method insteadGets messages from the channel’s history.
- async get_members()[source]#
New in version 4.3.0.
Gets the list of thread members
- Returns:
The members of the thread.
- Return type:
List[ThreadMember]
- async create_tag(name, emoji_id=<interactions.MISSING>, emoji_name=<interactions.MISSING>)[source]#
New in version 4.3.2.
Create a new tag.
Note
Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.
- async edit_tag(tag_id, name, emoji_name=<interactions.MISSING>, emoji_id=<interactions.MISSING>)[source]#
New in version 4.3.2.
Edits a tag
Note
Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.
- async create_forum_post(name, content, auto_archive_duration=<interactions.MISSING>, applied_tags=<interactions.MISSING>, files=<interactions.MISSING>, rate_limit_per_user=<interactions.MISSING>, reason=None)[source]#
New in version 4.3.2.
Creates a new post inside a forum channel
- Parameters:
name (str) – The name of the thread
auto_archive_duration (Optional[int]) – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
content (Union[dict, Message, str, Attachment, List[Attachment]]) – The content to send as first message.
applied_tags (Union[List[str], List[int], List[Tags], int, str, Tags]) – Tags to give to the created thread
files (Optional[List[File]]) – An optional list of files to send attached to the message.
rate_limit_per_user (Optional[int]) – Seconds a user has to wait before sending another message (0 to 21600), if given.
reason (Optional[str]) – An optional reason for the audit log
- Returns:
A channel of type
ChannelType.PUBLIC_THREAD
- Return type:
- async get_permissions_for(member)[source]#
New in version 4.3.2.
Returns the permissions of the member in this specific channel.
Note
The permissions returned by this function take into account role and user overwrites that can be assigned to channels or categories. If you don’t need these overwrites, look into
Member.get_guild_permissions()
.- Parameters:
member (Member) – The member to get the permissions from
- Returns:
Permissions of the member in this channel
- Return type:
- async add_permission_overwrite(id, type=<interactions.MISSING>, allow=<interactions.MISSING>, deny=<interactions.MISSING>, reason=None)[source]#
New in version 4.4.0.
Adds a permission overwrite to the channel.
- Parameters:
id (Union[int, str, Snowflake, User, Role]) – The ID of the User/Role to create the overwrite on.
type (Optional[Literal[0, 1, "0", "1"]]) – The type of the overwrite. 0 for Role 1 for User.
allow (Optional[Union[int, Permissions, str]]) – Permissions to allow
deny (Optional[Union[int, Permissions, str]]) – Permissions to deny
reason (Optional[str]) – The reason to be shown in the audit log
- Returns:
The updated channel
- Return type:
- async add_permission_overwrites(overwrites, reason=None)[source]#
New in version 4.4.0.
Add multiple overwrites to the channel.
- async overwrite_permission_overwrites(overwrites, reason=None)[source]#
New in version 4.4.0.
Overwrites the overwrites of the channel with new overwrites.
- class interactions.api.models.channel.ThreadMember(kwargs_dict=None, /, **other_kwargs)[source]#
A class object representing a member in a thread.
Note
id
only shows if there are active intents involved with the member in the thread.- Variables:
id (Optional[Snowflake]) – The “ID” or intents of the member.
user_id (Snowflake) – The user ID of the member.
join_timestamp (datetime) – The timestamp of when the member joined the thread.
flags (int) – The bitshift flags for the member in the thread.
muted (bool) – Whether the member is muted or not.
- class interactions.api.models.channel.ThreadMetadata(kwargs_dict=None, /, **other_kwargs)[source]#
A class object representing the metadata of a thread.
Note
invitable
will only show if the thread can have an invited created with the current cached permissions.- Variables:
archived (bool) – The current thread accessibility state.
auto_archive_duration (int) – The auto-archive time.
archive_timestamp (datetime) – The timestamp that the thread will be/has been closed at.
locked (bool) – The current message state of the thread.
invitable (Optional[bool]) – The ability to invite users to the thread.
- class interactions.api.models.channel.AsyncHistoryIterator(_client, obj, maximum=inf, start_at=<interactions.MISSING>, check=None, reverse=False)[source]#
New in version 4.3.2.
A class object that allows iterating through a channel’s history.
- Parameters:
_client (HTTPClient) – The HTTPClient of the bot
obj (Union[int, str, Snowflake, Channel]) – The channel to get the history from
start_at (Optional[Union[int, str, Snowflake, Message]]) – The message to begin getting the history from
reverse (Optional[bool]) – Whether to only get newer message. Default False
check (Optional[Callable[[Message], Union[bool, Awaitable[bool]]]]) – A check to ignore certain messages
maximum (Optional[int]) – A set maximum of messages to get before stopping the iteration
- class interactions.api.models.channel.AsyncTypingContextManager(obj, _client)[source]#
New in version 4.3.2.
An async context manager for triggering typing.
- class interactions.api.models.channel.Tags(kwargs_dict=None, /, **other_kwargs)[source]#
New in version 4.3.2.
An object denoting a tag object within a forum channel.
Note
If the emoji is custom, it won’t have name information.
- Variables:
name (str) – Name of the tag. The limit is up to 20 characters.
id (Snowflake) – ID of the tag. Can also be 0 if manually created.
moderated (bool) – A boolean denoting whether this tag can be removed/added by moderators with the
Permissions.MANAGE_THREADS
permission.emoji_name (Optional[str]) – The unicode character of the emoji.
emoji_id (Optional[Snowflake]) – The id of a guild’s custom emoji.
- async edit(channel_id, name, emoji_name=<interactions.MISSING>, emoji_id=<interactions.MISSING>)[source]#
Edits this tag
Note
Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.
- Parameters:
- Returns:
The modified tag
- Return type: